binance {"code":-1013,"msg":"Invalid price."}
See original GitHub issue- OS: macosx
- Programming Language version: python
- CCXT version: 1.18.412
- Exchange: binance
- Method: create_limit_sell_order
Cxxt is working very well (limit buy/sell orders) on many pairs (with different price precisions) but I have issues with some pairs like BTT/BTC SC/BTC.
So I tried to harcode the price I provide to ccxt in order to see where this {“code”:-1013,“msg”:“Invalid price.”} error is coming from
With harcoded price: 0.00000125
Price is truncated in the request: price=0.000001 (working but wrong price)
Request: POST https://api.binance.com/api/v3/order {'X-MBX-APIKEY': ‘xxxx’, 'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'python-requests/2.19.1', 'Accept-Encoding': 'gzip, deflate'} timestamp=xxxx&recvWindow=5000&symbol=BTTBTC&quantity=6491&type=LIMIT&side=SELL&newOrderRespType=RESULT&price=0.000001&timeInForce=GTC&signature=xxxxx
With harcoded price: 0.00000025
Price is truncated in the request: price=0 (failing)
Request: POST https://api.binance.com/api/v3/order {'X-MBX-APIKEY': ‘xxx’, 'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'python-requests/2.19.1', 'Accept-Encoding': 'gzip, deflate'} timestamp=xxxx&recvWindow=5000&symbol=BTTBTC&quantity=6491&type=LIMIT&side=SELL&newOrderRespType=RESULT&price=0&timeInForce=GTC&signature=xxxx
Response: POST https://api.binance.com/api/v3/order 400 (...) {"code":-1013,"msg":"Invalid price."}
it’s looks like price_to_precision
is not working correctly. What you see in the two request is what is return by this method (I tested manually myself)
EDIT: orders are now working by changing part of this ccxt code: https://github.com/0slab/ccxt/blob/master/python/ccxt/binance.py#L799
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:24 (13 by maintainers)
I added a log in
base/exchange.py
and looks like your internal parameters are always good:I will work on the snippet in coming days, it require some works 😉
Hello @kroitor,
You right my github fork was not up to date. This is now the case, I tried again without my fix and this is what I get (as proof, I added a printed value “test_416” in my fork to check that I’m using the last version"):
2019-03-30 18:12:56,736 - BOT - INFO - API call: Sell amount 8312.0 at price 0.00000020. test_416
Request: POST https://api.binance.com/api/v3/order {'X-MBX-APIKEY': 'xxx', 'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'python-requests/2.19.1', 'Accept-Encoding': 'gzip, deflate'} timestamp=xxxx&recvWindow=5000&symbol=BTTBTC&quantity=8312&type=LIMIT&side=SELL&newOrderRespType=RESULT&price=0&timeInForce=GTC&signature=xxxx
Response: POST https://api.binance.com/api/v3/order 400 (...) {"code":-1013,"msg":"Invalid price."}
2019-03-30 18:12:57,250 - BOT - WARNING - Unable to sell trade: Could not create limit sell order on market BTT/BTC.Tried to sell amount 8312.0 at rate 0.00000020 .Message: binance {"code":-1013,"msg":"Invalid price."}
So to make my code working, I need to replace this line: https://github.com/ccxt/ccxt/blob/master/python/ccxt/binance.py#L799
With that: https://github.com/0slab/ccxt/blob/master/python/ccxt/binance.py#L800