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.39k stars 775 forks source link

APIError(code=-2010): Account has insufficient balance for requested action. #8

Closed 21jake closed 3 years ago

21jake commented 3 years ago

I believe this issue comes from the fact that Binance (sometimes) don't let you sell 100% of some coins.

Untitled

For example I bought 15 CTXCUSDT but can only sell 14.95 of 'em.

One workaround I propose is just sell near 100% of the actual amount the bot bought earlier.

Define this in the user input section

ACTUAL_SELL_RATIO = 99

And In the sell_coins() function:

      try:
            sell_coins_limit = client.create_order(
                symbol=coin,
                side='SELL',
                type='MARKET',
                quantity=(coins_bought[coin]['volume'] * ACTUAL_SELL_RATIO  / 100) 
            )

Also, fuck Binance.

EDIT: The workaround above causes another issues of APIError(code=-1013): Filter failure: LOT_SIZE. So please propose another solution.

CyberPunkMetalHead commented 3 years ago

Thanks for bringing that up! I assume you're on the mainnet? I haven't seen this issue on the testnet, but I did come across before. I've seen other people's workaound is to sell 99.5% of the coin owned. Also, the lot size issue is probably due to the fact that the equation changes the format of the volume. Binance is very weird about the volume format. For example 12.300 XRP would return a LOT_SIZE error while 12.3 is perfectly fine.

I'll think of a way to implement your suggestion without breaking the formatting.

CyberPunkMetalHead commented 3 years ago

Are you able to try this for the sell quantity? quantity=float('{:.{}f}'.format((coins_bought[coin]['volume']*99.5/100), coins_bought[coin]['volume']))

21jake commented 3 years ago

Yes, I'm on mainnet. Not super familar with python tho but I can understand what your code is doing :D And thank you for the solution. I will feedback ASAP.

Truly appreciate what you're doing for the community 🥂

atmar commented 3 years ago

Are you able to try this for the sell quantity? quantity=float('{:.{}f}'.format((coins_bought[coin]['volume']*99.5/100), coins_bought[coin]['volume']))

This is not a valid format to use. And I can't really figure our what format you're going for, but I'm not that well versed in python syntax

CyberPunkMetalHead commented 3 years ago

New commit pushed, this should fix the issue above, feel free to re-open the issue in case it doesn't :)

LewisLebentz commented 3 years ago

@CyberPunkMetalHead it's still broken unfortunately.

APIError(code=-1013): Filter failure: LOT_SIZE