From 130a9b4db33afb9e71ffe917c70d301611d05e17 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 1 Feb 2021 19:39:55 +0100 Subject: [PATCH 1/2] Add test to call verify_pairlist multiple times --- tests/plugins/test_pairlist.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/plugins/test_pairlist.py b/tests/plugins/test_pairlist.py index fda2b1409..67cd96f5b 100644 --- a/tests/plugins/test_pairlist.py +++ b/tests/plugins/test_pairlist.py @@ -126,6 +126,20 @@ def test_load_pairlist_noexist(mocker, markets, default_conf): default_conf, {}, 1) +def test_load_pairlist_verify_multi(mocker, markets, default_conf): + freqtrade = get_patched_freqtradebot(mocker, default_conf) + mocker.patch('freqtrade.exchange.Exchange.markets', PropertyMock(return_value=markets)) + plm = PairListManager(freqtrade.exchange, default_conf) + # Call different versions one after the other, should always consider what was passed in + # and have no side-effects (therefore the same check multiple times) + assert plm.verify_whitelist(['ETH/BTC', 'XRP/BTC', ], print) == ['ETH/BTC', 'XRP/BTC'] + assert plm.verify_whitelist(['ETH/BTC', 'XRP/BTC', 'BUUU/BTC'], print) == ['ETH/BTC', 'XRP/BTC'] + assert plm.verify_whitelist(['XRP/BTC', 'BUUU/BTC'], print) == ['XRP/BTC'] + assert plm.verify_whitelist(['ETH/BTC', 'XRP/BTC', ], print) == ['ETH/BTC', 'XRP/BTC'] + assert plm.verify_whitelist(['ETH/USDT', 'XRP/USDT', ], print) == ['ETH/USDT', ] + assert plm.verify_whitelist(['ETH/BTC', 'XRP/BTC', ], print) == ['ETH/BTC', 'XRP/BTC'] + + def test_refresh_market_pair_not_in_whitelist(mocker, markets, static_pl_conf): freqtrade = get_patched_freqtradebot(mocker, static_pl_conf) From 52acf9aaf6648e7478acad42619f4222b6c01614 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 1 Feb 2021 19:40:31 +0100 Subject: [PATCH 2/2] Fix "disappearing pairs" bug closes #4277 --- freqtrade/plugins/pairlist/IPairList.py | 2 +- freqtrade/plugins/pairlistmanager.py | 17 ++--------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/freqtrade/plugins/pairlist/IPairList.py b/freqtrade/plugins/pairlist/IPairList.py index 95d776ae6..184feff9e 100644 --- a/freqtrade/plugins/pairlist/IPairList.py +++ b/freqtrade/plugins/pairlist/IPairList.py @@ -168,7 +168,7 @@ class IPairList(LoggingMixin, ABC): # Check if market is active market = markets[pair] if not market_is_active(market): - logger.info(f"Ignoring {pair} from whitelist. Market is not active.") + self.log_once(f"Ignoring {pair} from whitelist. Market is not active.", logger.info) continue if pair not in sanitized_whitelist: sanitized_whitelist.append(pair) diff --git a/freqtrade/plugins/pairlistmanager.py b/freqtrade/plugins/pairlistmanager.py index 7ce77da59..4e4135981 100644 --- a/freqtrade/plugins/pairlistmanager.py +++ b/freqtrade/plugins/pairlistmanager.py @@ -59,17 +59,6 @@ class PairListManager(): """The expanded blacklist (including wildcard expansion)""" return expand_pairlist(self._blacklist, self._exchange.get_markets().keys()) - @property - def expanded_whitelist_keep_invalid(self) -> List[str]: - """The expanded whitelist (including wildcard expansion), maintaining invalid pairs""" - return expand_pairlist(self._whitelist, self._exchange.get_markets().keys(), - keep_invalid=True) - - @property - def expanded_whitelist(self) -> List[str]: - """The expanded whitelist (including wildcard expansion), filtering invalid pairs""" - return expand_pairlist(self._whitelist, self._exchange.get_markets().keys()) - @property def name_list(self) -> List[str]: """Get list of loaded Pairlist Handler names""" @@ -153,10 +142,8 @@ class PairListManager(): :return: pairlist - whitelisted pairs """ try: - if keep_invalid: - whitelist = self.expanded_whitelist_keep_invalid - else: - whitelist = self.expanded_whitelist + + whitelist = expand_pairlist(pairlist, self._exchange.get_markets().keys(), keep_invalid) except ValueError as err: logger.error(f"Pair whitelist contains an invalid Wildcard: {err}") return []