Catch trying to read faulty parameter file

This commit is contained in:
Matthias 2021-06-29 20:38:14 +02:00
parent 62cdbdc26a
commit 55f032b18e
2 changed files with 9 additions and 4 deletions

View File

@ -313,6 +313,7 @@ CONF_SCHEMA = {
},
'db_url': {'type': 'string'},
'export': {'type': 'string', 'enum': EXPORT_OPTIONS, 'default': 'trades'},
'disableparamexport': {'type': 'boolean'},
'initial_state': {'type': 'string', 'enum': ['running', 'stopped']},
'forcebuy_enable': {'type': 'boolean'},
'disable_dataframe_checks': {'type': 'boolean'},

View File

@ -324,10 +324,14 @@ class HyperStrategyMixin(object):
if filename.is_file():
logger.info(f"Loading parameters from file {filename}")
params = json_load(filename.open('r'))
if params.get('strategy_name') != self.__class__.__name__:
raise OperationalException('Invalid parameter file provided')
return params
try:
params = json_load(filename.open('r'))
if params.get('strategy_name') != self.__class__.__name__:
raise OperationalException('Invalid parameter file provided')
return params
except ValueError:
logger.warning("Invalid parameter file.")
return {}
logger.info("Found no parameter file.")
return {}