Python Forum
Selling gives me ‘Insufficient balance’ error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Selling gives me ‘Insufficient balance’ error
#1
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:

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.
Reply
#2
Too little code to help. Check the get_asset_balance function

What happens to precision when f['filterType'] does not equal 'LOT_SIZE':

How do you expect to be able to use step_size after a break statement.
Gribouillis likes this post
Reply
#3
(Aug-03-2022, 06:40 PM)woooee Wrote: Too little code to help. Check the get_asset_balance function

What happens to precision when f['filterType'] does not equal 'LOT_SIZE':

How do you expect to be able to use step_size after a break statement.

Thanks, the problem is solved now.

Cheers !
Reply
#4
gerald: Please share your solution so others may benefit.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Balance integer list into multiple list of fixed value xenas 1 2,262 Oct-26-2018, 02:27 AM
Last Post: ichabod801
  Vintage analysis balance forecast HELP! Phoenixmaniac 0 2,384 Sep-10-2018, 03:45 PM
Last Post: Phoenixmaniac
  Balance Data in Python navindran 1 2,483 Aug-06-2018, 10:00 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020