Commit fd18e4c
committed
Fix order preview reporting for more order types
This has been broken for years and it was finally tracked down thanks to
contributor in #42.
Problem was just the value we compared against is the raw IBKR API
protocol value, but the comparison was expecting a parsed standard max
float value we use everywhere else.
Solution is just to parse the inbound float so it becomes a native value
to compare against first.
The impact of the problem was `whatIf` orders only worked for limit
orders previously. Attempting to run a preview `whatIf` order on other
order types always just returned bad values and couldn't show previews
and wouldn't report potential commission or margin impacts. Now the
`whatIf` orders run and execute fully so the caller receives a
completely populated `OrderState` object with all fields properly
populated.
According to the API patterns, these fields are _always_ numeric from
the API (which is why IBKR just uses "max float" to mean "no data") so
we should _always_ be able to `float()` parse the field without any
problems. If the API ever returns non-float-data then this will
obviously do weird things, but so far the upstream IBKR API doesn't
appear to be able to inject non-float values into these fields.
Fixes #421 parent 4a10847 commit fd18e4c
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
495 | 495 | | |
496 | 496 | | |
497 | 497 | | |
498 | | - | |
| 498 | + | |
499 | 499 | | |
500 | 500 | | |
501 | 501 | | |
| |||
0 commit comments