diff --git a/freqtrade/commands/data_commands.py b/freqtrade/commands/data_commands.py index 2019413b5..21b7a3194 100644 --- a/freqtrade/commands/data_commands.py +++ b/freqtrade/commands/data_commands.py @@ -12,7 +12,7 @@ from freqtrade.enums import CandleType, RunMode, TradingMode from freqtrade.exceptions import OperationalException from freqtrade.exchange import timeframe_to_minutes from freqtrade.exchange.exchange import market_is_active -from freqtrade.plugins.pairlist.pairlist_helpers import expand_pairlist +from freqtrade.plugins.pairlist.pairlist_helpers import dynamic_expand_pairlist, expand_pairlist from freqtrade.resolvers import ExchangeResolver @@ -50,12 +50,8 @@ def start_download_data(args: Dict[str, Any]) -> None: exchange = ExchangeResolver.load_exchange(config['exchange']['name'], config, validate=False) markets = [p for p, m in exchange.markets.items() if market_is_active(m) or config.get('include_inactive')] - if config.get('freqai', {}): - full_pairs = config['pairs'] + [pair for pair in config['freqai']['corr_pairlist'] - if pair not in config['pairs']] - expanded_pairs = expand_pairlist(full_pairs, markets) - else: - expanded_pairs = expand_pairlist(config['pairs'], markets) + + expanded_pairs = dynamic_expand_pairlist(config, markets) # Manual validations of relevant settings if not config['exchange'].get('skip_pair_validation', False): diff --git a/freqtrade/plugins/pairlist/pairlist_helpers.py b/freqtrade/plugins/pairlist/pairlist_helpers.py index 1de27fcbd..23233481a 100644 --- a/freqtrade/plugins/pairlist/pairlist_helpers.py +++ b/freqtrade/plugins/pairlist/pairlist_helpers.py @@ -40,3 +40,14 @@ def expand_pairlist(wildcardpl: List[str], available_pairs: List[str], except re.error as err: raise ValueError(f"Wildcard error in {pair_wc}, {err}") return result + + +def dynamic_expand_pairlist(config: dict, markets: list) -> List[str]: + if config.get('freqai', {}): + full_pairs = config['pairs'] + [pair for pair in config['freqai']['corr_pairlist'] + if pair not in config['pairs']] + expanded_pairs = expand_pairlist(full_pairs, markets) + else: + expanded_pairs = expand_pairlist(config['pairs'], markets) + + return expanded_pairs