Closed gaborvecsei closed 2 years ago
Thanks for opening an issue!
In this case this should be expected behavior. Notice that when placing an order on Coinbase in the web interface, there is only a certain number of decimals you can put in your order size. In this case Coinbase enforces a maximum resolution of 1e-8 of your base currency.
You created an order for 0.008585614459548448 base, which has a higher resolution than coinbase allows. We enforce the resolutions in the backtest so that you can be confident your live model will also be able to accurately submit orders.
This is why we built blankly.trunc()
.
Try wrapping your market orders to look like this:
state.interface.market_order(symbol, side="buy", size=blankly.trunc(buy, 8))
state.interface.market_order(symbol, side='sell', size=blankly.trunc(curr_value, 8))
This will enforce an 8 decimal accuracy and truncate higher accuracy decimals.
I recommend viewing the order filter we're checking with by doing:
print(state.interface.get_order_filter(symbol))
I will add a recommendation to use blankly.trunc
to the error!
@EmersonDove Thank you for the explanation and for extending the documentation!
Description
Some problem with the order size. Seems like we can't buy fractional coins?
Of course it can easily happen that I misunderstood something, but then a more verbose error would be better
settings.json
backtest.json (if applicable)
Error (if applicable)
Platform Info
This was the quick test code which produced the error: