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

Method fetch_paginated_call_deterministic

python/ccxt/base/exchange.py:7660–7691  ·  view source on GitHub ↗
(self, method: str, symbol: Str = None, since: Int = None, limit: Int = None, timeframe: Str = None, params={}, maxEntriesPerRequest: Int = None)

Source from the content-addressed store, hash-verified

7658 return []
7659
7660 def fetch_paginated_call_deterministic(self, method: str, symbol: Str = None, since: Int = None, limit: Int = None, timeframe: Str = None, params={}, maxEntriesPerRequest: Int = None):
7661 maxCalls = None
7662 maxCalls, params = self.handle_option_and_params(params, method, 'paginationCalls', 10)
7663 maxEntriesPerRequest, params = self.handle_max_entries_per_request_and_params(method, maxEntriesPerRequest, params)
7664 current = self.milliseconds()
7665 tasks = []
7666 time = self.parse_timeframe(timeframe) * 1000
7667 step = time * maxEntriesPerRequest
7668 currentSince = current - (maxCalls * step) - 1
7669 if since is not None:
7670 currentSince = max(currentSince, since)
7671 else:
7672 currentSince = max(currentSince, 1241440531000) # avoid timestamps older than 2009
7673 until = self.safe_integer_2(params, 'until', 'till') # do not omit it here
7674 if until is not None:
7675 requiredCalls = int(math.ceil((until - since)) / step)
7676 if requiredCalls > maxCalls:
7677 raise BadRequest(self.id + ' the number of required calls is greater than the max number of calls allowed, either increase the paginationCalls or decrease the since-until gap. Current paginationCalls limit is ' + str(maxCalls) + ' required calls is ' + str(requiredCalls))
7678 for i in range(0, maxCalls):
7679 if (until is not None) and (currentSince >= until):
7680 break
7681 if currentSince >= current:
7682 break
7683 tasks.append(self.safe_deterministic_call(method, symbol, currentSince, maxEntriesPerRequest, timeframe, params))
7684 currentSince = self.sum(currentSince, step) - 1
7685 results = tasks
7686 result = []
7687 for i in range(0, len(results)):
7688 result = self.array_concat(result, results[i])
7689 uniqueResults = self.remove_repeated_elements_from_array(result)
7690 key = 0 if (method == 'fetchOHLCV') else 'timestamp'
7691 return self.filter_by_since_limit(uniqueResults, since, limit, key)
7692
7693 def fetch_paginated_call_cursor(self, method: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}, cursorReceived: Str = None, cursorSent: Str = None, cursorIncrement: Int = None, maxEntriesPerRequest: Int = None):
7694 maxCalls = None

Callers 15

fetch_ohlcvMethod · 0.45
fetch_ohlcvMethod · 0.45
fetch_ohlcvMethod · 0.45
fetch_ohlcvMethod · 0.45
fetch_ohlcvMethod · 0.45
fetch_utaohlcvMethod · 0.45
fetch_spot_ohlcvMethod · 0.45
fetch_contract_ohlcvMethod · 0.45
fetch_ohlcvMethod · 0.45

Calls 14

millisecondsMethod · 0.95
parse_timeframeMethod · 0.95
safe_integer_2Method · 0.95
sumMethod · 0.95
array_concatMethod · 0.95
filter_by_since_limitMethod · 0.95
BadRequestClass · 0.90
maxFunction · 0.50

Tested by

no test coverage detected