diff --git a/freqtrade/commands/data_commands.py b/freqtrade/commands/data_commands.py index d4354e058..c529e8dc7 100644 --- a/freqtrade/commands/data_commands.py +++ b/freqtrade/commands/data_commands.py @@ -32,16 +32,13 @@ 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, exchange) + download_data_main(config) except KeyboardInterrupt: sys.exit("SIGINT received, aborting ...") diff --git a/freqtrade/data/history/history_utils.py b/freqtrade/data/history/history_utils.py index fb63e58d7..627959504 100644 --- a/freqtrade/data/history/history_utils.py +++ b/freqtrade/data/history/history_utils.py @@ -579,7 +579,18 @@ def validate_backtest_data( return found_missing -def download_data_main(config: Config, exchange: Exchange) -> None: +def download_data_main(config: Config) -> None: + from freqtrade.resolvers.exchange_resolver import ExchangeResolver + + exchange = ExchangeResolver.load_exchange(config, validate=False) + + download_data(config, exchange) + + +def download_data(config: Config, exchange: Exchange) -> None: + """ + Download data function. Used from both cli and API. + """ timerange = TimeRange() if "days" in config: time_since = (datetime.now() - timedelta(days=config["days"])).strftime("%Y%m%d")