(self, method: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}, maxEntriesPerRequest: Int = None, removeRepeated=True)
| 7570 | return [maxEntriesPerRequest, params] |
| 7571 | |
| 7572 | def fetch_paginated_call_dynamic(self, method: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}, maxEntriesPerRequest: Int = None, removeRepeated=True): |
| 7573 | maxCalls = None |
| 7574 | maxCalls, params = self.handle_option_and_params(params, method, 'paginationCalls', 10) |
| 7575 | maxRetries = None |
| 7576 | maxRetries, params = self.handle_option_and_params(params, method, 'maxRetries', 3) |
| 7577 | paginationDirection = None |
| 7578 | paginationDirection, params = self.handle_option_and_params(params, method, 'paginationDirection', 'backward') |
| 7579 | paginationTimestamp = None |
| 7580 | removeRepeatedOption = removeRepeated |
| 7581 | removeRepeatedOption, params = self.handle_option_and_params(params, method, 'removeRepeated', removeRepeated) |
| 7582 | calls = 0 |
| 7583 | result = [] |
| 7584 | errors = 0 |
| 7585 | until = self.safe_integer_n(params, ['until', 'untill', 'till']) # do not omit it from params here |
| 7586 | maxEntriesPerRequest, params = self.handle_max_entries_per_request_and_params(method, maxEntriesPerRequest, params) |
| 7587 | if (paginationDirection == 'forward'): |
| 7588 | if since is None: |
| 7589 | raise ArgumentsRequired(self.id + ' pagination requires a since argument when paginationDirection set to forward') |
| 7590 | paginationTimestamp = since |
| 7591 | while((calls < maxCalls)): |
| 7592 | calls += 1 |
| 7593 | try: |
| 7594 | if paginationDirection == 'backward': |
| 7595 | # do it backwards, starting from the last |
| 7596 | # UNTIL filtering is required in order to work |
| 7597 | if paginationTimestamp is not None: |
| 7598 | params['until'] = paginationTimestamp - 1 |
| 7599 | response = getattr(self, method)(symbol, None, maxEntriesPerRequest, params) |
| 7600 | responseLength = len(response) |
| 7601 | if self.verbose: |
| 7602 | backwardMessage = 'Dynamic pagination call ' + self.number_to_string(calls) + ' method ' + method + ' response length ' + self.number_to_string(responseLength) |
| 7603 | if paginationTimestamp is not None: |
| 7604 | backwardMessage += ' timestamp ' + self.number_to_string(paginationTimestamp) |
| 7605 | self.log(backwardMessage) |
| 7606 | if responseLength == 0: |
| 7607 | break |
| 7608 | errors = 0 |
| 7609 | result = self.array_concat(result, response) |
| 7610 | firstElement = self.safe_value(response, 0) |
| 7611 | paginationTimestamp = self.safe_integer_2(firstElement, 'timestamp', 0) |
| 7612 | if (since is not None) and (paginationTimestamp <= since): |
| 7613 | break |
| 7614 | else: |
| 7615 | # do it forwards, starting from the since |
| 7616 | response = getattr(self, method)(symbol, paginationTimestamp, maxEntriesPerRequest, params) |
| 7617 | responseLength = len(response) |
| 7618 | if self.verbose: |
| 7619 | forwardMessage = 'Dynamic pagination call ' + self.number_to_string(calls) + ' method ' + method + ' response length ' + self.number_to_string(responseLength) |
| 7620 | if paginationTimestamp is not None: |
| 7621 | forwardMessage += ' timestamp ' + self.number_to_string(paginationTimestamp) |
| 7622 | self.log(forwardMessage) |
| 7623 | if responseLength == 0: |
| 7624 | break |
| 7625 | errors = 0 |
| 7626 | result = self.array_concat(result, response) |
| 7627 | last = self.safe_value(response, responseLength - 1) |
| 7628 | paginationTimestamp = self.safe_integer(last, 'timestamp', 0) + 1 |
| 7629 | if (until is not None) and (paginationTimestamp >= until): |
no test coverage detected