As you can see below, I have one trade of EUR_USD.
[IN]
instrument = "EUR_USD"
params = {"instrument" : instrument}
r = trades.TradesList(accountID=accountID, params=params)
client.request(r)
[OUT]
{'lastTransactionID': '191',
'trades': [{'currentUnits': '300',
'financing': '-0.0034',
'id': '160',
'initialMarginRequired': '3.3922',
'initialUnits': '300',
'instrument': 'EUR_USD',
'marginUsed': '3.3946',
'openTime': '2018-11-30T18:25:27.729105653Z',
'price': '1.13079',
'realizedPL': '0.0000',
'state': 'OPEN',
'stopLossOrder': {'createTime': '2018-11-30T18:32:46.972901259Z',
'guaranteed': False,
'id': '166',
'price': '1.10000',
'state': 'PENDING',
'timeInForce': 'GTC',
'tradeID': '160',
'triggerCondition': 'DEFAULT',
'type': 'STOP_LOSS'},
'takeProfitOrder': {'createTime': '2018-11-30T18:32:46.972901259Z',
'id': '165',
'price': '1.15000',
'state': 'PENDING',
'timeInForce': 'GTC',
'tradeID': '160',
'triggerCondition': 'DEFAULT',
'type': 'TAKE_PROFIT'},
'unrealizedPL': '0.0750'}]}
Then, Iย would like to modify above trades' extension with trade id : 160, right?
[IN]
data = {"clientExtensions" : {
"comment": "myComment",
"id": "myxxxxx"
}
}
r = trades.TradeClientExtensions(accountID=accountID,tradeID=160,data=data)
client.request(r)
And what I got was:
[OUT]
V20Error: {"tradeClientExtensionsModifyRejectTransaction":{"type":"TRADE_CLIENT_EXTENSIONS_MODIFY_REJECT","rejectReason":"CLIENT_TRADE_ID_ALREADY_EXISTS","tradeID":"160","tradeClientExtensionsModify":{"id":"myxxxxx","comment":"myComment"},"id":"192","accountID":"101-011-8015835-002","userID":8015835,"batchID":"192","requestID":"78532062367077888","time":"2018-12-01T03:05:39.625695065Z"},"relatedTransactionIDs":["192"],"lastTransactionID":"192","errorMessage":"The client Trade ID specifed is already assigned to another open Trade","errorCode":"CLIENT_TRADE_ID_ALREADY_EXISTS"}
It said "CLIENT_TRADE_ID_ALREADY_EXISTS".
I understood it but if I would like to modify some trades' extensions, the trade should be exist, right?
I think I must lose in some point.
Please kindly advise me.
Thank you very much.