From f6545ebdb8a82cedce065779873d395631aff07f Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 13 Aug 2022 09:10:03 +0200 Subject: [PATCH] Disallow backtesting with --strategy-list for now. --- freqtrade/optimize/backtesting.py | 3 +++ tests/freqai/test_freqai_backtsting.py | 33 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/freqai/test_freqai_backtsting.py diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index 86c1822f7..c00f30686 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -89,6 +89,9 @@ class Backtesting: self.dataprovider = DataProvider(self.config, self.exchange) if self.config.get('strategy_list'): + if self.config.get('freqai'): + raise OperationalException( + "You can't use strategy_list and freqai at the same time.") for strat in list(self.config['strategy_list']): stratconf = deepcopy(self.config) stratconf['strategy'] = strat diff --git a/tests/freqai/test_freqai_backtsting.py b/tests/freqai/test_freqai_backtsting.py new file mode 100644 index 000000000..bb0a71e2c --- /dev/null +++ b/tests/freqai/test_freqai_backtsting.py @@ -0,0 +1,33 @@ +from pathlib import Path +from unittest.mock import PropertyMock + +import pytest + +from freqtrade.commands.optimize_commands import start_backtesting +from freqtrade.exceptions import OperationalException +from tests.conftest import (CURRENT_TEST_STRATEGY, get_args, patch_exchange, + patched_configuration_load_config_file) + + +def test_backtest_start_backtest_list_freqai(freqai_conf, mocker, testdatadir): + # Tests detail-data loading + patch_exchange(mocker) + + mocker.patch('freqtrade.plugins.pairlistmanager.PairListManager.whitelist', + PropertyMock(return_value=['HULUMULU/USDT', 'XRP/USDT'])) + # mocker.patch('freqtrade.optimize.backtesting.Backtesting.backtest', backtestmock) + + patched_configuration_load_config_file(mocker, freqai_conf) + + args = [ + 'backtesting', + '--config', 'config.json', + '--datadir', str(testdatadir), + '--strategy-path', str(Path(__file__).parents[1] / 'strategy/strats'), + '--timeframe', '1h', + '--strategy-list', CURRENT_TEST_STRATEGY + ] + args = get_args(args) + with pytest.raises(OperationalException, + match=r"You can't use strategy_list and freqai at the same time\."): + start_backtesting(args)