ApiV2 - Invalid Request - Order price has too many digits

Created at 22 Feb 2019, 13:25
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
AB

abierbrauer

Joined 29.01.2019

ApiV2 - Invalid Request - Order price has too many digits
22 Feb 2019, 13:25


Hello,

I'm using the OpenAPI V2 for two weeks now and it works great so far. However, sometimes I'm getting the following error

 

ProtoMessage{OrderErrorResponse{errorCode:INVALID_REQUEST, description:Order price = 1.1339299999999999 has more digits than symbol allows. Allowed 5 digits}}

I know what this error means, it's obvious, but I'm not sending this price information as you can see in the below log output.

 

2/22/2019 2:37:44 AM: MotherTask: create_secure_market_order
2/22/2019 2:37:44 AM: stopLossPrice 1.13393 has digits 5 OK
2/22/2019 2:37:44 AM: takeProfitPrice 1.13089 has digits 5 OK
2/22/2019 2:37:44 AM: performTaskSecureMarketOrder sent position: 55036142 SL: 1.13393 TP: 1.13089
2/22/2019 2:37:44 AM: Received: ProtoMessage{OrderErrorResponse{errorCode:INVALID_REQUEST, description:Order price = 1.1339299999999999 has more digits than symbol allows. Allowed 5 digits}}

 

msgFactory.CreateAmendPositionStopLossTakeProfitRequest is taking DOUBLE datatypes for the stop loss price and the take profit prices. I'm using DOUBLE values and as you can see above I'm also checking if there are too many digits. In 99.9% of the time , the API works flawless but sometimes this error occurs and I dunno why. Are you doing something the value on the server ?

 

Regards, Alex


@abierbrauer
Replies

PanagiotisCharalampous
22 Feb 2019, 14:05

Hi Alex,

Just round the values to the symbol digits and the problem should disappear.

Best Regards,

Panagiotis


@PanagiotisCharalampous

... Deleted by UFO ...