python-binance
python-binance copied to clipboard
Can't buy or sell on margin - Account has insufficient balance for requested action
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
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
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')