Closed msarm closed 4 years ago
Finally, I figured out the issue with my code: passed the ClientExtensions, TakeProfitDetails & StopLossOnFill object as object and now converted to JSON string using "data" property.
takeProfitOnFillOrder = TakeProfitDetails(price=takeProfit)
stopLossOnFill = StopLossDetails(price=stopLoss)
clientExtensions= ClientExtensions(clientID="123", clientTag="ABC", clientComment = "new stratagy" )
client = oandapyV20.API(access_token=apikey, environment=environment)
ordr = LimitOrderRequest(instrument=instrument,
units=units,
price= openPrice,
takeProfitOnFill=takeProfitOnFillOrder.data,
stopLossOnFill=stopLossOnFill.data,
clientExtensions=clientExtensions.data
)
r = orders.OrderCreate(accountID = account, data=ordr.data)
rv = client.request(r)
print(r.response)
Getting errors that JSON is not serializable for ClientExtensions, TakeProfitDetails & StopLossOnFill
Here is the code used to create LimitOrderRequest: