Always set trailing_stop=True with 'trailing' hyperspace

This commit is contained in:
hroff-1902 2019-11-08 12:47:28 +03:00
parent d3a3765819
commit 31ab32f0b9
2 changed files with 9 additions and 3 deletions

View File

@ -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 = \

View File

@ -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'),