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

Method parse_swap_balance

python/ccxt/phemex.py:1998–2043  ·  view source on GitHub ↗
(self, response)

Source from the content-addressed store, hash-verified

1996 return self.safe_balance(result)
1997
1998 def parse_swap_balance(self, response):
1999 # usdt
2000 # {
2001 # "info": {
2002 # "code": "0",
2003 # "msg": '',
2004 # "data": {
2005 # "account": {
2006 # "userID": "940666",
2007 # "accountId": "9406660003",
2008 # "currency": "USDT",
2009 # "accountBalanceRv": "99.93143972",
2010 # "totalUsedBalanceRv": "0.40456",
2011 # "bonusBalanceRv": "0"
2012 # },
2013 # }
2014 #
2015 # {
2016 # "code":0,
2017 # "msg":"",
2018 # "data":{
2019 # "account":{
2020 # "accountId":6192120001,
2021 # "currency":"BTC",
2022 # "accountBalanceEv":1254744,
2023 # "totalUsedBalanceEv":0,
2024 # "bonusBalanceEv":1254744
2025 # }
2026 # }
2027 # }
2028 #
2029 result = {'info': response}
2030 data = self.safe_value(response, 'data', {})
2031 balance = self.safe_value(data, 'account', {})
2032 currencyId = self.safe_string(balance, 'currency')
2033 code = self.safe_currency_code(currencyId)
2034 currency = self.currency(code)
2035 valueScale = self.safe_integer(currency, 'valueScale', 8)
2036 account = self.account()
2037 accountBalanceEv = self.safe_string_2(balance, 'accountBalanceEv', 'accountBalanceRv')
2038 totalUsedBalanceEv = self.safe_string_2(balance, 'totalUsedBalanceEv', 'totalUsedBalanceRv')
2039 needsConversion = (code != 'USDT')
2040 account['total'] = self.from_en(accountBalanceEv, valueScale) if needsConversion else accountBalanceEv
2041 account['used'] = self.from_en(totalUsedBalanceEv, valueScale) if needsConversion else totalUsedBalanceEv
2042 result[code] = account
2043 return self.safe_balance(result)
2044
2045 def fetch_balance(self, params={}) -> Balances:
2046 """

Callers 1

fetch_balanceMethod · 0.95

Calls 9

from_enMethod · 0.95
safe_valueMethod · 0.80
safe_stringMethod · 0.80
safe_integerMethod · 0.80
safe_string_2Method · 0.80
safe_balanceMethod · 0.80
safe_currency_codeMethod · 0.45
currencyMethod · 0.45
accountMethod · 0.45

Tested by

no test coverage detected