hootnot/saxo_openapi

StockOptions Order requires "ToOpenClose"

vinutshetty opened this issue · 2 comments

StockOptions Order requires "ToOpenClose" attribute which is not part of the current
saxo_openapi/saxo_openapi/contrib/orders/limitorder.py

OpenAPIError: HTTP error: 400, reason: Bad Request, errorcontent: {"Message":"One or more properties of the request are invalid!","ModelState":{"ToOpenClose":["ToOpenClose must be set to either ToClose or ToOpen when AssetType=FuturesOption,StockIndexOption,StockOption,CfdIndexOption"]},"ErrorCode":"InvalidModelState"}

this also applies for OnFill TakeProfit

Hi,

contrib module contains code to make it a easier to construct orders. It is an add-on and does not directly relate to SAXO-OpenAPI.

It contains a base class LimitOrder and 2 classes derived from that
class:

  • LimitOrderFxSpot
  • LimitOrderStock

At SAXO you can trade a lot of instruments and the contrib module
covers FX and Stock related instrument types.

Feel free to create a LimitOrderOption yourself to handle Options.

Constructing the orderbody as you need it and pass it to
tr.orders.Order(...) as in
https://saxo-openapi.readthedocs.io/en/latest/endpoints/trading/orders/Order.html
should work fine.