MarketOrder¶
-
class
saxo_openapi.contrib.orders.
MarketOrder
(Uic, Amount, AssetType, ManualOrder=False, AmountType='Quantity', TakeProfitOnFill=None, StopLossOnFill=None, TrailingStopLossOnFill=None)¶ create a MarketOrder.
MarketOrder is used to build the body for a MarketOrder. The body can be used to pass to the Order endpoint.
-
__init__
(Uic, Amount, AssetType, ManualOrder=False, AmountType='Quantity', TakeProfitOnFill=None, StopLossOnFill=None, TrailingStopLossOnFill=None)¶ Instantiate a MarketOrder.
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. A value > 0 means ‘buy’, a value < 0 means ‘sell’
- 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
Example
>>> import json >>> from saxo_openapi import API >>> import saxo_openapi.endpoints.trading as tr >>> from saxo_openapi.contrib.orders import MarketOrder >>> # buy 10k EURUSD (Uic=21) >>> mo = MarketOrder(Uic=21, ... AssetType=OD.AssetType.FxSpot, ... Amount=10000) >>> print(json.dumps(mo.data, indent=4)) { "Uic": 21, "AssetType": "FxSpot", "Amount": 10000, "BuySell": "Buy", "OrderType": "Market", "AmountType": "Quantity", "ManualOrder": False, "OrderDuration": { "DurationType": "DayOrder" } } >>> # now we have the order specification, create the order request >>> r = tr.orders.Order(data=mo.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
()¶
-