Simplify "no-space-configured" error handling by moving it to hyperopt_auto

This commit is contained in:
Matthias
2021-10-13 19:54:35 +02:00
parent df45f467c6
commit aed919a05f
5 changed files with 33 additions and 57 deletions

View File

@@ -237,63 +237,28 @@ class Hyperopt:
logger.debug("Hyperopt has 'protection' space")
# Enable Protections if protection space is selected.
self.config['enable_protections'] = True
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
self.protection_space = self.custom_hyperopt.protection_space()
if HyperoptTools.has_space(self.config, 'buy'):
logger.debug("Hyperopt has 'buy' 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
self.buy_space = self.custom_hyperopt.buy_indicator_space()
if HyperoptTools.has_space(self.config, 'sell'):
logger.debug("Hyperopt has 'sell' 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
self.sell_space = self.custom_hyperopt.sell_indicator_space()
if HyperoptTools.has_space(self.config, 'roi'):
logger.debug("Hyperopt has '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
self.roi_space = self.custom_hyperopt.roi_space()
if HyperoptTools.has_space(self.config, 'stoploss'):
logger.debug("Hyperopt has '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
self.stoploss_space = self.custom_hyperopt.stoploss_space()
if HyperoptTools.has_space(self.config, 'trailing'):
logger.debug("Hyperopt has '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.trailing_space = self.custom_hyperopt.trailing_space()
self.dimensions = (self.buy_space + self.sell_space + self.protection_space
+ self.roi_space + self.stoploss_space + self.trailing_space)