ccxt: Wrong sell price for cheap currencies on Binance via freqtrade
- OS: Linux (tested on Centos and SUSE)
- Programming Language version: Python 3.6.3 and Python 3.6.5
- CCXT version: ccxt==1.17.363 and ccxt==1.17.376
- Exchange: Binance
- Method: create_limit_sell_order()
I am using freqtrade and i hit stoploss, but the bot tries to sell at a price higher than current price.
Price of the bid posted on market was 4e-06
Price of the bid posted on market should be 3.73e-06
I am still trying to investigate this together with freqtrade maintainer @xmatthias and up until create_limit_sell_order, the price seems to be correct, but on the market it isn’t. However i was not able to reproduce this directly in freqtrade, so i am asking for help here.
More details (test case used, debug logs) can be found in https://github.com/freqtrade/freqtrade/issues/1289
Debug log:
I am calling create_limit_sell_order with this parameters:
2018-10-20 17:26:52,468 - freqtrade.exchange - DEBUG - Parameters for create_limit_sell_order. pair: POE/BTC, amount: 5549.445, rate: 1.77e-06
Code:
try:
# Set the precision for amount and price(rate) as accepted by the exchange
logger.debug("Rate for sell in exchange/__init__py: %s",rate)
amount = self.symbol_amount_prec(pair, amount)
rate = self.symbol_price_prec(pair, rate)
logger.debug("Rate for sell in exchange/__init__py: %s",rate)
logger.debug("Parameters for create_limit_sell_order. pair: %s, amount: %s, rate: %s",pair,amount,rate)
logger.debug("type(rate): %s",type(rate))
ret = self._api.create_limit_sell_order(pair, amount, rate)
logger.debug("ccxt return: %s", ret)
return ret
but get this output and response from ccxt:
2018-10-20 18:07:12,287 - freqtrade.exchange - DEBUG - Rate for sell in exchange/__init__py: 1.78e-06
2018-10-20 18:07:12,288 - freqtrade.exchange - DEBUG - Price in symbol_price_prec 1.78e-06
2018-10-20 18:07:12,288 - freqtrade.exchange - DEBUG - Rate for sell in exchange/__init__py: 1.78e-06
2018-10-20 18:07:12,288 - freqtrade.exchange - DEBUG - Parameters for create_limit_sell_order. pair: POE/BTC, amount: 5549.445, rate: 1.78e-06
2018-10-20 18:07:12,288 - freqtrade.exchange - DEBUG - type(rate): <class 'float'>
2018-10-20 18:07:12,793 - freqtrade.exchange - DEBUG - ccxt return: {'info': {'symbol': 'POEBTC', 'orderId': 21744127, 'clientOrderId': '', 'transactTime': 1540051632660, 'price': '0.00000200', 'origQty': '5549.00000000', 'executedQty': '0.00000000', 'cummulativeQuoteQty': '0.00000000', 'status': 'NEW', 'timeInForce': 'GTC', 'type': 'LIMIT', 'side': 'SELL'}, 'id': '21744127', 'timestamp': 1540051632660, 'datetime': '2018-10-20T16:07:12.660Z', 'lastTradeTimestamp': None, 'symbol': 'POE/BTC', 'type': 'limit', 'side': 'sell', 'price': 2e-06, 'amount': 5549.0, 'cost': 0.0, 'average': None, 'filled': 0.0, 'remaining': 5549.0, 'status': 'open', 'fee': None, 'trades': None}
Request: POST https://api.binance.com/api/v3/order {'X-MBX-APIKEY': '', 'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'python-requests/2.19.1', 'Accept-Encoding': 'gzip, deflate'} timestamp=1540051632520&recvWindow=5000&symbol=POEBTC&quantity=5549&type=LIMIT&side=SELL&newOrderRespType=RESULT&price=0.000002&timeInForce=GTC&signature=
Response: POST https://api.binance.com/api/v3/order 200 {'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Date': 'Sat, 20 Oct 2018 16:07:12 GMT', 'Server': 'nginx', 'Content-Encoding': 'gzip', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains', 'X-Frame-Options': 'SAMEORIGIN', 'X-Xss-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Content-Security-Policy': "default-src 'self'", 'X-Content-Security-Policy': "default-src 'self'", 'X-WebKit-CSP': "default-src 'self'", 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Cache': 'Miss from cloudfront', 'Via': '1.1 2e8f70eb03b681aa6bd8c18fff081f80.cloudfront.net (CloudFront)', 'X-Amz-Cf-Id': ''} {"symbol":"POEBTC","orderId":21744127,"clientOrderId":"","transactTime":1540051632660,"price":"0.00000200","origQty":"5549.00000000","executedQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"SELL"}
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 21 (13 by maintainers)
Confirmed by @xmatthias , the issue is caused by changing context precision in freqtrade persistence api.
Thanks @kroitor and @xmatthias for help