Keyboard Shortcuts
Likes
Search
Error 110. The price does not conform to the minimum price variation for this contract
Hi All,
There is a topic on this subject from 2016.? It just doesn't seem to add up. I tried to place a bracket Sell Order for NIO thru the API.? This is the output from my logs: BKT Entry order??? STPLMT Shr:290 Limit:38.96 Aux:38.96 BKT Profit order?? LMT??? Shr:290 Limit:35.16 BKT StopLoss order STPLMT Shr:290 Limit:45.40 Aux:41.40 and received the error on the BKT StopLoss order STPLMT Shr:290 Limit:45.40 Aux:41.40 Error 110. The price does not conform to the minimum price variation for this contract The Entry and Profit order both went thru just fine. I received this simultaneously on the test and production systems. Thanks and be well, Lou Dudka |
Nick
You can check the api log to see what was actually sent to IB.
toggle quoted message
Show quoted text
Depending on the language and how floating point numbers are converted to text their may be differences in rounding from what you show in your logs. The api log should help you track down the issue (either sending an invalid price or an issue on IB's end). On 10/22/2021 6:50 PM, Lou Dudka wrote:
and received the error on the BKT StopLoss order STPLMT Shr:290 Limit:45.40 Aux:41.40 |
That was my first reaction as well. The ? say: ´³¨¹°ù²µ±ð²Ô On Fri, Oct 22, 2021 at 06:09 PM, Nick wrote: ... |
Thank you, Lou. Glad we pointed you in the right direction. You won;t be able to "round yourself" out of the problem completely. Even double precision floating point math can be pretty tricky and randomly generates very imprecise results in certain cases. Take the 35.16, for example (one of your prices). Here a couple example with Java double values:
It is common practice in financial software to use a Decimal or fixed point data type instead of? float and double. In fact IBKR introduced a Decimal data type in TWS API 10.10 and changed the size fields for many objects from double to Decimal (probably for crypto support). Interesting though that they left all price fields unchanged as double. Here the results with a Java decimal type:
Internally, we use a Decimal type for all our applications as well. Makes calculations a little more cumbersome to code but makes for much better and controlled outcomes. |