diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 8cfe90272..53a3960b1 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -1427,6 +1427,8 @@ class Exchange: :return: fetch_tickers result """ tickers: Tickers + if not self.exchange_has('fetchTickers'): + return {} if cached: with self._cache_lock: tickers = self._fetch_tickers_cache.get('fetch_tickers') # type: ignore diff --git a/tests/exchange/test_exchange.py b/tests/exchange/test_exchange.py index b07892f72..07aad80ff 100644 --- a/tests/exchange/test_exchange.py +++ b/tests/exchange/test_exchange.py @@ -1834,6 +1834,7 @@ def test_get_tickers(default_conf, mocker, exchange_name): 'last': 41, } } + mocker.patch('freqtrade.exchange.exchange.Exchange.exchange_has', return_value=True) api_mock.fetch_tickers = MagicMock(return_value=tick) api_mock.fetch_bids_asks = MagicMock(return_value={}) exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name) @@ -1883,6 +1884,11 @@ def test_get_tickers(default_conf, mocker, exchange_name): assert api_mock.fetch_tickers.call_count == 1 assert api_mock.fetch_bids_asks.call_count == (1 if exchange_name == 'binance' else 0) + api_mock.fetch_tickers.reset_mock() + api_mock.fetch_bids_asks.reset_mock() + mocker.patch('freqtrade.exchange.exchange.Exchange.exchange_has', return_value=False) + assert exchange.get_tickers() == {} + @pytest.mark.parametrize("exchange_name", EXCHANGES) def test_fetch_ticker(default_conf, mocker, exchange_name):