Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Margin is insufficient" - I have plenty of margin. #9

Open
XMVZ opened this issue Jun 8, 2021 · 8 comments
Open

"Margin is insufficient" - I have plenty of margin. #9

XMVZ opened this issue Jun 8, 2021 · 8 comments

Comments

@XMVZ
Copy link

XMVZ commented Jun 8, 2021

Please help.. I have plenty of margin room.

{"code":-2019,"msg":"Margin is insufficient."} Encountered Exception ('ExecuteError', '[Executing] -2019: Margin is insufficient.') Traceback (most recent call last): File "C:\Users\mxwo\Documents\Apps\binance_futures_bot\bot.py", line 47, in <module> qty, side, in_position = bf.handle_signal(client, std, File "C:\Users\mxwo\Documents\Apps\binance_futures_bot\bot_functions.py", line 218, in handle_signal execute_order(client, _qty=qty, _side=order_side, _market=market) File "C:\Users\mxwo\Documents\Apps\binance_futures_bot\bot_functions.py", line 107, in execute_order client.post_order(symbol=_market, File "C:\Users\mxwo\Documents\Programs\lib\site-packages\binance_f\requestclient.py", line 246, in post_order response = call_sync(self.request_impl.post_order(symbol, side, ordertype, File "C:\Users\mxwo\Documents\Programs\lib\site-packages\binance_f\impl\restapiinvoker.py", line 44, in call_sync check_response(json_wrapper) File "C:\Users\mxwo\Documents\Programs\lib\site-packages\binance_f\impl\restapiinvoker.py", line 21, in check_response raise BinanceApiException(BinanceApiException.EXEC_ERROR, "[Executing] " + str(code) + ": " + msg) binance_f.exception.binanceapiexception.BinanceApiException: ('ExecuteError', '[Executing] -2019: Margin is insufficient.')

@XMVZ
Copy link
Author

XMVZ commented Jun 8, 2021

When I bring it down to 1x it works fine..
However, another question. If it opens a trade (IE SELL: 4.0 $37.902) and the price doesn't hit that/does not fill and continues to go down, does the bot reset? When does it reset? Or does it ever move on past that signal?

Thanks!

@XMVZ
Copy link
Author

XMVZ commented Jun 8, 2021

Looks like trades are occuring via Binance, but nothing is really being printed to console..

@XMVZ
Copy link
Author

XMVZ commented Jun 8, 2021

How does one follow updates in addition to all of these questions?

@XMVZ
Copy link
Author

XMVZ commented Jun 8, 2021

And without changing anything it now does not work at all.

@Nai-mul
Copy link

Nai-mul commented Jun 13, 2021

In bot_function.py you need to change qty = 0.1 or something your portfolio persent. In bot_function.py change cross leverage to isolated. then in settings.json change margin type isolated.

@Hephyrius
Copy link
Owner

In bot_function.py you need to change qty = 0.1 or something your portfolio persent. In bot_function.py change cross leverage to isolated. then in settings.json change margin type isolated.

when I get some time i'll see if i can make this simpler.

@abuvanth
Copy link

facing the same issue

@kosmetron
Copy link

In my case the "Margin is insufficient." error was occurring when the bot tries to place a trailing stop loss order, following the initial long or short position.

I was able to prevent this from happening by leaving some percentage of the total margin available in the wallet. Effectively, changed the calculate_position_size bot function to not use 99% of the total margin when opening the initial position. Done this by modifying line 119 in bot_functions.py:

From:
qty = round(qty * 0.99,8)

To:
qty = round(qty * 0.74,8)

And also using ISOLATED margin_type in settings.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants