MCPcopy Create free account
hub / github.com/ccxt/ccxt / fetch_balance

Method fetch_balance

python/ccxt/async_support/gate.py:2943–3225  ·  view source on GitHub ↗

https://www.gate.com/docs/developers/apiv4/en/#get-unified-account-information https://www.gate.com/docs/developers/apiv4/en/#list-spot-trading-accounts https://www.gate.com/docs/developers/apiv4/en/#margin-account-list https://www.gate.com/docs/developers/apiv4/en/

(self, params={})

Source from the content-addressed store, hash-verified

2941 return account
2942
2943 async def fetch_balance(self, params={}) -> Balances:
2944 """
2945
2946 https://www.gate.com/docs/developers/apiv4/en/#get-unified-account-information
2947 https://www.gate.com/docs/developers/apiv4/en/#list-spot-trading-accounts
2948 https://www.gate.com/docs/developers/apiv4/en/#margin-account-list
2949 https://www.gate.com/docs/developers/apiv4/en/#funding-account-list
2950 https://www.gate.com/docs/developers/apiv4/en/#get-futures-account
2951 https://www.gate.com/docs/developers/apiv4/en/#get-futures-account-2
2952 https://www.gate.com/docs/developers/apiv4/en/#query-account-information
2953
2954 :param dict [params]: exchange specific parameters
2955 :param str [params.type]: spot, margin, swap or future, if not provided self.options['defaultType'] is used
2956 :param str [params.settle]: 'btc' or 'usdt' - settle currency for perpetual swap and future - default="usdt" for swap and "btc" for future
2957 :param str [params.marginMode]: 'cross' or 'isolated' - marginMode for margin trading if not provided self.options['defaultMarginMode'] is used
2958 :param str [params.symbol]: margin only - unified ccxt symbol
2959 :param boolean [params.unifiedAccount]: default False, set to True for fetching the unified account balance
2960 :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>`
2961 """
2962 await self.load_markets()
2963 await self.load_unified_status()
2964 symbol = self.safe_string(params, 'symbol')
2965 params = self.omit(params, 'symbol')
2966 isUnifiedAccount = False
2967 isUnifiedAccount, params = self.handle_option_and_params(params, 'fetchBalance', 'unifiedAccount')
2968 type, query = self.handle_market_type_and_params('fetchBalance', None, params)
2969 request, requestParams = self.prepare_request(None, type, query)
2970 marginMode, requestQuery = self.get_margin_mode(False, requestParams)
2971 if symbol is not None:
2972 market = self.market(symbol)
2973 request['currency_pair'] = market['id']
2974 response: dict
2975 if isUnifiedAccount:
2976 response = await self.privateUnifiedGetAccounts(self.extend(request, params))
2977 elif type == 'spot':
2978 if marginMode == 'spot':
2979 response = await self.privateSpotGetAccounts(self.extend(request, requestQuery))
2980 elif marginMode == 'margin':
2981 response = await self.privateMarginGetAccounts(self.extend(request, requestQuery))
2982 elif marginMode == 'cross_margin':
2983 response = await self.privateMarginGetCrossAccounts(self.extend(request, requestQuery))
2984 else:
2985 raise NotSupported(self.id + ' fetchBalance() not support self marginMode')
2986 elif type == 'funding':
2987 response = await self.privateMarginGetFundingAccounts(self.extend(request, requestQuery))
2988 elif type == 'swap':
2989 response = await self.privateFuturesGetSettleAccounts(self.extend(request, requestQuery))
2990 elif type == 'future':
2991 response = await self.privateDeliveryGetSettleAccounts(self.extend(request, requestQuery))
2992 elif type == 'option':
2993 response = await self.privateOptionsGetAccounts(self.extend(request, requestQuery))
2994 else:
2995 raise NotSupported(self.id + ' fetchBalance() not support self market type')
2996 contract = ((type == 'swap') or (type == 'future') or (type == 'option'))
2997 if contract:
2998 response = [response]
2999 #
3000 # Spot / margin funding

Callers

nothing calls this directly

Tested by

no test coverage detected