OrderReplace¶
-
class
oandapyV20.endpoints.orders.
OrderReplace
(accountID, orderID, data)¶ Bases:
oandapyV20.endpoints.orders.Orders
OrderReplace.
Replace an Order in an Account by simultaneously cancelling it and creating a replacement Order.
-
ENDPOINT
= 'v3/accounts/{accountID}/orders/{orderID}'¶
-
EXPECTED_STATUS
= 201¶
-
HEADERS
= {'Content-Type': 'application/json'}¶
-
METHOD
= 'PUT'¶
-
__init__
(accountID, orderID, data)¶ Instantiate an OrderReplace request.
Parameters: - accountID (string (required)) – id of the account to perform the request on.
- orderID (string (required)) – id of the order to perform the request on.
- data (JSON (required)) – json orderbody to send
Orderbody example:
{ "order": { "units": "-500000", "instrument": "EUR_USD", "price": "1.25000", "type": "LIMIT" } }
>>> import oandapyV20 >>> import oandapyV20.endpoints.orders as orders >>> client = oandapyV20.API(access_token=...) >>> data = { "order": { "units": "-500000", "instrument": "EUR_USD", "price": "1.25000", "type": "LIMIT" } }
>>> r = orders.OrderReplace(accountID=..., orderID=..., data=data) >>> client.request(r) >>> print r.response
Output:
{ "orderCreateTransaction": { "price": "1.25000", "timeInForce": "GTC", "reason": "REPLACEMENT", "clientExtensions": { "comment": "myComment", "id": "myID" }, "id": "2307", "batchID": "2306", "triggerCondition": "TRIGGER_DEFAULT", "replacesOrderID": "2304", "positionFill": "DEFAULT", "userID": 1435156, "instrument": "EUR_USD", "time": "2016-10-25T19:45:38.558056359Z", "units": "-500000", "type": "LIMIT_ORDER", "accountID": "101-004-1435156-001" }, "orderCancelTransaction": { "orderID": "2304", "clientOrderID": "myID", "reason": "CLIENT_REQUEST_REPLACED", "batchID": "2306", "time": "2016-10-25T19:45:38.558056359Z", "type": "ORDER_CANCEL", "replacedByOrderID": "2307", "userID": 1435156, "id": "2306", "accountID": "101-004-1435156-001" }, "lastTransactionID": "2307", "relatedTransactionIDs": [ "2306", "2307" ] }
-