make flake and mypy happy

This commit is contained in:
hroff-1902 2019-08-15 23:13:46 +03:00
parent 4fa92ec0fa
commit e525275d10

View File

@ -140,7 +140,7 @@ class Hyperopt(Backtesting):
print(f"\nBest result:\n\n{log_str}\n") print(f"\nBest result:\n\n{log_str}\n")
if self.config.get('print_json'): if self.config.get('print_json'):
result_dict = {} result_dict: Dict = {}
if self.has_space('buy') or self.has_space('sell'): if self.has_space('buy') or self.has_space('sell'):
result_dict['params'] = {} result_dict['params'] = {}
if self.has_space('buy'): if self.has_space('buy'):
@ -150,13 +150,13 @@ class Hyperopt(Backtesting):
result_dict['params'].update({p.name: params.get(p.name) result_dict['params'].update({p.name: params.get(p.name)
for p in self.hyperopt_space('sell')}) for p in self.hyperopt_space('sell')})
if self.has_space('roi'): if self.has_space('roi'):
min_roi = self.custom_hyperopt.generate_roi_table(params)
# Convert keys in min_roi dict to strings because # Convert keys in min_roi dict to strings because
# rapidjson cannot dump dicts with integer keys... # rapidjson cannot dump dicts with integer keys...
# OrderedDict is used to keep the numeric order of the items # OrderedDict is used to keep the numeric order of the items
# in the dict. # in the dict.
min_roi = OrderedDict((str(k),v) for k,v in min_roi.items()) result_dict['minimal_roi'] = OrderedDict(
result_dict['minimal_roi'] = min_roi (str(k), v) for k, v in self.custom_hyperopt.generate_roi_table(params).items()
)
if self.has_space('stoploss'): if self.has_space('stoploss'):
result_dict['stoploss'] = params.get('stoploss') result_dict['stoploss'] = params.get('stoploss')
print(rapidjson.dumps(result_dict, default=str, number_mode=rapidjson.NM_NATIVE)) print(rapidjson.dumps(result_dict, default=str, number_mode=rapidjson.NM_NATIVE))