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

Method parse_swap_balance

python/ccxt/async_support/phemex.py:1999–2044  ·  view source on GitHub ↗
(self, response)

Source from the content-addressed store, hash-verified

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

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