python-binance-profit icon indicating copy to clipboard operation
python-binance-profit copied to clipboard

[BUG] Account has insufficient balance for requested action while placing OCO order

Open JulienDev opened this issue 4 years ago • 7 comments

Describe the bug Once the buy order is filled, the script was not able to sell what was bought because of this error :

Account has insufficient balance for requested action while placing

I've placed a 67 SUSHI order but probably because of the finance fees, I was only owning 66.970 SUSHI 🍣

Additional context

The order is not filled yet...
The buy order has been filled!
=========================
=== Buy order summary ===
=> Buy price: 15.360 USDT
=> Total price: 1029.120 USDT
=> Buy quantity: 67.000 SUSHI
=> Step 2 - Sell OCO order execution
Selling price (profit): 16.051
Stoploss price: 14.899
(Code 400) Account has insufficient balance for requested action.
Traceback (most recent call last):
  File "execute_orders.py", line 145, in <module>
    input_args=input_args_validated
  File "execute_orders.py", line 74, in main
    input_args.loss,
  File "/home/pi/python-binance-profit/app/client.py", line 515, in execute_sell_strategy
    sell_orders = sell_order["orderReports"]
KeyError: 'orderReports'

JulienDev avatar Feb 14 '21 12:02 JulienDev

Hey @JulienDev Which buy order did you place? Limit or Market? I'm just trying to understand why you didn't get the quantity you requested with the buy order...

UPetit avatar Feb 16 '21 13:02 UPetit

Limit, always limit :)

JulienDev avatar Feb 16 '21 13:02 JulienDev

@JulienDev @UPetit Found any solution ? I am stuck with the same bug.

Avik-Jain avatar Apr 04 '21 07:04 Avik-Jain

Same problem for me as well. Anyone have a fix for this?

gogetta69 avatar Apr 17 '21 19:04 gogetta69

The problem with fees is that they're paid by following two scenarios:

  • either with BNB if you own some
  • otherwise it's deducted from the assets you just bought

At the second step (sell) of the script, it is expecting to sell the exact quantity that has been bought during the first step of the logic which doesn't seem to be always true...: In case you don't own BNB and we're in the second scenario I've just mentioned, then the quantity you bought is slightly different from the quantity input parameter so the script is trying to sell more than what you really have.

It's not very straightforward to check how you paid your fees for each trade (BNB or not).

I need to evaluate what is the best option here for a fix. The first one I can think of right now is to check the current fees for the crypto pair you selected then calculate the quantity to sell by deducting the estimated fees from the quantity that has been bought.

I'll investigate and try few solutions 🤞

UPetit avatar Apr 17 '21 21:04 UPetit

I can confirm that as long as you have a BNB balance the oco selling works.

gogetta69 avatar Apr 21 '21 19:04 gogetta69

I can confirm that as long as you have a BNB balance the oco selling works.

Makes sense, thanks for checking. The idea is thus to estimate the fees before creating the buy order 👍 I'll see how I can integrate that to the script.

UPetit avatar Apr 23 '21 20:04 UPetit