Catch trying to read faulty parameter file
This commit is contained in:
parent
62cdbdc26a
commit
55f032b18e
@ -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'},
|
||||
|
@ -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 {}
|
||||
|
Loading…
Reference in New Issue
Block a user