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

Method fetch_ledger

python/ccxt/async_support/bybit.py:5880–6049  ·  view source on GitHub ↗

fetch the history of changes, actions done by the user or operations that altered the balance of the user https://bybit-exchange.github.io/docs/v5/account/transaction-log https://bybit-exchange.github.io/docs/v5/account/contract-transaction-log :param str [code]: u

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

Source from the content-addressed store, hash-verified

5878 }
5879
5880 async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
5881 """
5882 fetch the history of changes, actions done by the user or operations that altered the balance of the user
5883
5884 https://bybit-exchange.github.io/docs/v5/account/transaction-log
5885 https://bybit-exchange.github.io/docs/v5/account/contract-transaction-log
5886
5887 :param str [code]: unified currency code, default is None
5888 :param int [since]: timestamp in ms of the earliest ledger entry, default is None
5889 :param int [limit]: max number of ledger entries to return, default is None
5890 :param dict [params]: extra parameters specific to the exchange API endpoint
5891 :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)
5892 :param str [params.subType]: if inverse will use v5/account/contract-transaction-log
5893 :returns dict: a `ledger structure <https://docs.ccxt.com/?id=ledger-entry-structure>`
5894 """
5895 await self.load_markets()
5896 paginate = False
5897 paginate, params = self.handle_option_and_params(params, 'fetchLedger', 'paginate')
5898 if paginate:
5899 return await self.fetch_paginated_call_cursor('fetchLedger', code, since, limit, params, 'nextPageCursor', 'cursor', None, 50)
5900 request = {
5901 # 'coin': currency['id'],
5902 # 'currency': currency['id'], # alias
5903 # 'start_date': self.iso8601(since),
5904 # 'end_date': self.iso8601(until),
5905 # 'wallet_fund_type': 'Deposit', # Withdraw, RealisedPNL, Commission, Refund, Prize, ExchangeOrderWithdraw, ExchangeOrderDeposit
5906 # 'page': 1,
5907 # 'limit': 20, # max 50
5908 # v5 transaction log
5909 # 'accountType': '', Account Type. UNIFIED
5910 # 'category': '', Product type. spot,linear,option
5911 # 'currency': '', Currency
5912 # 'baseCoin': '', BaseCoin. e.g., BTC of BTCPERP
5913 # 'type': '', Types of transaction logs
5914 # 'startTime': 0, The start timestamp(ms)
5915 # 'endTime': 0, The end timestamp(ms)
5916 # 'limit': 0, Limit for data size per page. [1, 50]. Default: 20
5917 # 'cursor': '', Cursor. Used for pagination
5918 }
5919 enableUnified = await self.is_unified_enabled()
5920 currency = None
5921 currencyKey = 'coin'
5922 if enableUnified[1]:
5923 currencyKey = 'currency'
5924 if since is not None:
5925 request['startTime'] = since
5926 else:
5927 if since is not None:
5928 request['start_date'] = self.yyyymmdd(since)
5929 if code is not None:
5930 currency = self.currency(code)
5931 request[currencyKey] = currency['id']
5932 if limit is not None:
5933 request['limit'] = limit
5934 subType = None
5935 subType, params = self.handle_sub_type_and_params('fetchLedger', None, params)
5936 response: dict
5937 if enableUnified[1]:

Callers

nothing calls this directly

Calls 13

is_unified_enabledMethod · 0.95
safe_integerMethod · 0.80
parse_ledgerMethod · 0.80
load_marketsMethod · 0.45
yyyymmddMethod · 0.45
currencyMethod · 0.45

Tested by

no test coverage detected