diff --git a/freqtrade/freqai/utils.py b/freqtrade/freqai/utils.py index d56702049..6081b6ce5 100644 --- a/freqtrade/freqai/utils.py +++ b/freqtrade/freqai/utils.py @@ -22,21 +22,17 @@ def download_all_data_for_training(dp: DataProvider, config: dict) -> None: :param dp: DataProvider instance attached to the strategy """ - if dp._exchange is not None: - markets = [p for p, m in dp._exchange.markets.items() if market_is_active(m) - or config.get('include_inactive')] - else: - # This should not occur: + if dp._exchange is None: raise OperationalException('No exchange object found.') + markets = [p for p, m in dp._exchange.markets.items() if market_is_active(m) + or config.get('include_inactive')] all_pairs = dynamic_expand_pairlist(config, markets) timerange = get_required_data_timerange(config) new_pairs_days = int((timerange.stopts - timerange.startts) / 86400) - if not dp._exchange: - # Not realistic - this is only called in live mode. - raise OperationalException("Dataprovider did not have an exchange attached.") + refresh_backtest_ohlcv_data( dp._exchange, pairs=all_pairs, diff --git a/tests/freqai/test_freqai_backtesting.py b/tests/freqai/test_freqai_backtesting.py index c8a51edb0..ea127fa99 100644 --- a/tests/freqai/test_freqai_backtesting.py +++ b/tests/freqai/test_freqai_backtesting.py @@ -48,10 +48,4 @@ def test_freqai_backtest_load_data(freqai_conf, mocker, caplog): assert log_has_re('Increasing startup_candle_count for freqai to.*', caplog) - # del freqai_conf['freqai']['startup_candles'] - # backtesting = Backtesting(freqai_conf) - # with pytest.raises(OperationalException, - # match=r'FreqAI backtesting module.*startup_candles in config.'): - # backtesting.load_bt_data() - Backtesting.cleanup()