Hi,
I am giving automated orders using the spot trade API POST /api/v3/order
- I set the
quoteOrderQty
to a fixed USDT amount for eachBUY
order - The response provides me with a
executedQty
number, which I save into my position model - When my bot gives a sell decision, it sends a sell order to Binance API with
quantity
as theexecutedQty
that was returned before
This sometimes works; but sometimes when selling, I get an insufficient balance error due to the rounded-up quantity returned by Binance.
Let me tell by an example:
- I bought 12$ worth of
IOTAUSDT
via API ('quoteOrderQty': 12
). Binance returned7.7
for theexecutedQty
- When I check my wallet in Binance UI, I have
7.69230000
IOTA
- When I try to sell the position with
quantity=7.7
, I get
{'code': -2010, 'msg': 'Account has insufficient balance for requested action.'}
How can I get around this?
I looked for a command like ‘sell all the coin that was bought with this order ID’ in the API documentation, but I couldn’t find such an option. Is there a specific variable I could send to binance to sell exactly the same amount, or at least the floored amount of it?