From 50071659084285c42fe9ec323d6af3e51b921389 Mon Sep 17 00:00:00 2001 From: Janne Sinivirta Date: Wed, 24 Jan 2018 17:58:44 +0200 Subject: [PATCH] add search space for ROI table --- freqtrade/optimize/hyperopt.py | 20 +++++++++++++++++--- freqtrade/tests/optimize/test_hyperopt.py | 6 ++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index 62dcdf68f..16bb30fd4 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -225,11 +225,22 @@ def calculate_loss(total_profit: float, trade_count: int, trade_duration: float) return trade_loss + profit_loss + duration_loss -def hyperopt_space() -> List[Dict]: +def roi_space() -> List[Dict]: + return { + 'roi_t1': hp.quniform('roi_t1', 10, 220, 10), + 'roi_t2': hp.quniform('roi_t2', 10, 120, 10), + 'roi_t3': hp.quniform('roi_t3', 10, 120, 10), + 'roi_p1': hp.quniform('roi_p1', 1, 5, 1), + 'roi_p2': hp.quniform('roi_p2', 1, 5, 1), + 'roi_p3': hp.quniform('roi_p3', 1, 10, 1), + } + + +def indicator_space() -> List[Dict]: """ Define your Hyperopt space for searching strategy parameters """ - space = { + return { 'macd_below_zero': hp.choice('macd_below_zero', [ {'enabled': False}, {'enabled': True} @@ -284,7 +295,10 @@ def hyperopt_space() -> List[Dict]: ]), 'stoploss': hp.uniform('stoploss', -0.5, -0.02), } - return space + + +def hyperopt_space() -> List[Dict]: + return {**indicator_space(), **roi_space()} def buy_strategy_generator(params) -> None: diff --git a/freqtrade/tests/optimize/test_hyperopt.py b/freqtrade/tests/optimize/test_hyperopt.py index 6e21cde76..9e5517df6 100644 --- a/freqtrade/tests/optimize/test_hyperopt.py +++ b/freqtrade/tests/optimize/test_hyperopt.py @@ -125,6 +125,12 @@ def test_fmin_best_results(mocker, caplog): "uptrend_short_ema": 0, "uptrend_sma": 0, "stoploss": -0.1, + "roi_t1": 1, + "roi_t2": 2, + "roi_t3": 3, + "roi_p1": 1, + "roi_p2": 2, + "roi_p3": 3, } mocker.patch('freqtrade.optimize.hyperopt.MongoTrials', return_value=create_trials(mocker))