Fix whitelist expansion problem
This commit is contained in:
parent
37acaa685b
commit
16f9675356
@ -19,7 +19,7 @@ def expand_pairlist(wildcardpl: List[str], available_pairs: List[str],
|
|||||||
try:
|
try:
|
||||||
comp = re.compile(pair_wc)
|
comp = re.compile(pair_wc)
|
||||||
result_partial = [
|
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.
|
# Add all matching pairs.
|
||||||
# If there are no matching pairs (Pair not on exchange) keep it.
|
# 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:
|
try:
|
||||||
comp = re.compile(pair_wc)
|
comp = re.compile(pair_wc)
|
||||||
result += [
|
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:
|
except re.error as err:
|
||||||
raise ValueError(f"Wildcard error in {pair_wc}, {err}")
|
raise ValueError(f"Wildcard error in {pair_wc}, {err}")
|
||||||
|
@ -870,6 +870,9 @@ def test_performance_filter(mocker, whitelist_conf, pairlists, pair_allowlist, o
|
|||||||
(['*UP/USDT', 'BTC/USDT', 'ETH/USDT'],
|
(['*UP/USDT', 'BTC/USDT', 'ETH/USDT'],
|
||||||
['BTC/USDT', 'ETC/USDT', 'ETH/USDT', 'BTCUP/USDT', 'XRPUP/USDT', 'XRPDOWN/USDT'],
|
['BTC/USDT', 'ETC/USDT', 'ETH/USDT', 'BTCUP/USDT', 'XRPUP/USDT', 'XRPDOWN/USDT'],
|
||||||
None),
|
None),
|
||||||
|
(['BTC/USD'],
|
||||||
|
['BTC/USD', 'BTC/USDT'],
|
||||||
|
['BTC/USD']),
|
||||||
])
|
])
|
||||||
def test_expand_pairlist(wildcardlist, pairs, expected):
|
def test_expand_pairlist(wildcardlist, pairs, expected):
|
||||||
if expected is None:
|
if expected is None:
|
||||||
@ -901,7 +904,11 @@ def test_expand_pairlist(wildcardlist, pairs, expected):
|
|||||||
(['*UP/USDT', 'BTC/USDT', 'ETH/USDT'],
|
(['*UP/USDT', 'BTC/USDT', 'ETH/USDT'],
|
||||||
['BTC/USDT', 'ETC/USDT', 'ETH/USDT', 'BTCUP/USDT', 'XRPUP/USDT', 'XRPDOWN/USDT'],
|
['BTC/USDT', 'ETC/USDT', 'ETH/USDT', 'BTCUP/USDT', 'XRPUP/USDT', 'XRPDOWN/USDT'],
|
||||||
None),
|
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):
|
def test_expand_pairlist_keep_invalid(wildcardlist, pairs, expected):
|
||||||
if expected is None:
|
if expected is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user