From 16f96753564bbe791a7d4edc2b918a1ec58f92f3 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 23 Jan 2021 20:35:10 +0100 Subject: [PATCH] Fix whitelist expansion problem --- freqtrade/plugins/pairlist/pairlist_helpers.py | 4 ++-- tests/plugins/test_pairlist.py | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/freqtrade/plugins/pairlist/pairlist_helpers.py b/freqtrade/plugins/pairlist/pairlist_helpers.py index 04320fe16..924bfb293 100644 --- a/freqtrade/plugins/pairlist/pairlist_helpers.py +++ b/freqtrade/plugins/pairlist/pairlist_helpers.py @@ -19,7 +19,7 @@ def expand_pairlist(wildcardpl: List[str], available_pairs: List[str], try: comp = re.compile(pair_wc) result_partial = [ - pair for pair in available_pairs if re.match(comp, pair) + pair for pair in available_pairs if re.fullmatch(comp, pair) ] # Add all matching pairs. # If there are no matching pairs (Pair not on exchange) keep it. @@ -35,7 +35,7 @@ def expand_pairlist(wildcardpl: List[str], available_pairs: List[str], try: comp = re.compile(pair_wc) result += [ - pair for pair in available_pairs if re.match(comp, pair) + pair for pair in available_pairs if re.fullmatch(comp, pair) ] except re.error as err: raise ValueError(f"Wildcard error in {pair_wc}, {err}") diff --git a/tests/plugins/test_pairlist.py b/tests/plugins/test_pairlist.py index 910a9580c..d62230e76 100644 --- a/tests/plugins/test_pairlist.py +++ b/tests/plugins/test_pairlist.py @@ -870,6 +870,9 @@ def test_performance_filter(mocker, whitelist_conf, pairlists, pair_allowlist, o (['*UP/USDT', 'BTC/USDT', 'ETH/USDT'], ['BTC/USDT', 'ETC/USDT', 'ETH/USDT', 'BTCUP/USDT', 'XRPUP/USDT', 'XRPDOWN/USDT'], None), + (['BTC/USD'], + ['BTC/USD', 'BTC/USDT'], + ['BTC/USD']), ]) def test_expand_pairlist(wildcardlist, pairs, expected): if expected is None: @@ -901,7 +904,11 @@ def test_expand_pairlist(wildcardlist, pairs, expected): (['*UP/USDT', 'BTC/USDT', 'ETH/USDT'], ['BTC/USDT', 'ETC/USDT', 'ETH/USDT', 'BTCUP/USDT', 'XRPUP/USDT', 'XRPDOWN/USDT'], None), - (['HELLO/WORLD'], [], ['HELLO/WORLD']) # Invalid pair kept + (['HELLO/WORLD'], [], ['HELLO/WORLD']), # Invalid pair kept + (['BTC/USD'], + ['BTC/USD', 'BTC/USDT'], + ['BTC/USD']), + ]) def test_expand_pairlist_keep_invalid(wildcardlist, pairs, expected): if expected is None: