Aug-03-2022, 04:45 AM
Hi everyone,
When I try to sell it gives me error: APIError(code=-2010): Account has insufficient balance for requested action. Even though I should have enough balance left to pay for the fees. What can possibly be wrong with my code ?
Here is my sell code:
When I try to sell it gives me error: APIError(code=-2010): Account has insufficient balance for requested action. Even though I should have enough balance left to pay for the fees. What can possibly be wrong with my code ?
Here is my sell code:
pr = client.get_symbol_ticker(symbol=symbol) price=float(pr['price']) bal = client.get_asset_balance(asset='RIF') quantity = ((float(bal['free'])) / price) # 0.995 sym_info = client.get_symbol_info(symbol) filters = sym_info['filters'] for f in filters: print("filter~~~~~~~~~~~~ " + str(f)) if f['filterType'] == 'LOT_SIZE': step_size = float(f['stepSize']) break precision = int(round(-math.log(step_size, 10), 0)) quantity = float(round(quantity*0.99, precision)) order = client.create_order(symbol=symbol, side='SELL', type='MARKET', quantity=quantity)Any help would be much appreciated.