quoteOrderQty issue

Hi

i have 1000 USDT in my spot wallet.

On the pair HOT/USDT.

i’m trying to place a marker buy order with the ‘cummulativeQuoteQty’ value of my last sell order filled(500 USTD for example) as “quoteOrderQty”.

But the buy order is filled fully with 1000 USDT not 500 USDT.

The piece of my code :

trades_sell_amount_fiat = client.get_all_orders(symbol=‘HOTUSDT’)[-1][‘cummulativeQuoteQty’]
trades_sell_amount_fiat_decimal = Decimal(trades_sell_amount_fiat).quantize(Decimal(‘0’), rounding=decimal.ROUND_DOWN) ## → The last amount value of my sell order (500 USDT)

buyOrder = client.order_market_buy(symbol = pairName, side = ‘buy’, quoteOrderQty = trades_sell_amount_fiat_decimal)

I tried and tested so many times but no success…and that cost me a lot of fees :))

I have also this error message :

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

And despite the error message, the order is still filled and fully.

Please and thanks for your help !

  1. what is the exactly amount of this trades_sell_amount_fiat_decimal when placing market buy order?
  2. Do you have enough amount in your account?

Btw the spot testnet is the place for this testing.
testnet.binance.vision.

Thanks a lot for your answer

The amount of this trades_sell_amount_fiat_decimal is 491 USDT(the amount of the last sell filled order).

My inital spot wallet is 1000 USDT.

The idea is always to use the “cummulativeQuoteQty” (TP or SL inclued) from each sell order closed.

My code works fine but it just doesn’t respect the desired invested amount and use the full USDT spot wallet each time.

Thanks for the binance testnet, I just created my APIs but I can’t find the website, I searched on youtube for a tutorial, nothing either. If you have any advice, I’ll take it!! :wink: