sammchardy / python-binance

Binance Exchange API python implementation for automated trading
https://python-binance.readthedocs.io/en/latest/
MIT License
5.89k stars 2.2k forks source link

Disable Isolated Margin Accounts #1176

Open A-leonidas opened 2 years ago

A-leonidas commented 2 years ago

Just thought I'd be helpful and post the following:

Currently there is no functionality in this module to disable margin accounts which you need to do in order to trade other margin pairs once you have met your isolated margin account limit (see Binance website for more info on the limit). I have changed the module in a personal copy to include the following:

def disable_isolated_margin_account(self, **params):

    return self._request_margin_api('delete', 'margin/isolated/account', signed=True, data=params)

async def disable_isolated_margin_account(self, **params):
    return await self._request_margin_api('delete', 'margin/isolated/account', signed=True, data=params)

The above changes now allow functionality to disable accounts via this API. Just thought I'd flag in case owner wanted to implement a similar update.

old-flat-company commented 1 year ago

Just thought I'd be helpful and post the following:

Currently there is no functionality in this module to disable margin accounts which you need to do in order to trade other margin pairs once you have met your isolated margin account limit (see Binance website for more info on the limit). I have changed the module in a personal copy to include the following:

def disable_isolated_margin_account(self, **params):

    return self._request_margin_api('delete', 'margin/isolated/account', signed=True, data=params)

async def disable_isolated_margin_account(self, **params):
    return await self._request_margin_api('delete', 'margin/isolated/account', signed=True, data=params)

The above changes now allow functionality to disable accounts via this API. Just thought I'd flag in case owner wanted to implement a similar update.

Thanks ))

old-flat-company commented 1 year ago

Or if you don't want to change a source code of this lib You just can to use this variant


def disable_isolated_margin_account(symbol=''):
    return client._request_margin_api('delete', 'margin/isolated/account', signed=True, data={'symbol': symbol})

disable_isolated_margin_account(symbol='LUNAUSDT')