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: