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

Method fetch_paginated_call_cursor

python/ccxt/base/exchange.py:7693–7753  ·  view source on GitHub ↗
(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)

Source from the content-addressed store, hash-verified

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
7695 maxCalls, params = self.handle_option_and_params(params, method, 'paginationCalls', 10)
7696 maxRetries = None
7697 maxRetries, params = self.handle_option_and_params(params, method, 'maxRetries', 3)
7698 maxEntriesPerRequest, params = self.handle_max_entries_per_request_and_params(method, maxEntriesPerRequest, params)
7699 cursorValue = None
7700 i = 0
7701 errors = 0
7702 result = []
7703 timeframe = self.safe_string(params, 'timeframe')
7704 params = self.omit(params, 'timeframe') # reading the timeframe from the method arguments to avoid changing the signature
7705 while(i < maxCalls):
7706 try:
7707 if cursorValue is not None:
7708 if cursorIncrement is not None:
7709 cursorValue = self.parse_to_int(cursorValue) + cursorIncrement
7710 params[cursorSent] = cursorValue
7711 response = None
7712 if method == 'fetchAccounts':
7713 response = getattr(self, method)(params)
7714 elif method == 'getLeverageTiersPaginated' or method == 'fetchPositions':
7715 response = getattr(self, method)(symbol, params)
7716 elif method == 'fetchOpenInterestHistory':
7717 response = getattr(self, method)(symbol, timeframe, since, maxEntriesPerRequest, params)
7718 else:
7719 response = getattr(self, method)(symbol, since, maxEntriesPerRequest, params)
7720 errors = 0
7721 responseLength = len(response)
7722 if self.verbose:
7723 cursorString = '' if (cursorValue is None) else cursorValue
7724 iteration = (i + 1)
7725 cursorMessage = 'Cursor pagination call ' + str(iteration) + ' method ' + method + ' response length ' + str(responseLength) + ' cursor ' + cursorString
7726 self.log(cursorMessage)
7727 if responseLength == 0:
7728 break
7729 result = self.array_concat(result, response)
7730 last = self.safe_dict(response, responseLength - 1)
7731 # cursorValue = self.safe_value(last['info'], cursorReceived)
7732 cursorValue = None # search for the cursor
7733 for j in range(0, responseLength):
7734 index = responseLength - j - 1
7735 entry = self.safe_dict(response, index)
7736 info = self.safe_dict(entry, 'info')
7737 cursor = self.safe_value(info, cursorReceived)
7738 if cursor is not None:
7739 cursorValue = cursor
7740 break
7741 if cursorValue is None:
7742 break
7743 lastTimestamp = self.safe_integer(last, 'timestamp')
7744 if lastTimestamp is not None and lastTimestamp < since:
7745 break
7746 except Exception as e:
7747 errors += 1
7748 if errors > maxRetries:
7749 raise e
7750 i += 1

Callers 15

fetch_orders_classicMethod · 0.45
fetch_open_ordersMethod · 0.45
fetch_my_tradesMethod · 0.45
fetch_depositsMethod · 0.45
fetch_withdrawalsMethod · 0.45
fetch_ledgerMethod · 0.45
fetch_positionsMethod · 0.45
fetch_transfersMethod · 0.45
fetch_my_liquidationsMethod · 0.45

Calls 13

safe_stringMethod · 0.95
omitMethod · 0.95
parse_to_intMethod · 0.95
logMethod · 0.95
array_concatMethod · 0.95
safe_dictMethod · 0.95
safe_valueMethod · 0.95
safe_integerMethod · 0.95
filter_by_since_limitMethod · 0.95

Tested by

no test coverage detected