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

Can't buy or sell on margin - Account has insufficient balance for requested action

Open AzadY1997 opened this issue 3 years ago • 2 comments

Hello,

obviously I checked and have enough money on my account. However I can't buy or sell on margin, it works for spot though.

First of all I had an issue with EUR and LOT_SIZE, so I tried rounding my balance to the last 2 digitis (had to do it on spot and it worked afterwards, so I did the same on margin)

totalEURInMargin = client.get_max_margin_transfer(asset='EUR', isolatedSymbol = 'ADAEUR')
            floatOfBackAmount = float(totalEURInMargin['amount'])
            roundBackAmount = float(round(floatOfBackAmount, 2))
            totalEURInMargin['amount'] = str(roundBackAmount)
            
print(totalEURInMargin['amount'])
            print(price)

            order = client.create_margin_order(symbol='ADAEUR', side = side, type = order_type, timeInForce = TIME_IN_FORCE_GTC, quantity = float(totalEURInMargin['amount']), price = price, isIsolated = True)

Price is being defined somewhere else with insomnia and I set it to 1.1 to limit buy 20 contracts, manually it works obviously. But it doesn't work on margin and I tried for hours but can't find a solution. There is enough money on my margin account to buy 20 contracts but apparently its supposed to be insufficient.

Appreciate any help, thank you

AzadY1997 avatar Jun 08 '21 13:06 AzadY1997

Having the same issue, when trying to place an order I'm getting APIError(code=-2019): Margin is insufficient. Tried both with isIsolated True/False. Makes no difference imagen

Karlheinzniebuhr avatar Feb 09 '22 13:02 Karlheinzniebuhr

Solved this by placing the quantity in BTC not in USDT amount. Turns out I was trying to place an order in BTC

client.futures_create_order(
    symbol='BTCUSDT',
    side='BUY',
    type='MARKET',
    quantity=0.001,
    isIsolated='FALSE')

Karlheinzniebuhr avatar Mar 09 '22 15:03 Karlheinzniebuhr