CyberPunkMetalHead / Binance-volatility-trading-bot

This is a fully functioning Binance trading bot that measures the volatility of every coin on Binance and places trades with the highest gaining coins If you like this project consider donating though the Brave browser to allow me to continuously improve the script.
MIT License
3.41k stars 775 forks source link

crash on sell_coins #32

Closed phroton closed 3 years ago

phroton commented 3 years ago

testnet

TP or SL reached, selling 0.02 BNBUSDT...
Traceback (most recent call last):
  File "Binance Detect Moonings.py", line 320, in <module>
    coins_sold = sell_coins()
  File "Binance Detect Moonings.py", line 247, in sell_coins
    test_order = client.create_test_order(symbol=coin, side='SELL', type='MARKET', quantity=coins_bought[coin]['volume'])
  File "/usr/local/lib/python3.6/dist-packages/binance/client.py", line 1762, in create_test_order
    return self._post('order/test', True, data=params)
  File "/usr/local/lib/python3.6/dist-packages/binance/client.py", line 368, in _post
    return self._request_api('post', path, signed, version, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/binance/client.py", line 328, in _request_api
    return self._request(method, uri, signed, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/binance/client.py", line 309, in _request
    return self._handle_response(self.response)
  File "/usr/local/lib/python3.6/dist-packages/binance/client.py", line 318, in _handle_response
    raise BinanceAPIException(response, response.status_code, response.text)
binance.exceptions.BinanceAPIException: APIError(code=-1013): Filter failure: MIN_NOTIONAL
CyberPunkMetalHead commented 3 years ago

MIN_NOTIONAL errors usually mean you're trying to sell a smaller quantity than what Binance expects, try and run

info = client.get_symbol_info('BNBUSDT')
print(info)
print(info['filters'][2]['minQty'])

to get some details on the symbol

phroton commented 3 years ago
{'symbol': 'BNBUSDT', 'status': 'TRADING', 'baseAsset': 'BNB', 'baseAssetPrecision': 8, 'quoteAsset': 'USDT', 'quotePrecision': 8, 'quoteAssetPrecision': 8, 'baseCommissionPrecision': 8, 'quoteCommissionPrecision': 8, 'orderTypes': ['LIMIT', 'LIMIT_MAKER', 'MARKET', 'STOP_LOSS_LIMIT', 'TAKE_PROFIT_LIMIT'], 'icebergAllowed': True, 'ocoAllowed': True, 'quoteOrderQtyMarketAllowed': True, 'isSpotTradingAllowed': True, 'isMarginTradingAllowed': False, 'filters': [{'filterType': 'PRICE_FILTER', 'minPrice': '0.01000000', 'maxPrice': '10000.00000000', 'tickSize': '0.01000000'}, {'filterType': 'PERCENT_PRICE', 'multiplierUp': '5', 'multiplierDown': '0.2', 'avgPriceMins': 5}, {'filterType': 'LOT_SIZE', 'minQty': '0.01000000', 'maxQty': '9000.00000000', 'stepSize': '0.01000000'}, {'filterType': 'MIN_NOTIONAL', 'minNotional': '10.00000000', 'applyToMarket': True, 'avgPriceMins': 5}, {'filterType': 'ICEBERG_PARTS', 'limit': 10}, {'filterType': 'MARKET_LOT_SIZE', 'minQty': '0.00000000', 'maxQty': '1000.00000000', 'stepSize': '0.00000000'}, {'filterType': 'MAX_NUM_ORDERS', 'maxNumOrders': 200}, {'filterType': 'MAX_NUM_ALGO_ORDERS', 'maxNumAlgoOrders': 5}], 'permissions': ['SPOT']}

info['filters'][2]['minQty'] = 0.01000000

the script did try to sell 0.02 in testnet and crashed, hm

CyberPunkMetalHead commented 3 years ago

I have removed the CAPPED SELL SINCE IT DIDN'T HELP, have pushed (hopefully) a stability fix for the sell function.