query for balance and get the amount of funds available for trading or funds locked in orders https://ascendex.github.io/ascendex-pro-api/#cash-account-balance https://ascendex.github.io/ascendex-pro-api/#margin-account-balance https://ascendex.github.io/ascendex-fu
(self, params={})
| 966 | return self.safe_balance(result) |
| 967 | |
| 968 | async def fetch_balance(self, params={}) -> Balances: |
| 969 | """ |
| 970 | query for balance and get the amount of funds available for trading or funds locked in orders |
| 971 | |
| 972 | https://ascendex.github.io/ascendex-pro-api/#cash-account-balance |
| 973 | https://ascendex.github.io/ascendex-pro-api/#margin-account-balance |
| 974 | https://ascendex.github.io/ascendex-futures-pro-api-v2/#position |
| 975 | |
| 976 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 977 | :param str [params.type]: wallet type, 'spot', 'margin', or 'swap' |
| 978 | :param str [params.marginMode]: 'cross' or None, for spot margin trading, value of 'isolated' is invalid |
| 979 | :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>` |
| 980 | """ |
| 981 | await self.load_markets() |
| 982 | await self.load_accounts() |
| 983 | marketType = None |
| 984 | marginMode = None |
| 985 | marketType, params = self.handle_market_type_and_params('fetchBalance', None, params) |
| 986 | marginMode, params = self.handle_margin_mode_and_params('fetchBalance', params) |
| 987 | isMargin = self.safe_bool(params, 'margin', False) |
| 988 | isCross = marginMode == 'cross' |
| 989 | marketType = 'margin' if (isMargin or isCross) else marketType |
| 990 | params = self.omit(params, 'margin') |
| 991 | accountsByType = self.safe_dict(self.options, 'accountsByType', {}) |
| 992 | accountCategory = self.safe_string(accountsByType, marketType, 'cash') |
| 993 | account = self.safe_dict(self.accounts, 0, {}) |
| 994 | accountGroup = self.safe_string(account, 'id') |
| 995 | request = { |
| 996 | 'account-group': accountGroup, |
| 997 | } |
| 998 | if (marginMode == 'isolated') and (marketType != 'swap'): |
| 999 | raise BadRequest(self.id + ' does not supported isolated margin trading') |
| 1000 | if (accountCategory == 'cash') or (accountCategory == 'margin'): |
| 1001 | request['account-category'] = accountCategory |
| 1002 | response = None |
| 1003 | if (marketType == 'spot') or (marketType == 'margin'): |
| 1004 | response = await self.v1PrivateAccountCategoryGetBalance(self.extend(request, params)) |
| 1005 | elif marketType == 'swap': |
| 1006 | response = await self.v2PrivateAccountGroupGetFuturesPosition(self.extend(request, params)) |
| 1007 | else: |
| 1008 | raise NotSupported(self.id + ' fetchBalance() is not currently supported for ' + marketType + ' markets') |
| 1009 | # |
| 1010 | # cash |
| 1011 | # |
| 1012 | # { |
| 1013 | # "code": 0, |
| 1014 | # "data": [ |
| 1015 | # { |
| 1016 | # "asset": "BCHSV", |
| 1017 | # "totalBalance": "64.298000048", |
| 1018 | # "availableBalance": "64.298000048", |
| 1019 | # }, |
| 1020 | # ] |
| 1021 | # } |
| 1022 | # |
| 1023 | # margin |
| 1024 | # |
| 1025 | # { |
nothing calls this directly
no test coverage detected