query for balance and get the amount of funds available for trading or funds locked in orders https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#account-information-user_data # spot https://developers.binance.com/docs/margin_trading/accoun
(self, params={})
| 3765 | return result if isolated else self.safe_balance(result) |
| 3766 | |
| 3767 | def fetch_balance(self, params={}) -> Balances: |
| 3768 | """ |
| 3769 | query for balance and get the amount of funds available for trading or funds locked in orders |
| 3770 | |
| 3771 | https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#account-information-user_data # spot |
| 3772 | https://developers.binance.com/docs/margin_trading/account/Query-Cross-Margin-Account-Details # cross margin |
| 3773 | https://developers.binance.com/docs/margin_trading/account/Query-Isolated-Margin-Account-Info # isolated margin |
| 3774 | https://developers.binance.com/docs/wallet/asset/funding-wallet # funding |
| 3775 | https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Futures-Account-Balance-V2 # swap |
| 3776 | https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Futures-Account-Balance # future |
| 3777 | https://developers.binance.com/docs/derivatives/option/account/Option-Account-Information # option |
| 3778 | https://developers.binance.com/docs/derivatives/portfolio-margin/account/Account-Balance # portfolio margin |
| 3779 | |
| 3780 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 3781 | :param str [params.type]: 'future', 'delivery', 'savings', 'funding', or 'spot' or 'papi' |
| 3782 | :param str [params.marginMode]: 'cross' or 'isolated', for margin trading, uses self.options.defaultMarginMode if not passed, defaults to None/None/None |
| 3783 | :param str[]|None [params.symbols]: unified market symbols, only used in isolated margin mode |
| 3784 | :param boolean [params.portfolioMargin]: set to True if you would like to fetch the balance for a portfolio margin account |
| 3785 | :param str [params.subType]: 'linear' or 'inverse' |
| 3786 | :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>` |
| 3787 | """ |
| 3788 | self.load_markets() |
| 3789 | defaultType = self.safe_string_2(self.options, 'fetchBalance', 'defaultType', 'spot') |
| 3790 | type = self.safe_string(params, 'type', defaultType) |
| 3791 | subType = None |
| 3792 | subType, params = self.handle_sub_type_and_params('fetchBalance', None, params) |
| 3793 | isPortfolioMargin = None |
| 3794 | isPortfolioMargin, params = self.handle_option_and_params_2(params, 'fetchBalance', 'papi', 'portfolioMargin', False) |
| 3795 | marginMode = None |
| 3796 | query = None |
| 3797 | marginMode, query = self.handle_margin_mode_and_params('fetchBalance', params) |
| 3798 | query = self.omit(query, 'type') |
| 3799 | response = None |
| 3800 | request = {} |
| 3801 | if isPortfolioMargin or (type == 'papi'): |
| 3802 | if self.is_linear(type, subType): |
| 3803 | type = 'linear' |
| 3804 | elif self.is_inverse(type, subType): |
| 3805 | type = 'inverse' |
| 3806 | isPortfolioMargin = True |
| 3807 | response = self.papiGetBalance(self.extend(request, query)) |
| 3808 | elif self.is_linear(type, subType): |
| 3809 | type = 'linear' |
| 3810 | useV2 = None |
| 3811 | useV2, params = self.handle_option_and_params(params, 'fetchBalance', 'useV2', False) |
| 3812 | params = self.extend(request, query) |
| 3813 | if not useV2: |
| 3814 | response = self.fapiPrivateV3GetAccount(params) |
| 3815 | else: |
| 3816 | response = self.fapiPrivateV2GetAccount(params) |
| 3817 | elif self.is_inverse(type, subType): |
| 3818 | type = 'inverse' |
| 3819 | response = self.dapiPrivateGetAccount(self.extend(request, query)) |
| 3820 | elif marginMode == 'isolated': |
| 3821 | paramSymbols = self.safe_list(params, 'symbols') |
| 3822 | query = self.omit(query, 'symbols') |
| 3823 | if paramSymbols is not None: |
| 3824 | symbols = '' |
nothing calls this directly
no test coverage detected