From 9869a21951c4947f6d1f070ff40c432e78515a36 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 20 May 2023 15:39:21 +0200 Subject: [PATCH] Move strategy to it's own directory to avoid having other --- freqtrade/optimize/lookahead_analysis.py | 3 --- tests/optimize/test_lookahead_analysis.py | 19 +++++++++++++------ .../strategy_test_v3_with_lookahead_bias.py | 0 3 files changed, 13 insertions(+), 9 deletions(-) rename tests/strategy/strats/{ => lookahead_bias}/strategy_test_v3_with_lookahead_bias.py (100%) diff --git a/freqtrade/optimize/lookahead_analysis.py b/freqtrade/optimize/lookahead_analysis.py index e8631e8b6..dfb1a9ea2 100755 --- a/freqtrade/optimize/lookahead_analysis.py +++ b/freqtrade/optimize/lookahead_analysis.py @@ -259,6 +259,3 @@ class LookaheadAnalysis: logging.info(self.local_config['strategy'] + ": no bias detected") self.failed_bias_check = False - - - diff --git a/tests/optimize/test_lookahead_analysis.py b/tests/optimize/test_lookahead_analysis.py index 0092b6074..944892685 100644 --- a/tests/optimize/test_lookahead_analysis.py +++ b/tests/optimize/test_lookahead_analysis.py @@ -11,13 +11,15 @@ from freqtrade.data.history import get_timerange from freqtrade.exceptions import OperationalException from freqtrade.optimize.lookahead_analysis import LookaheadAnalysis from freqtrade.optimize.lookahead_analysis_helpers import LookaheadAnalysisSubFunctions -from tests.conftest import CURRENT_TEST_STRATEGY, get_args, log_has_re, patch_exchange +from tests.conftest import EXMS, get_args, patch_exchange @pytest.fixture def lookahead_conf(default_conf_usdt): default_conf_usdt['minimum_trade_amount'] = 10 default_conf_usdt['targeted_trade_amount'] = 20 + default_conf_usdt['strategy_path'] = str( + Path(__file__).parent.parent / "strategy/strats/lookahead_bias") return default_conf_usdt @@ -33,7 +35,7 @@ def test_start_lookahead_analysis(mocker): args = [ "lookahead-analysis", "--strategy", - CURRENT_TEST_STRATEGY, + "strategy_test_v3_with_lookahead_bias", "--strategy-path", str(Path(__file__).parent.parent / "strategy" / "strats"), ] @@ -50,7 +52,7 @@ def test_start_lookahead_analysis(mocker): args = [ "lookahead-analysis", "--strategy", - CURRENT_TEST_STRATEGY, + "strategy_test_v3_with_lookahead_bias", "--strategy-path", str(Path(__file__).parent.parent / "strategy" / "strats"), "--targeted-trade-amount", @@ -114,16 +116,21 @@ def test_initialize_single_lookahead_analysis(): def test_biased_strategy(lookahead_conf, mocker, caplog) -> None: mocker.patch('freqtrade.data.history.get_timerange', get_timerange) + mocker.patch(f'{EXMS}.get_fee', return_value=0.0) + mocker.patch(f'{EXMS}.get_min_pair_stake_amount', return_value=0.00001) + mocker.patch(f'{EXMS}.get_max_pair_stake_amount', return_value=float('inf')) patch_exchange(mocker) mocker.patch('freqtrade.plugins.pairlistmanager.PairListManager.whitelist', PropertyMock(return_value=['UNITTEST/BTC'])) + lookahead_conf['pairs'] = ['UNITTEST/USDT'] lookahead_conf['timeframe'] = '5m' - lookahead_conf['timerange'] = '-1510694220' + lookahead_conf['timerange'] = '1516406400-1517270400' lookahead_conf['strategy'] = 'strategy_test_v3_with_lookahead_bias' strategy_obj = {} strategy_obj['name'] = "strategy_test_v3_with_lookahead_bias" - LookaheadAnalysis(lookahead_conf, strategy_obj) + instance = LookaheadAnalysis(lookahead_conf, strategy_obj) + instance.start() - pass + # TODO: assert something ... most likely output (?) or instance state? diff --git a/tests/strategy/strats/strategy_test_v3_with_lookahead_bias.py b/tests/strategy/strats/lookahead_bias/strategy_test_v3_with_lookahead_bias.py similarity index 100% rename from tests/strategy/strats/strategy_test_v3_with_lookahead_bias.py rename to tests/strategy/strats/lookahead_bias/strategy_test_v3_with_lookahead_bias.py