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

Method fetch_ledger

python/ccxt/binance.py:11307–11395  ·  view source on GitHub ↗

fetch the history of changes, actions done by the user or operations that altered the balance of the user https://developers.binance.com/docs/derivatives/option/account/Account-Funding-Flow https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-a

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

Source from the content-addressed store, hash-verified

11305 return self.parse_ledger_entry(first, currency)
11306
11307 def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
11308 """
11309 fetch the history of changes, actions done by the user or operations that altered the balance of the user
11310
11311 https://developers.binance.com/docs/derivatives/option/account/Account-Funding-Flow
11312 https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Get-Income-History
11313 https://developers.binance.com/docs/derivatives/coin-margined-futures/account/rest-api/Get-Income-History
11314 https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Income-History
11315 https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Income-History
11316
11317 :param str [code]: unified currency code
11318 :param int [since]: timestamp in ms of the earliest ledger entry
11319 :param int [limit]: max number of ledger entries to return
11320 :param dict [params]: extra parameters specific to the exchange API endpoint
11321 :param int [params.until]: timestamp in ms of the latest ledger entry
11322 :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)
11323 :param boolean [params.portfolioMargin]: set to True if you would like to fetch the ledger for a portfolio margin account
11324 :param str [params.subType]: "linear" or "inverse"
11325 :returns dict: a `ledger structure <https://docs.ccxt.com/?id=ledger-entry-structure>`
11326 """
11327 self.load_markets()
11328 paginate = False
11329 paginate, params = self.handle_option_and_params(params, 'fetchLedger', 'paginate')
11330 if paginate:
11331 return self.fetch_paginated_call_dynamic('fetchLedger', code, since, limit, params, None, False)
11332 type = None
11333 subType = None
11334 currency = None
11335 if code is not None:
11336 currency = self.currency(code)
11337 request = {}
11338 type, params = self.handle_market_type_and_params('fetchLedger', None, params)
11339 subType, params = self.handle_sub_type_and_params('fetchLedger', None, params)
11340 if since is not None:
11341 request['startTime'] = since
11342 if limit is not None:
11343 request['limit'] = limit
11344 until = self.safe_integer(params, 'until')
11345 if until is not None:
11346 params = self.omit(params, 'until')
11347 request['endTime'] = until
11348 isPortfolioMargin = None
11349 isPortfolioMargin, params = self.handle_option_and_params_2(params, 'fetchLedger', 'papi', 'portfolioMargin', False)
11350 response = None
11351 if type == 'option':
11352 self.check_required_argument('fetchLedger', code, 'code')
11353 request['currency'] = currency['id']
11354 response = self.eapiPrivateGetBill(self.extend(request, params))
11355 elif self.is_linear(type, subType):
11356 if isPortfolioMargin:
11357 response = self.papiGetUmIncome(self.extend(request, params))
11358 else:
11359 response = self.fapiPrivateGetIncome(self.extend(request, params))
11360 elif self.is_inverse(type, subType):
11361 if isPortfolioMargin:
11362 response = self.papiGetCmIncome(self.extend(request, params))
11363 else:
11364 response = self.dapiPrivateGetIncome(self.extend(request, params))

Callers

nothing calls this directly

Calls 15

eapiPrivateGetBillMethod · 0.95
is_linearMethod · 0.95
papiGetUmIncomeMethod · 0.95
fapiPrivateGetIncomeMethod · 0.95
is_inverseMethod · 0.95
papiGetCmIncomeMethod · 0.95
dapiPrivateGetIncomeMethod · 0.95
NotSupportedClass · 0.90
safe_integerMethod · 0.80

Tested by

no test coverage detected