How do I get Margin wallet balance from 'python-binance' library ?

I think I moved to next step. I’m getting used to spot orders. But now working on getting used to margin trading.

So I was using ‘python-binance’ library but there isn’t any specifically described about margin trading like spot trading. Can anyone guide me how could I use ‘python-binance’ for margin trading.
Here’s the link of documentation of 'python-binance’library : https://python-binance.readthedocs.io/en/latest/margin.html

From the document, this is the method to place an margin order:

https://python-binance.readthedocs.io/en/latest/margin.html#id5

And this endpoint should be triggered to place the order:

https://binance-docs.github.io/apidocs/spot/en/#margin-account-new-order-trade

Hope this will be helpful.

That’s just a limit order, can’t I place OCO. And there isn’t any option to retrieve margin wallet balance of specific coin. And one more thing is, can’t I ‘borrow funds’ at the time of order execution or I’ve to do it separately ?

Margin OCO is not support from API yet.
it’s only allowed to get one symbol balance for isolated margin, for cross margin, it only returns all assets.
You can borrow during placing margin order, sideEffectType=MARGIN_BUY

2 Likes

To stream isolated_margin userData you can use: https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api

ubwa_com_im = BinanceWebSocketApiManager(exchange="binance.com-isolated_margin")

user_stream_id = ubwa_com_im.create_stream('arr', '!userData',  api_key=api_key, api_secret=api_secret, symbol="trxbtc")

Try it with the example file: https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/blob/master/example_userdata_stream_new_style.py

1 Like