refactor: extract exchangeInit from download-data main

This commit is contained in:
Matthias
2024-10-24 18:10:39 +02:00
parent 83122fa58b
commit 43c9d14ac2
2 changed files with 5 additions and 6 deletions

View File

@@ -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 ...")

View File

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