def get_balances_list(self) -> List[Balance]: balances = [] for data in self.private_get('/getbalance'): currency = self.rcurrencies[data['currency_code']] balance = Balance(balance_type=BalanceType.MAIN, currency=currency, total=data['amount'], locked=data['amount'] - data['available'], _data=data) balances.append(balance) for data in self.private_get('/getcollateralaccounts'): currency = self.rcurrencies[data['currency_code']] balance = Balance(balance_type=BalanceType.MARGIN, currency=currency, total=data['amount'], _data=data) balances.append(balance) return balances
def get_balances(self) -> Dict[str, Dict[str, Balance]]: balances: dict = CaseInsensitiveDict() for data in self.private_get('/accounts/balance'): currency = data['currency'] balances[currency] = Balance(currency=currency, total=float(data['balance']), _data=data) return { BalanceType.MAIN: balances, }
def get_balances_list(self) -> List[Balance]: balances = [] for data in self.private_get('/accounts/balance'): currency = data['currency'] balance = Balance(balance_type=BalanceType.MAIN, currency=currency, total=float(data['balance']), _data=data) balances.append(balance) return balances
def get_balances_list(self, *, params: dict = None) -> List[Balance]: kwargs = params or {} res = self.private_get('/user/assets', **kwargs) balances = [] for asset in res['assets']: currency = self.rcurrencies[asset['asset']] balance = Balance(balance_type=BalanceType.MAIN, currency=currency, total=float(asset['onhand_amount']), locked=float(asset['locked_amount']), _data=asset) balances.append(balance) return balances
def get_balances_list(self) -> List[Balance]: balances = [] res = self.private_get('/user/margin') assert res['currency'] == 'XBt', res total = res['marginBalance'] / 1e8 locked = (res['marginBalance'] - res['availableMargin']) / 1e8 currency = self.rcurrencies[res['currency']] balance = Balance(balance_type=BalanceType.MARGIN, currency=currency, total=total, locked=locked, _data=res) balances.append(balance) return balances
def get_balances_list(self) -> List[Balance]: balances = [] type_map = { 'exchange': BalanceType.MAIN, 'trading': BalanceType.MARGIN, 'deposit': BalanceType.LOAN, } for data in self.private_post('/balances'): assert data['type'] in type_map, data balance_type = type_map[data['type']] currency = self.rcurrencies[data['currency']] balance = Balance(balance_type=balance_type, currency=currency, total=float(data['amount']), locked=float(data['amount']) - float(data['available']), _data=data) balances.append(balance) return balances
def _convert_balance(self, data: list) -> Balance: keys = [ 'wallet_type', 'currency', 'balance', 'unsettled_interest', 'balance_available', ] data = OrderedDict(zip(keys, data), _extra=data[len(keys):]) balance_type = self._balance_type_map.get(data['wallet_type']) currency = self.CURRENCY_MAP.get(data['currency'], data['currency']) total = data['balance'] available = data['balance_available'] if available is not None: locked = total - available else: locked = None return Balance(balance_type=balance_type, currency=currency, total=total, locked=locked, _data=data)