Prices delivered and received by OpenAPI are always represented by decimal numbers. It is however common to format prices in a certain way. By looking up an instrument in Reference Data, one can find the fields that control formatting.
In addition to the decimals and format keys in the structure, the instrument can also have the following values: NumeratorDecimals, BarrierDecimals & StrikeDecimals
In the format structure the values means the following:
Decimals - can be anything from 0 and up. Takes on a special meaning for prices quoted in fractions (see explanation on that)
Format - valid values are:
- Normal - if absent, this value can be assumed
- AllowDecimalPips - common on Fx instruments. Introduces an extra valid decimal called the deci-pip
- ModernFractions - common on futures on US Bonds
- Percentage - used for FxOneTouchOption and FxNoTouchOption
NumeratorDecimals - provided when format is either fractions or ModernFractions. Indicates how many decimals are shown in the numerator value in a fraction
StrikeDecimals - used for FxVanillaOptions to indicate how many decimals should be used when setting or showing a FxVanillaOption's strike price
BarrierDecimals - used for FxOneTouchOptions & FxNoTouchOptions to indicate how many decimals should be used when setting or showing the options barrier price
This sections show examples on how prices are formatted in SaxoTrader GO. The actual values and format information is modified to illustrate the point:
|Value||Example Instrument||AssetType||Format||NumeratorDecimals||Decimals||Shown As|
Dealing with Percentages
Two assettypes are quoted in percentages and should be displayed as such: FxOneTouchOption & FxNoTouchOption. An example can be seen above.
Dealing with Fractions
While the price values received from OpenAPI are always regular decimal numbers, the value in decimals takes on a different meaning when the price is quoted in fractions. In that case decimals can be used to calculate the denominator of the fraction as 2decimals, meaning that a decimals value of 5 equals a denominator of 25=32. I.e. that the price is quoted in 1/32's. So a price like 154.03125 is formatted like 154 for the integer part and 0.03125*25=1 for the numerator in the fraction used to represent non-integer part of the price. Final result is then 154 1/32.
An alternative way of writing fractions is by only providing the numerator part of the fraction. For 1/32's the integer part and the fractional part must then be separated by a apostrophe (') and 1/64's with a dash (-). Examples can be seen above.
In a few cases the value for the numerator can be a decimal number itself. The number of decimals on the numerator is then indicated by the numeratordecimals value.