StopLossOrderRequest¶
-
class
oandapyV20.contrib.requests.
StopLossOrderRequest
(tradeID, price, clientTradeID=None, timeInForce='GTC', gtdTime=None, clientExtensions=None)¶ Bases:
oandapyV20.contrib.requests.baserequest.BaseRequest
create a StopLossOrderRequest.
StopLossOrderRequest is used to build the body for a StopLossOrder. The body can be used to pass to the OrderCreate endpoint.
-
__init__
(tradeID, price, clientTradeID=None, timeInForce='GTC', gtdTime=None, clientExtensions=None)¶ Instantiate a StopLossOrderRequest.
Parameters: - tradeID (string (required)) – the tradeID of an existing trade
- price (float (required)) – the treshold price indicating the price to close the order
Example
>>> import json >>> from oandapyV20 import API >>> import oandapyV20.endpoints.orders as orders >>> from oandapyV20.contrib.requests import StopLossOrderRequest >>> >>> accountID = "..." >>> client = API(access_token=...) >>> ordr = StopLossOrderRequest(tradeID="1234", price=1.07) >>> print(json.dumps(ordr.data, indent=4)) { "order": { "type": "STOP_LOSS", "tradeID": "1234", "price": "1.07000", "timeInForce": "GTC", } } >>> # now we have the order specification, create the order request >>> r = orders.OrderCreate(accountID, data=ordr.data) >>> # perform the request >>> rv = client.request(r) >>> print(json.dumps(rv, indent=4)) >>> ...
-
data
¶ data property.
return the JSON body.
-