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

Method parse_ledger_entry

python/ccxt/bitmex.py:1283–1376  ·  view source on GitHub ↗
(self, item: dict, currency: Currency = None)

Source from the content-addressed store, hash-verified

1281 return self.safe_string(types, type, type)
1282
1283 def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
1284 #
1285 # {
1286 # "transactID": "69573da3-7744-5467-3207-89fd6efe7a47",
1287 # "account": 24321,
1288 # "currency": "XBt",
1289 # "transactType": "Withdrawal", # "AffiliatePayout", "Transfer", "Deposit", "RealisedPNL", ...
1290 # "amount": -1000000,
1291 # "fee": 300000,
1292 # "transactStatus": "Completed", # "Canceled", ...
1293 # "address": "1Ex4fkF4NhQaQdRWNoYpqiPbDBbq18Kdd9",
1294 # "tx": "3BMEX91ZhhKoWtsH9QRb5dNXnmnGpiEetA",
1295 # "text": "",
1296 # "transactTime": "2017-03-21T20:05:14.388Z",
1297 # "walletBalance": 0, # balance after
1298 # "marginBalance": null,
1299 # "timestamp": "2017-03-22T13:09:23.514Z"
1300 # }
1301 #
1302 # ButMEX returns the unrealized pnl from the wallet history endpoint.
1303 # The unrealized pnl transaction has an empty timestamp.
1304 # It is not related to historical pnl it has status set to "Pending".
1305 # Therefore it's not a part of the history at all.
1306 # https://github.com/ccxt/ccxt/issues/6047
1307 #
1308 # {
1309 # "transactID":"00000000-0000-0000-0000-000000000000",
1310 # "account":121210,
1311 # "currency":"XBt",
1312 # "transactType":"UnrealisedPNL",
1313 # "amount":-5508,
1314 # "fee":0,
1315 # "transactStatus":"Pending",
1316 # "address":"XBTUSD",
1317 # "tx":"",
1318 # "text":"",
1319 # "transactTime":null, # ←---------------------------- null
1320 # "walletBalance":139198767,
1321 # "marginBalance":139193259,
1322 # "timestamp":null # ←---------------------------- null
1323 # }
1324 #
1325 id = self.safe_string(item, 'transactID')
1326 account = self.safe_string(item, 'account')
1327 referenceId = self.safe_string(item, 'tx')
1328 referenceAccount = None
1329 type = self.parse_ledger_entry_type(self.safe_string(item, 'transactType'))
1330 currencyId = self.safe_string(item, 'currency')
1331 code = self.safe_currency_code(currencyId, currency)
1332 currency = self.safe_currency(currencyId, currency)
1333 amountString = self.safe_string(item, 'amount')
1334 amount = self.convert_to_real_amount(code, amountString)
1335 timestamp = self.parse8601(self.safe_string(item, 'transactTime'))
1336 if timestamp is None:
1337 # https://github.com/ccxt/ccxt/issues/6047
1338 # set the timestamp to zero, 1970 Jan 1 00:00:00
1339 # for unrealized pnl and other transactions without a timestamp
1340 timestamp = 0 # see comments above

Callers

nothing calls this directly

Calls 13

safe_stringMethod · 0.80
safe_currencyMethod · 0.80
parse_numberMethod · 0.80
string_subMethod · 0.80
string_ltMethod · 0.80
string_absMethod · 0.80
safe_ledger_entryMethod · 0.80
safe_currency_codeMethod · 0.45
parse8601Method · 0.45

Tested by

no test coverage detected