From 26a7af85eaae69bce974c6ac97837bb248384a05 Mon Sep 17 00:00:00 2001 From: hroff-1902 Date: Sun, 1 Dec 2019 03:31:03 +0300 Subject: [PATCH] Add trailing_space() into AdvancedSampleHyperOpt --- .../templates/sample_hyperopt_advanced.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/freqtrade/templates/sample_hyperopt_advanced.py b/freqtrade/templates/sample_hyperopt_advanced.py index 5634c21ea..b4bbee3fb 100644 --- a/freqtrade/templates/sample_hyperopt_advanced.py +++ b/freqtrade/templates/sample_hyperopt_advanced.py @@ -233,6 +233,27 @@ class AdvancedSampleHyperOpt(IHyperOpt): Real(-0.5, -0.02, name='stoploss'), ] + @staticmethod + def trailing_space() -> List[Dimension]: + """ + Create a trailing stoploss space. + + You may override it in your custom Hyperopt class. + """ + return [ + # 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.02, 0.35, name='trailing_stop_positive'), + Real(0.01, 0.1, name='trailing_stop_positive_offset'), + Categorical([True, False], name='trailing_only_offset_is_reached'), + ] + def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: """ Based on TA indicators.