StopOrder

class saxo_openapi.contrib.orders.stoporder.StopOrder(Uic, Amount, AssetType, OrderPrice, ManualOrder=False, AmountType='Quantity', TakeProfitOnFill=None, StopLossOnFill=None, TrailingStopLossOnFill=None, OrderDurationType='DayOrder', GTDDate=None)

create a StopOrder.

StopOrder is used to build the body for a StopOrder. The body can be used to pass to the Order endpoint.

ALLOWED_DT = ['DayOrder', 'GoodTillDate', 'GoodTillCancel']
__init__(Uic, Amount, AssetType, OrderPrice, ManualOrder=False, AmountType='Quantity', TakeProfitOnFill=None, StopLossOnFill=None, TrailingStopLossOnFill=None, OrderDurationType='DayOrder', GTDDate=None)

Instantiate a StopOrder.

Parameters:
  • Uic (int (required)) – the Uic of the instrument to trade
  • Amount (decimal (required)) – the number of lots/shares/contracts or a monetary value if amountType is set to CashAmount
  • OrderPrice (decimal (required)) – the price indicating the limitprice
  • AssetType (string (required)) – the assettype for the Uic
  • ManualOrder (bool (required)) – flag to identify if an order is from an automated origin, default: False
  • AmountType (AmountType (optional)) – the amountType, defaults to Quantity, see AmountType for other options
  • TakeProfitOnFill (TakeProfitDetails instance or dict) – the take-profit order specification
  • StopLosstOnFill (StopLossDetails instance or dict) – the stoploss order specification
  • TrailingStopLosstOnFill (TrailingStopLossDetails instance or dict) – the Trailingstoploss order specification
  • OrderDurationType (string, default DayOrder) – the order duration type, check SAXO Bank specs. for details
  • GTDDate (datetime string (required if order duration is GoodTillDate)) – the GTD-datetime

Example

>>> import json
>>> from saxo_openapi import API
>>> import saxo_openapi.endpoints.trading as tr
>>> from saxo_openapi.contrib.orders import StopOrder
>>>
>>> so = StopOrder(Uic=21,
...                 AssetType=OD.AssetType.FxSpot,
...                 Amount=10000,
...                 OrderPrice=1.1025)
>>> print(json.dumps(so.data, indent=2))
{
  "Uic": 21,
  "AssetType": "FxSpot",
  "Amount": 10000,
  "Price": 1.1025,
  "BuySell": "Buy",
  "OrderType": "Stop",
  "ManualOrder": false,
  "AmountType": "Quantity",
  "OrderDuration": {
     "DurationType": "DayOrder"
  }
}
>>> # now we have the order specification, create the order request
>>> r = tr.orders.Order(data=so.data)
>>> # perform the request
>>> rv = client.request(r)
>>> print(rv)
>>> print(json.dumps(rv, indent=4))
{
   "OrderId": "76697286"
}
data

data property.

return the JSON body.

hndOnFill(TakeProfitOnFill=None, StopLossOnFill=None, TrailingStopLossOnFill=None)
toJSON()