You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been looking at the truncation issue too. JordanMandel - while your approach looks good to me, why not bypass the whole issue and pass the price as a string? Oh wait, the docs say
You can sidestep this entire process by passing your price as a string, although be forewarned that TDAmeritrade may reject your order or even interpret it in unexpected ways.
Does anyone know the circumstances where the TDAmeritrade weirdness happens? Fetched quotes routinely arrive with 4 decimals places of precision - eg 77.1234. Would placing a buy_limit order using the string "77.1234" ever give unexpected results?
Description of Bug
Certain price values (such as 5.06) are not respected when creating a limit order
Code to Reproduce
Expected Behavior
The resulting order should have a limit price of 5.06
Actual Behavior
Instead, the limit order has a price of 5.05
The error is in
truncate_float
due to floating point rounding errors.Notice how
flt * 100
is505.99999999999994
. A possible fix might be to add a small epsilon value (haven't tested negative values though):The text was updated successfully, but these errors were encountered: