TradeCRCDO¶
-
class
oandapyV20.endpoints.trades.
TradeCRCDO
(accountID, tradeID, data)¶ Bases:
oandapyV20.endpoints.trades.Trades
Trade Create Replace Cancel Dependent Orders.
-
ENDPOINT
= 'v3/accounts/{accountID}/trades/{tradeID}/orders'¶
-
EXPECTED_STATUS
= 200¶
-
HEADERS
= {'Content-Type': 'application/json'}¶
-
METHOD
= 'PUT'¶
-
__init__
(accountID, tradeID, data)¶ Instantiate a TradeClientExtensions request.
Parameters: - accountID (string (required)) – id of the account to perform the request on.
- tradeID (string (required)) – id of the trade to update client extensions for.
- data (dict (required)) – clientextension data to send, check developer.oanda.com for details.
Data body example:
{ "takeProfit": { "timeInForce": "GTC", "price": "1.05" }, "stopLoss": { "timeInForce": "GTC", "price": "1.10" } }
>>> import oandapyV20 >>> import oandapyV20.endpoints.trades as trades >>> accountID = ... >>> tradeID = ... >>> client = oandapyV20.API(access_token=...) >>> data = { "takeProfit": { "timeInForce": "GTC", "price": "1.05" }, "stopLoss": { "timeInForce": "GTC", "price": "1.10" } }
>>> r = trades.TradeCRCDO(accountID=accountID, >>> tradeID=tradeID, >>> data=data) >>> client.request(r) >>> print r.response
Output:
{ "lastTransactionID": "2327", "stopLossOrderCancelTransaction": { "orderID": "2324", "batchID": "2325", "reason": "CLIENT_REQUEST_REPLACED", "time": "2016-10-28T21:00:19.978476830Z", "type": "ORDER_CANCEL", "replacedByOrderID": "2327", "userID": 1435156, "id": "2326", "accountID": "101-004-1435156-001" }, "stopLossOrderTransaction": { "tradeID": "2323", "price": "1.10000", "timeInForce": "GTC", "reason": "REPLACEMENT", "id": "2327", "batchID": "2325", "triggerCondition": "TRIGGER_DEFAULT", "replacesOrderID": "2324", "userID": 1435156, "time": "2016-10-28T21:00:19.978476830Z", "cancellingTransactionID": "2326", "type": "STOP_LOSS_ORDER", "accountID": "101-004-1435156-001" }, "relatedTransactionIDs": [ "2325", "2326", "2327" ], "takeProfitOrderTransaction": { "tradeID": "2323", "price": "1.05000", "timeInForce": "GTC", "reason": "CLIENT_ORDER", "id": "2325", "batchID": "2325", "triggerCondition": "TRIGGER_DEFAULT", "userID": 1435156, "time": "2016-10-28T21:00:19.978476830Z", "type": "TAKE_PROFIT_ORDER", "accountID": "101-004-1435156-001" } }
-