Improve kraken pagination behavior

This commit is contained in:
Matthias
2024-01-21 15:55:34 +01:00
parent f9b6830b78
commit ac5b12cfd2
+13 -13
View File
@@ -157,21 +157,21 @@ class Kraken(Exchange):
return fees if is_short else -fees return fees if is_short else -fees
def _trades_contracts_to_amount(self, trades: List) -> List: def _get_trade_pagination_next_value(self, trades: List[Dict]) -> str:
""" """
Fix "last" id issue for kraken data downloads Extract pagination id for the next "from_id" value
This whole override can probably be removed once the following Applies only to fetch_trade_history by id.
issue is closed in ccxt: https://github.com/ccxt/ccxt/issues/15827
""" """
super()._trades_contracts_to_amount(trades) if len(trades) > 0:
if ( if (
len(trades) > 0 isinstance(trades[-1].get('info'), list)
and isinstance(trades[-1].get('info'), list) and len(trades[-1].get('info', [])) > 7
and len(trades[-1].get('info', [])) > 7 ):
): # Trade response's "last" value.
return trades[-1].get('info', [])[-1]
trades[-1]['id'] = trades[-1].get('info', [])[-1] # Fall back to timestamp if info is somehow empty.
return trades return trades[-1].get('timestamp')
return None
def _valid_trade_pagination_id(self, pair: str, from_id: str) -> bool: def _valid_trade_pagination_id(self, pair: str, from_id: str) -> bool:
""" """