Add expand_pairlist method
This commit is contained in:
18
freqtrade/plugins/pairlist/pairlist_helpers.py
Normal file
18
freqtrade/plugins/pairlist/pairlist_helpers.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import re
|
||||
from typing import List
|
||||
|
||||
|
||||
def expand_pairlist(wildcardpl: List[str], available_pairs: List[str]) -> List[str]:
|
||||
"""
|
||||
TODO: Add docstring here
|
||||
"""
|
||||
result = []
|
||||
for pair_wc in wildcardpl:
|
||||
try:
|
||||
comp = re.compile(pair_wc)
|
||||
result += [
|
||||
pair for pair in available_pairs if re.match(comp, pair)
|
||||
]
|
||||
except re.error as err:
|
||||
raise ValueError(f"Wildcard error in {pair_wc}, {err}")
|
||||
return result
|
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
PairList manager class
|
||||
"""
|
||||
from freqtrade.plugins.pairlist.pairlist_helpers import expand_pairlist
|
||||
import logging
|
||||
from copy import deepcopy
|
||||
from typing import Any, Dict, List
|
||||
@@ -55,6 +56,13 @@ class PairListManager():
|
||||
"""
|
||||
return self._blacklist
|
||||
|
||||
@property
|
||||
def expanded_blacklist(self) -> List[str]:
|
||||
"""
|
||||
Has the expanded blacklist (including wildcard expansion)
|
||||
"""
|
||||
return expand_pairlist(self._blacklist, self._exchange.get_markets().keys())
|
||||
|
||||
@property
|
||||
def name_list(self) -> List[str]:
|
||||
"""
|
||||
@@ -121,7 +129,7 @@ class PairListManager():
|
||||
:return: pairlist - blacklisted pairs
|
||||
"""
|
||||
for pair in deepcopy(pairlist):
|
||||
if pair in self._blacklist:
|
||||
if pair in self.expanded_blacklist:
|
||||
logmethod(f"Pair {pair} in your blacklist. Removing it from whitelist...")
|
||||
pairlist.remove(pair)
|
||||
return pairlist
|
||||
|
Reference in New Issue
Block a user