From 70a77ba3d975e1cdfa5626bd0af55ff7e2b3cfb9 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 18 Aug 2022 20:07:41 +0200 Subject: [PATCH] Check for "last" availability in PrecisionFilter closes #7250 --- freqtrade/plugins/pairlist/PrecisionFilter.py | 5 +++++ tests/plugins/test_pairlist.py | 3 +++ 2 files changed, 8 insertions(+) diff --git a/freqtrade/plugins/pairlist/PrecisionFilter.py b/freqtrade/plugins/pairlist/PrecisionFilter.py index 521f38635..dcd153d8e 100644 --- a/freqtrade/plugins/pairlist/PrecisionFilter.py +++ b/freqtrade/plugins/pairlist/PrecisionFilter.py @@ -51,6 +51,11 @@ class PrecisionFilter(IPairList): :param ticker: ticker dict as returned from ccxt.fetch_tickers() :return: True if the pair can stay, false if it should be removed """ + if ticker.get('last', None) is None: + self.log_once(f"Removed {ticker['symbol']} from whitelist, because " + "ticker['last'] is empty (Usually no trade in the last 24h).", + logger.info) + return False stop_price = ticker['last'] * self._stoploss # Adjust stop-prices to precision diff --git a/tests/plugins/test_pairlist.py b/tests/plugins/test_pairlist.py index 5974bee89..48a0f81cb 100644 --- a/tests/plugins/test_pairlist.py +++ b/tests/plugins/test_pairlist.py @@ -366,6 +366,9 @@ def test_VolumePairList_refresh_empty(mocker, markets_empty, whitelist_conf): ([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"}, {"method": "PrecisionFilter"}], "BTC", ['ETH/BTC', 'TKN/BTC', 'LTC/BTC', 'XRP/BTC']), + ([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"}, + {"method": "PrecisionFilter"}], + "USDT", ['ETH/USDT', 'NANO/USDT']), # PriceFilter and VolumePairList ([{"method": "VolumePairList", "number_assets": 5, "sort_key": "quoteVolume"}, {"method": "PriceFilter", "low_price_ratio": 0.03}],