Add expand_pairlist method

This commit is contained in:
Matthias
2020-12-30 09:55:44 +01:00
parent 2fdda8e448
commit 704cf14383
4 changed files with 60 additions and 2 deletions

View 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

View File

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