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

Method parseLedgerEntry

ts/src/cryptocom.ts:2761–2814  ·  view source on GitHub ↗
(item: Dict, currency: Currency = undefined)

Source from the content-addressed store, hash-verified

2759 }
2760
2761 parseLedgerEntry (item: Dict, currency: Currency = undefined): LedgerEntry {
2762 //
2763 // {
2764 // "account_id": "ce075cef-1234-4321-bd6e-gf9007351e64",
2765 // "event_date": "2023-06-15",
2766 // "journal_type": "TRADING",
2767 // "journal_id": "6530219460124075091",
2768 // "transaction_qty": "6.0091224",
2769 // "transaction_cost": "6.0091224",
2770 // "realized_pnl": "0",
2771 // "order_id": "6530219477766741833",
2772 // "trade_id": "6530219495775954765",
2773 // "trade_match_id": "4611686018455865176",
2774 // "event_timestamp_ms": 1686804665013,
2775 // "event_timestamp_ns": "1686804665013642422",
2776 // "client_oid": "CCXT_d6ea7c5db6c1495aa8b758",
2777 // "taker_side": "",
2778 // "side": "BUY",
2779 // "instrument_name": "USD"
2780 // }
2781 //
2782 const timestamp = this.safeInteger (item, 'event_timestamp_ms');
2783 const currencyId = this.safeString (item, 'instrument_name');
2784 const code = this.safeCurrencyCode (currencyId, currency);
2785 currency = this.safeCurrency (currencyId, currency);
2786 let amount = this.safeString (item, 'transaction_qty');
2787 let direction: Str = undefined;
2788 if (Precise.stringLt (amount, '0')) {
2789 direction = 'out';
2790 amount = Precise.stringAbs (amount);
2791 } else {
2792 direction = 'in';
2793 }
2794 return this.safeLedgerEntry ({
2795 'info': item,
2796 'id': this.safeString (item, 'order_id'),
2797 'direction': direction,
2798 'account': this.safeString (item, 'account_id'),
2799 'referenceId': this.safeString (item, 'trade_id'),
2800 'referenceAccount': this.safeString (item, 'trade_match_id'),
2801 'type': this.parseLedgerEntryType (this.safeString (item, 'journal_type')),
2802 'currency': code,
2803 'amount': this.parseNumber (amount),
2804 'timestamp': timestamp,
2805 'datetime': this.iso8601 (timestamp),
2806 'before': undefined,
2807 'after': undefined,
2808 'status': undefined,
2809 'fee': {
2810 'currency': undefined,
2811 'cost': undefined,
2812 },
2813 }, currency) as LedgerEntry;
2814 }
2815
2816 parseLedgerEntryType (type) {
2817 const ledgerType: Dict = {

Callers

nothing calls this directly

Calls 10

parseLedgerEntryTypeMethod · 0.95
safeIntegerMethod · 0.45
safeStringMethod · 0.45
safeCurrencyCodeMethod · 0.45
safeCurrencyMethod · 0.45
stringLtMethod · 0.45
stringAbsMethod · 0.45
safeLedgerEntryMethod · 0.45
parseNumberMethod · 0.45
iso8601Method · 0.45

Tested by

no test coverage detected