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

Method fetch_ledger

python/ccxt/coinbase.py:2455–2493  ·  view source on GitHub ↗

Fetch the history of changes, i.e. actions done by the user or operations that altered the balance. Will return staking rewards, and crypto deposits or withdrawals. https://docs.cdp.coinbase.com/coinbase-app/track-apis/transactions :param str [code]: unified currency code,

(self, code: Str = None, since: Int = None, limit: Int = None, params={})

Source from the content-addressed store, hash-verified

2453 return self.parse_custom_balance(response, params)
2454
2455 def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
2456 """
2457 Fetch the history of changes, i.e. actions done by the user or operations that altered the balance. Will return staking rewards, and crypto deposits or withdrawals.
2458
2459 https://docs.cdp.coinbase.com/coinbase-app/track-apis/transactions
2460
2461 :param str [code]: unified currency code, default is None
2462 :param int [since]: timestamp in ms of the earliest ledger entry, default is None
2463 :param int [limit]: max number of ledger entries to return, default is None
2464 :param dict [params]: extra parameters specific to the exchange API endpoint
2465 :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2466 :returns dict: a `ledger structure <https://docs.ccxt.com/?id=ledger-entry-structure>`
2467 """
2468 self.load_markets()
2469 paginate = False
2470 paginate, params = self.handle_option_and_params(params, 'fetchLedger', 'paginate')
2471 if paginate:
2472 return self.fetch_paginated_call_cursor('fetchLedger', code, since, limit, params, 'next_starting_after', 'starting_after', None, 100)
2473 currency = None
2474 if code is not None:
2475 currency = self.currency(code)
2476 request = None
2477 request, params = self.prepare_account_request_with_currency_code(code, limit, params)
2478 # for pagination use parameter 'starting_after'
2479 # the value for the next page can be obtained from the result of the previous call in the 'pagination' field
2480 # eg: instance.last_http_response -> pagination.next_starting_after
2481 response = self.v2PrivateGetAccountsAccountIdTransactions(self.extend(request, params))
2482 ledger = self.parse_ledger(response['data'], currency, since, limit)
2483 length = len(ledger)
2484 if length == 0:
2485 return ledger
2486 lastIndex = length - 1
2487 last = self.safe_dict(ledger, lastIndex)
2488 pagination = self.safe_dict(response, 'pagination', {})
2489 cursor = self.safe_string(pagination, 'next_starting_after')
2490 if (cursor is not None) and (cursor != ''):
2491 last['info']['next_starting_after'] = cursor
2492 ledger[lastIndex] = last
2493 return ledger
2494
2495 def parse_ledger_entry_status(self, status):
2496 types = {

Callers

nothing calls this directly

Calls 10

parse_ledgerMethod · 0.80
safe_dictMethod · 0.80
safe_stringMethod · 0.80
load_marketsMethod · 0.45
currencyMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected