Fix whitelist expansion problem

This commit is contained in:
Matthias 2021-01-23 20:35:10 +01:00
parent 37acaa685b
commit 16f9675356
2 changed files with 10 additions and 3 deletions

View File

@ -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}")

View File

@ -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: