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

Method parse_spot_balance

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

Source from the content-addressed store, hash-verified

1945 }, market)
1946
1947 def parse_spot_balance(self, response):
1948 #
1949 # {
1950 # "code":0,
1951 # "msg":"",
1952 # "data":[
1953 # {
1954 # "currency":"USDT",
1955 # "balanceEv":0,
1956 # "lockedTradingBalanceEv":0,
1957 # "lockedWithdrawEv":0,
1958 # "lastUpdateTimeNs":1592065834511322514,
1959 # "walletVid":0
1960 # },
1961 # {
1962 # "currency":"ETH",
1963 # "balanceEv":0,
1964 # "lockedTradingBalanceEv":0,
1965 # "lockedWithdrawEv":0,
1966 # "lastUpdateTimeNs":1592065834511322514,
1967 # "walletVid":0
1968 # }
1969 # ]
1970 # }
1971 #
1972 timestamp = None
1973 result = {'info': response}
1974 data = self.safe_value(response, 'data', [])
1975 for i in range(0, len(data)):
1976 balance = data[i]
1977 currencyId = self.safe_string(balance, 'currency')
1978 code = self.safe_currency_code(currencyId)
1979 currency = self.safe_value(self.currencies, code, {})
1980 scale = self.safe_integer(currency, 'valueScale', 8)
1981 account = self.account()
1982 balanceEv = self.safe_string(balance, 'balanceEv')
1983 lockedTradingBalanceEv = self.safe_string(balance, 'lockedTradingBalanceEv')
1984 lockedWithdrawEv = self.safe_string(balance, 'lockedWithdrawEv')
1985 total = self.from_en(balanceEv, scale)
1986 lockedTradingBalance = self.from_en(lockedTradingBalanceEv, scale)
1987 lockedWithdraw = self.from_en(lockedWithdrawEv, scale)
1988 used = Precise.string_add(lockedTradingBalance, lockedWithdraw)
1989 lastUpdateTimeNs = self.safe_integer_product(balance, 'lastUpdateTimeNs', 0.000001)
1990 timestamp = lastUpdateTimeNs if (timestamp is None) else max(timestamp, lastUpdateTimeNs)
1991 account['total'] = total
1992 account['used'] = used
1993 result[code] = account
1994 result['timestamp'] = timestamp
1995 result['datetime'] = self.iso8601(timestamp)
1996 return self.safe_balance(result)
1997
1998 def parse_swap_balance(self, response):
1999 # usdt

Callers 1

fetch_balanceMethod · 0.95

Calls 12

from_enMethod · 0.95
safe_valueMethod · 0.80
safe_stringMethod · 0.80
safe_integerMethod · 0.80
string_addMethod · 0.80
safe_integer_productMethod · 0.80
safe_balanceMethod · 0.80
rangeFunction · 0.50
maxFunction · 0.50
safe_currency_codeMethod · 0.45
accountMethod · 0.45
iso8601Method · 0.45

Tested by

no test coverage detected