Trading on Fx Options are supported through trading on a quote rather than through an order. It involves getting a price and and then accepting the offer that the price constitutes. Trading on a quote is a bit more involved than placing an order due to the correlation between the time limited offer that the price represents. It is only supported that one application at the time can do trading on quotes on behalf of a user. This is controlled by the TradeLevel on the user's OpenAPI session. To enable a specific OpenAPI session to do this, its TradeLevel has to be elevated to FullTradingAndChat and indirectly forcing all the user's other sessions (if such exist) to go into OrdersOnly-mode.
It is also required to have a tradable price with a QuoteId, which can be obtained through a price subscription. This makes having a streaming connection and a price subscription setup a prerequisite for trading Fx Options through Saxo's OpenAPI.
Setting up a Proper Price Subscription for a Trade
Price can be requested with only a few parameters provided and a sensible set of values will then be assumed for the parameters missing. However, when a price is intended for trading it is strongly recommended that all optional parameters are provided in order to ensure that the resulting trade corresponds to what was intended. In the below example the accountkey, the amount and the strike price represents such parameters:
{ "Arguments": { "AccountKey": "zsnh|NO42RmzjC4oPovKGA==", "AssetType": "FxVanillaOption", "PutCall": "Call", "Uic": 21, "Amount": 10000, "ExpiryDate": "2017-03-01", "StrikePrice": 1.0655, "RequireTradableQuote": true }, "ContextId": "ctx1", "ReferenceId": "x1" }
The result of setting up such a subscription is a snapshot like:
{ "ContextId": "ctx1", "InactivityTimeout": 60, "ReferenceId": "x1", "RefreshRate": 0, "Snapshot": { "AssetType": "FxVanillaOption", "InstrumentPriceDetails": { "ExpiryDate": "2017-03-01", "IsMarketOpen": false, "ShortTradeDisabled": false, "StrikePrice": 1.0655 }, "LastUpdated": "0001-01-01T00:00:00.000000Z", "Quote": { "Amount": 10000, "Ask": 0.00608, "Bid": 0.00497, "DelayedByMinutes": 0, "ErrorCode": "None", "Mid": 0.0055286077533363, "PriceTypeAsk": "Tradable", "PriceTypeBid": "Tradable", "QuoteId": "636229368728284945", "RFQState": "None" }, "Uic": 21 }, "State": "Active" }
The above price represent a valid offer of a trade. This can be seen by price type (in both directions) are Tradable, that the ErrorCode is None and That the quote includes a QuoteId (here "636229368728284945"). The offer is only valid for a very short while, so it is necessary to continuously keep the offer updated with the price updates received over the streaming channel - even if the only changing in a price update is the QuoteId. In the latter case a new QuoteId can be considered an extension on the offer given.
In the section on pricing a few cases are described where the expiry date or strike price is changed in the response compared to the request. Before accepting the offer, the caller should be aware that this can happen and make the decision to accept the offer based on whether the alterations are acceptable. The client is not necessarily seeing a price or getting a position on the expiry date he requested!
The above examples are for Fx Vanilla Options. For Fx OneTouch options and Fx NoTouch options a LowerBarrier or UpperBarrier should be explicitly provided in the price subscription request rather than a strike price.
Placing a Trade
Placing a trade consists of calling the positions endpoint with the received QuoteId to accept the offer implied in the price. This is far simpler than getting the price:
POST https://gateway.saxobank.com/sim/openapi/trade/v1/positions { "BuySell": "Buy", "UserPrice": 0.00608, "QuoteId": "636229368728284945", "ExerciseMethod": "Spot", "ContextId": "ctx1", "PriceReferenceId": "x1" }
The above request accepts the offer by posting the positions endpoint with three parameters referencing the offer received. PriceReferenceId references the price subscription and the QuoteId the specific offer. The request indicates that it is the offer to buy that is accepted and confirms this by also providing the ask price received. If any of these parameters are inconsistent with the received offer, the operation will fail.
In addition to those values, the desired exercise method is also provided. Possible values here are Spot or Cash. Depending on client configuration both may not be valid.
The result of placing a trade is a structure containing the resulting position's id:
HTTP/1.1 201 Created { "PositionId":"182108394" }
Change Exercise Method
The position created has an exercise method that can (for clients on a setup that allows this) later be changed from Spot to Cash or the other way around:
PATCH https://gateway.saxobank.com/sim/openapi/trade/v1/positions/182108394 { "AccountKey": "zsnh|NO42RmzjC4oPovKGA==", "ExerciseMethod": "Cash" }
Placing a Trade to Close a Position
It is possible to place a trade to close an existing position. In order to do that, the initial price subscription must be set up with the ToClosePositionId parameter set to indicate the position to be closed. This feature is still limited by:
- The client has to be on End-of-Day-netting mode
- It won't work if the position is already explicitly partially closed