From df45f467c69e5b0dc64fe8cb5b5af716b42979d7 Mon Sep 17 00:00:00 2001 From: Scott Lyons Date: Thu, 30 Sep 2021 01:11:02 -0700 Subject: [PATCH] Adding ability to ignore unparameterized spaces --- freqtrade/optimize/hyperopt.py | 48 +++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index 9549b4054..f6c677a6e 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -237,27 +237,63 @@ class Hyperopt: logger.debug("Hyperopt has 'protection' space") # Enable Protections if protection space is selected. self.config['enable_protections'] = True - self.protection_space = self.custom_hyperopt.protection_space() + try: + self.protection_space = self.custom_hyperopt.protection_space() + except OperationalException as e: + if self.config["hyperopt_ignore_unparam_space"]: + logger.warning(e) + else: + raise if HyperoptTools.has_space(self.config, 'buy'): logger.debug("Hyperopt has 'buy' space") - self.buy_space = self.custom_hyperopt.buy_indicator_space() + try: + self.buy_space = self.custom_hyperopt.buy_indicator_space() + except OperationalException as e: + if self.config["hyperopt_ignore_unparam_space"]: + logger.warning(e) + else: + raise if HyperoptTools.has_space(self.config, 'sell'): logger.debug("Hyperopt has 'sell' space") - self.sell_space = self.custom_hyperopt.sell_indicator_space() + try: + self.sell_space = self.custom_hyperopt.sell_indicator_space() + except OperationalException as e: + if self.config["hyperopt_ignore_unparam_space"]: + logger.warning(e) + else: + raise if HyperoptTools.has_space(self.config, 'roi'): logger.debug("Hyperopt has 'roi' space") - self.roi_space = self.custom_hyperopt.roi_space() + try: + self.roi_space = self.custom_hyperopt.roi_space() + except OperationalException as e: + if self.config["hyperopt_ignore_unparam_space"]: + logger.warning(e) + else: + raise if HyperoptTools.has_space(self.config, 'stoploss'): logger.debug("Hyperopt has 'stoploss' space") - self.stoploss_space = self.custom_hyperopt.stoploss_space() + try: + self.stoploss_space = self.custom_hyperopt.stoploss_space() + except OperationalException as e: + if self.config["hyperopt_ignore_unparam_space"]: + logger.warning(e) + else: + raise if HyperoptTools.has_space(self.config, 'trailing'): logger.debug("Hyperopt has 'trailing' space") - self.trailing_space = self.custom_hyperopt.trailing_space() + try: + self.trailing_space = self.custom_hyperopt.trailing_space() + except OperationalException as e: + if self.config["hyperopt_ignore_unparam_space"]: + logger.warning(e) + else: + raise self.dimensions = (self.buy_space + self.sell_space + self.protection_space + self.roi_space + self.stoploss_space + self.trailing_space)