Binance: amount_to_lots() overly precise
See original GitHub issue- OS: Mac
- Programming Language version: Python 3.6
- CCXT version: 1.10.837
- Exchange: Binance
- Method: amount_to_lots()
I’m trying to buy 1.01 ETH/USDT
. To avoid the order amount should be evenly divisible by lot
error, I convert the order amount using amount_to_lots()
before placing the order.
I’ve been trying to follow this issue: https://github.com/ccxt/ccxt/issues/663, but I’m not sure to understand the conclusion. Should I even call amount_to_lots()
before my order, or should I just make sure that the order amount is not below the lot size?
In this case, CCXT tells me that the lot size for ETH/USDT
is 1e-05 (which is suspiciously small). As a result, the output of amount_to_lots()
is 1.0099. Ordering 1.0099 ETH/USDT
works but it only fills 1.0098 without any errors or warning.
When I skip amount_to_lots()
and directly order 1.01 ETH/USDT, it works. This confirms my assumption that the lot size is incorrect.
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (13 by maintainers)
@mkutny we are making an all-in-one prototype function for this, and will add modules (in C++ V8, precompiled for speed for Node.js and Python) later.
https://github.com/ccxt/ccxt/blob/master/js/base/functions/number.js
We are going to transpile to compiled languages as well (namely, c/cpp, go and probably rust).
@fredfortier yep, fixing it now. The problem is decoupling the truncation logic, fixing it and making it work seamlessly and universally for all exchanges, but we are almost there… Thanks for your patience!