From 138e867a68f0ff3639d74cd6f7ca987e1a9c2a53 Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 28 Jan 2022 07:20:47 +0100 Subject: [PATCH] Filter tickers on stake-currency for kraken --- freqtrade/exchange/exchange.py | 4 ++-- freqtrade/exchange/kraken.py | 8 +++++++- tests/exchange/test_ccxt_compat.py | 12 ++++++------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index bfff7d06c..004fb2437 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -953,7 +953,7 @@ class Exchange: raise OperationalException(e) from e @retrier - def get_tickers(self, cached: bool = False) -> Dict: + def get_tickers(self, symbols: List[str] = None, cached: bool = False) -> Dict: """ :param cached: Allow cached result :return: fetch_tickers result @@ -963,7 +963,7 @@ class Exchange: if tickers: return tickers try: - tickers = self._api.fetch_tickers() + tickers = self._api.fetch_tickers(symbols) self._fetch_tickers_cache['fetch_tickers'] = tickers return tickers except ccxt.NotSupported as e: diff --git a/freqtrade/exchange/kraken.py b/freqtrade/exchange/kraken.py index 1b069aa6c..f4c8ca275 100644 --- a/freqtrade/exchange/kraken.py +++ b/freqtrade/exchange/kraken.py @@ -1,6 +1,6 @@ """ Kraken exchange subclass """ import logging -from typing import Any, Dict +from typing import Any, Dict, List import ccxt @@ -33,6 +33,12 @@ class Kraken(Exchange): return (parent_check and market.get('darkpool', False) is False) + def get_tickers(self, symbols: List[str] = None, cached: bool = False) -> Dict: + # Only fetch tickers for current stake currency + # Otherwise the request for kraken becomes too large. + symbols = list(self.get_markets(quote_currencies=[self._config['stake_currency']])) + return super().get_tickers(symbols=symbols, cached=cached) + @retrier def get_balances(self) -> dict: if self._config['dry_run']: diff --git a/tests/exchange/test_ccxt_compat.py b/tests/exchange/test_ccxt_compat.py index 6314b6eb8..44c664c92 100644 --- a/tests/exchange/test_ccxt_compat.py +++ b/tests/exchange/test_ccxt_compat.py @@ -29,12 +29,12 @@ EXCHANGES = { 'hasQuoteVolume': True, 'timeframe': '5m', }, - # 'kraken': { - # 'pair': 'BTC/USDT', - # 'stake_currency': 'USDT', - # 'hasQuoteVolume': True, - # 'timeframe': '5m', - # }, + 'kraken': { + 'pair': 'BTC/USDT', + 'stake_currency': 'USDT', + 'hasQuoteVolume': True, + 'timeframe': '5m', + }, 'ftx': { 'pair': 'BTC/USDT', 'stake_currency': 'USDT',