From 31ab32f0b965f112c796112f830d0c3e550ddc7d Mon Sep 17 00:00:00 2001 From: hroff-1902 Date: Fri, 8 Nov 2019 12:47:28 +0300 Subject: [PATCH] Always set trailing_stop=True with 'trailing' hyperspace --- freqtrade/optimize/hyperopt.py | 3 +-- freqtrade/optimize/hyperopt_interface.py | 9 ++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index c5a003bd6..e5e027d46 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -313,8 +313,7 @@ class Hyperopt: if self.has_space('trailing'): self.backtesting.strategy.trailing_stop = params['trailing_stop'] - self.backtesting.strategy.trailing_stop_positive = \ - params['trailing_stop_positive'] + self.backtesting.strategy.trailing_stop_positive = params['trailing_stop_positive'] self.backtesting.strategy.trailing_stop_positive_offset = \ params['trailing_stop_positive_offset'] self.backtesting.strategy.trailing_only_offset_is_reached = \ diff --git a/freqtrade/optimize/hyperopt_interface.py b/freqtrade/optimize/hyperopt_interface.py index e8f16d572..b4cfdcaf3 100644 --- a/freqtrade/optimize/hyperopt_interface.py +++ b/freqtrade/optimize/hyperopt_interface.py @@ -182,7 +182,14 @@ class IHyperOpt(ABC): You may override it in your custom Hyperopt class. """ return [ - Categorical([True, False], name='trailing_stop'), + # It was decided to always set trailing_stop is to True if the 'trailing' hyperspace + # is used. Otherwise hyperopt will vary other parameters that won't have effect if + # trailing_stop is set False. + # This parameter is included into the hyperspace dimensions rather than assigning + # it explicitly in the code in order to have it printed in the results along with + # other 'trailing' hyperspace parameters. + Categorical([True], name='trailing_stop'), + Real(-0.35, -0.02, name='trailing_stop_positive'), Real(0.01, 0.1, name='trailing_stop_positive_offset'), Categorical([True, False], name='trailing_only_offset_is_reached'),