{"record":{"id":"95445e755950c7ca","repo":"freqtrade/freqtrade","slug":"no-exchange-object-found","errorCode":null,"errorMessage":"No exchange object found.","messagePattern":"No exchange object found\\.","errorType":"exception","errorClass":"OperationalException","httpStatus":null,"severity":"error","filePath":"freqtrade/freqai/utils.py","lineNumber":34,"sourceCode":"from freqtrade.freqai.data_drawer import FreqaiDataDrawer\nfrom freqtrade.freqai.data_kitchen import FreqaiDataKitchen\nfrom freqtrade.plugins.pairlist.pairlist_helpers import dynamic_expand_pairlist\n\n\nlogger = logging.getLogger(__name__)\n\n\ndef download_all_data_for_training(dp: DataProvider, config: Config) -> None:\n    \"\"\"\n    Called only once upon start of bot to download the necessary data for\n    populating indicators and training the model.\n    :param timerange: TimeRange = The full data timerange for populating the indicators\n                                    and training the model.\n    :param dp: DataProvider instance attached to the strategy\n    \"\"\"\n\n    if dp._exchange is None:\n        raise OperationalException(\"No exchange object found.\")\n    markets = [\n        p\n        for p in dp._exchange.get_markets(\n            tradable_only=True, active_only=not config.get(\"include_inactive\")\n        ).keys()\n    ]\n\n    all_pairs = dynamic_expand_pairlist(config, markets)\n\n    timerange = get_required_data_timerange(config)\n\n    new_pairs_days = int((timerange.stopts - timerange.startts) / 86400)\n\n    refresh_backtest_ohlcv_data(\n        dp._exchange,\n        pairs=all_pairs,\n        timeframes=config[\"freqai\"][\"feature_parameters\"].get(\"include_timeframes\"),\n        datadir=config[\"datadir\"],","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/freqtrade/freqtrade/blob/1c8edfe4d1e8d11bd4b40e8fc3237c26c3a60e15/freqtrade/freqai/utils.py#L16-L52","documentation":"download_all_data_for_training() must enumerate tradable markets via the exchange object attached to DataProvider. dp._exchange is None when the DataProvider was created without a live exchange connection (e.g. pure backtest context), and the helper raises OperationalException because pair discovery is impossible.","triggerScenarios":"Calling freqtrade freqai commands that lead to download_all_data_for_training() (e.g. download-data with --freqaimodel, or start-up data preparation) with a config whose exchange section is missing or not instantiated; or invoking the utility programmatically with a DataProvider built with exchange=None.","commonSituations":"Config lacks the 'exchange' block or has an empty name; running data download utilities from a script with a DataProvider meant for backtesting; exchange initialization failed earlier and the error surfaces here first.","solutions":["Ensure the config contains a valid 'exchange' section (name, pair_whitelist, etc.) — copy from config_examples and pass it with -c","Run the official entry point: freqtrade download-data --freqaimodel <model> --config <config with freqai + exchange>","When calling programmatically, construct DataProvider with a real Exchange instance (dp = DataProvider(config, exchange)) before calling the helper"],"exampleFix":"# before (script)\ndp = DataProvider(config, None)  # no exchange\ndownload_all_data_for_training(dp, config)\n\n# after\nexchange = ExchangeResolver.load_exchange(config, validate=True)\ndp = DataProvider(config, exchange)\ndownload_all_data_for_training(dp, config)","handlingStrategy":"validation","validationCode":"# Programmatic guard before downloading freqAI training data\nassert dp._exchange is not None, (\n    'DataProvider has no exchange - load one via ExchangeResolver first')","typeGuard":"def dataprovider_has_exchange(dp) -> bool:\n    return getattr(dp, '_exchange', None) is not None","tryCatchPattern":null,"preventionTips":["Always include a valid 'exchange' block in configs used for freqAI data downloads","Construct DataProvider(config, exchange) with a real Exchange in scripts"],"tags":["freqai","exchange","dataprovider","config"],"backgroundTag":null,"analyzedSha":"1c8edfe4d1e8d11bd4b40e8fc3237c26c3a60e15","analyzedAt":"2026-08-15T05:09:08.096Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}