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

Method parse_ledger_entry

python/ccxt/gate.py:7130–7210  ·  view source on GitHub ↗
(self, item: dict, currency: Currency = None)

Source from the content-addressed store, hash-verified

7128 return self.parse_ledger(response, currency, since, limit)
7129
7130 def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
7131 #
7132 # spot
7133 #
7134 # {
7135 # "id": "123456",
7136 # "time": 1547633726123,
7137 # "currency": "BTC",
7138 # "change": "1.03",
7139 # "balance": "4.59316525194",
7140 # "type": "margin_in"
7141 # }
7142 #
7143 # margin
7144 #
7145 # {
7146 # "id": "123456",
7147 # "time": "1547633726",
7148 # "time_ms": 1547633726123,
7149 # "currency": "BTC",
7150 # "currency_pair": "BTC_USDT",
7151 # "change": "1.03",
7152 # "balance": "4.59316525194"
7153 # }
7154 #
7155 # swap and future
7156 #
7157 # {
7158 # "time": 1682294400.123456,
7159 # "change": "0.000010152188",
7160 # "balance": "4.59316525194",
7161 # "text": "ETH_USD:6086261",
7162 # "type": "fee"
7163 # }
7164 #
7165 # option
7166 #
7167 # {
7168 # "time": 1685594770,
7169 # "change": "3.33",
7170 # "balance": "29.87911771",
7171 # "text": "BTC_USDT-20230602-26500-C:2611026125",
7172 # "type": "prem"
7173 # }
7174 #
7175 direction = None
7176 amount = self.safe_string(item, 'change')
7177 if Precise.string_lt(amount, '0'):
7178 direction = 'out'
7179 amount = Precise.string_abs(amount)
7180 else:
7181 direction = 'in'
7182 currencyId = self.safe_string(item, 'currency')
7183 currency = self.safe_currency(currencyId, currency)
7184 type = self.safe_string(item, 'type')
7185 rawTimestamp = self.safe_string(item, 'time')
7186 timestamp = None
7187 if len(rawTimestamp) > 10:

Callers

nothing calls this directly

Calls 11

safe_stringMethod · 0.80
string_ltMethod · 0.80
string_absMethod · 0.80
safe_currencyMethod · 0.80
parse_numberMethod · 0.80
string_subMethod · 0.80
safe_ledger_entryMethod · 0.80
safe_numberMethod · 0.80
safe_currency_codeMethod · 0.45
iso8601Method · 0.45

Tested by

no test coverage detected