From 43c9d14ac2580f01c52b7e56146f73e99aee501e Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 24 Oct 2024 18:10:39 +0200 Subject: [PATCH] refactor: extract exchangeInit from download-data main --- freqtrade/commands/data_commands.py | 5 ++++- freqtrade/data/history/history_utils.py | 6 +----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/freqtrade/commands/data_commands.py b/freqtrade/commands/data_commands.py index c529e8dc7..d4354e058 100644 --- a/freqtrade/commands/data_commands.py +++ b/freqtrade/commands/data_commands.py @@ -32,13 +32,16 @@ def start_download_data(args: dict[str, Any]) -> None: """ from freqtrade.configuration import setup_utils_configuration from freqtrade.data.history import download_data_main + from freqtrade.resolvers.exchange_resolver import ExchangeResolver config = setup_utils_configuration(args, RunMode.UTIL_EXCHANGE) _check_data_config_download_sanity(config) + exchange = ExchangeResolver.load_exchange(config, validate=False) + try: - download_data_main(config) + download_data_main(config, exchange) except KeyboardInterrupt: sys.exit("SIGINT received, aborting ...") diff --git a/freqtrade/data/history/history_utils.py b/freqtrade/data/history/history_utils.py index 66b4d82bd..fb63e58d7 100644 --- a/freqtrade/data/history/history_utils.py +++ b/freqtrade/data/history/history_utils.py @@ -579,7 +579,7 @@ def validate_backtest_data( return found_missing -def download_data_main(config: Config) -> None: +def download_data_main(config: Config, exchange: Exchange) -> None: timerange = TimeRange() if "days" in config: time_since = (datetime.now() - timedelta(days=config["days"])).strftime("%Y%m%d") @@ -593,10 +593,6 @@ def download_data_main(config: Config) -> None: pairs_not_available: list[str] = [] - # Init exchange - from freqtrade.resolvers.exchange_resolver import ExchangeResolver - - exchange = ExchangeResolver.load_exchange(config, validate=False) available_pairs = [ p for p in exchange.get_markets(