OpenAPI

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.

"Format": {
  "Decimals": 4,
  "Format": "AllowDecimalPips",
}

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
  • Fractions
  • 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

Examples

This sections show examples on how prices are formatted in SaxoTrader GO. The actual values and format information is modified to illustrate the point:

ValueExample InstrumentAssetTypeFormatNumeratorDecimalsDecimalsShown As
1.08905EURUSDFxSpotAllowDecimalPips
41.09805
123.80900USDJPYFxSpotAllowDecimalPips
2123,809
13.43230XAGEURFxSpotNormal
213.43
0.2498EURUSDFxOneTouchOptionPercentage
224.98%
213.20000DANSKE:xcseStockNormal
2213.20
213.20000DANSKE:xcseCfdOnStockNormal
3213.200
154.03125UBZ5ContractFutureModernFractions05154'01
154.03125UBZ5ContractFutureFractions05154 1/32
125.43750ZNZ5ContractFutureModernFractions06125-28
125.43750ZNZ5ContractFuturesFractions06125 28/64
119.21094ZFU5ContractFuturesModernFractions25119'06,75
119.21094ZFU5ContractFuturesFractions25119 6,76/32
126.25000ZNU5ContractFuturesModernFractions16126-08,0
126.25000ZNU5ContractFuturesFractions16126 8,0/32

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.


See also the live sample on price formatting (with source).