Improve kraken pagination behavior

This commit is contained in:
Matthias 2024-01-21 15:55:34 +01:00
parent f9b6830b78
commit ac5b12cfd2

View File

@ -157,21 +157,21 @@ class Kraken(Exchange):
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
This whole override can probably be removed once the following
issue is closed in ccxt: https://github.com/ccxt/ccxt/issues/15827
Extract pagination id for the next "from_id" value
Applies only to fetch_trade_history by id.
"""
super()._trades_contracts_to_amount(trades)
if (
len(trades) > 0
and isinstance(trades[-1].get('info'), list)
and len(trades[-1].get('info', [])) > 7
):
trades[-1]['id'] = trades[-1].get('info', [])[-1]
return trades
if len(trades) > 0:
if (
isinstance(trades[-1].get('info'), list)
and len(trades[-1].get('info', [])) > 7
):
# Trade response's "last" value.
return trades[-1].get('info', [])[-1]
# Fall back to timestamp if info is somehow empty.
return trades[-1].get('timestamp')
return None
def _valid_trade_pagination_id(self, pair: str, from_id: str) -> bool:
"""