From 065ebd39ef9fae6c57f133bbf4c41ee46e3e6be1 Mon Sep 17 00:00:00 2001 From: hroff-1902 Date: Thu, 1 Aug 2019 23:57:26 +0300 Subject: [PATCH] cleanup in hyperopt --- freqtrade/optimize/hyperopt.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index 842a111ca..479f8c70a 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -78,6 +78,12 @@ class Hyperopt(Backtesting): self.max_open_trades = 0 self.position_stacking = self.config.get('position_stacking', False), + if self.has_space('sell'): + # Make sure experimental is enabled + if 'experimental' not in self.config: + self.config['experimental'] = {} + self.config['experimental']['use_sell_signal'] = True + def clean_hyperopt(self): """ Remove hyperopt pickle files to restart hyperopt. @@ -124,13 +130,14 @@ class Hyperopt(Backtesting): """ results = sorted(self.trials, key=itemgetter('loss')) best_result = results[0] + params = best_result['params'] log_str = self.format_results_logstring(best_result) print(f"\nBest result:\n{log_str}\nwith values:") - pprint(best_result['params'], indent=4) - if 'roi_t1' in best_result['params']: + pprint(params, indent=4) + if self.has_space('roi'): print("ROI table:") - pprint(self.custom_hyperopt.generate_roi_table(best_result['params']), indent=4) + pprint(self.custom_hyperopt.generate_roi_table(params), indent=4) def log_results(self, results) -> None: """ @@ -162,9 +169,7 @@ class Hyperopt(Backtesting): """ Tell if a space value is contained in the configuration """ - if space in self.config['spaces'] or 'all' in self.config['spaces']: - return True - return False + return any(s in self.config['spaces'] for s in [space, 'all']) def hyperopt_space(self) -> List[Dimension]: """ @@ -172,16 +177,16 @@ class Hyperopt(Backtesting): """ spaces: List[Dimension] = [] if self.has_space('buy'): + logger.debug("Hyperopt has 'buy' space") spaces += self.custom_hyperopt.indicator_space() if self.has_space('sell'): + logger.debug("Hyperopt has 'sell' space") spaces += self.custom_hyperopt.sell_indicator_space() - # Make sure experimental is enabled - if 'experimental' not in self.config: - self.config['experimental'] = {} - self.config['experimental']['use_sell_signal'] = True if self.has_space('roi'): + logger.debug("Hyperopt has 'roi' space") spaces += self.custom_hyperopt.roi_space() if self.has_space('stoploss'): + logger.debug("Hyperopt has 'stoploss' space") spaces += self.custom_hyperopt.stoploss_space() return spaces