Fix generation of hyperopt trailing params

This commit is contained in:
hroff-1902
2019-12-10 03:13:45 +03:00
parent 0e4ef33d6a
commit 641e3fdf7a
2 changed files with 28 additions and 9 deletions

View File

@@ -177,8 +177,7 @@ class Hyperopt:
result['stoploss'] = {p.name: params.get(p.name)
for p in self.hyperopt_space('stoploss')}
if self.has_space('trailing'):
result['trailing'] = {p.name: params.get(p.name)
for p in self.hyperopt_space('trailing')}
result['trailing'] = self.custom_hyperopt.generate_trailing_params(params)
return result
@@ -353,13 +352,13 @@ class Hyperopt:
self.backtesting.strategy.stoploss = params_dict['stoploss']
if self.has_space('trailing'):
self.backtesting.strategy.trailing_stop = params_dict['trailing_stop']
self.backtesting.strategy.trailing_stop_positive = \
params_dict['trailing_stop_positive']
d = self.custom_hyperopt.generate_trailing_params(params_dict)
self.backtesting.strategy.trailing_stop = d['trailing_stop']
self.backtesting.strategy.trailing_stop_positive = d['trailing_stop_positive']
self.backtesting.strategy.trailing_stop_positive_offset = \
params_dict['trailing_stop_positive_offset']
d['trailing_stop_positive_offset']
self.backtesting.strategy.trailing_only_offset_is_reached = \
params_dict['trailing_only_offset_is_reached']
d['trailing_only_offset_is_reached']
processed = load(self.tickerdata_pickle)