BugFix - hyperopt-show --print-json include non-optimized params
This commit is contained in:
parent
bb1222d9b8
commit
bd44deea0d
19
freqtrade/optimize/hyperopt_tools.py
Normal file → Executable file
19
freqtrade/optimize/hyperopt_tools.py
Normal file → Executable file
@ -93,7 +93,7 @@ class HyperoptTools():
|
||||
if print_json:
|
||||
result_dict: Dict = {}
|
||||
for s in ['buy', 'sell', 'roi', 'stoploss', 'trailing']:
|
||||
HyperoptTools._params_update_for_json(result_dict, params, s)
|
||||
HyperoptTools._params_update_for_json(result_dict, params, non_optimized, s)
|
||||
print(rapidjson.dumps(result_dict, default=str, number_mode=rapidjson.NM_NATIVE))
|
||||
|
||||
else:
|
||||
@ -106,11 +106,20 @@ class HyperoptTools():
|
||||
HyperoptTools._params_pretty_print(params, 'trailing', "Trailing stop:")
|
||||
|
||||
@staticmethod
|
||||
def _params_update_for_json(result_dict, params, space: str) -> None:
|
||||
def _params_update_for_json(result_dict, params, non_optimized, space: str) -> None:
|
||||
if space in params:
|
||||
space_params = HyperoptTools._space_params(params, space)
|
||||
space_non_optimized = HyperoptTools._space_params(non_optimized, space)
|
||||
all_space_params = space_params
|
||||
|
||||
# Include non optimized params if there are any
|
||||
if len(space_non_optimized) > 0:
|
||||
for non_optimized_param in space_non_optimized:
|
||||
if non_optimized_param not in all_space_params:
|
||||
all_space_params[non_optimized_param] = space_non_optimized[non_optimized_param]
|
||||
|
||||
if space in ['buy', 'sell']:
|
||||
result_dict.setdefault('params', {}).update(space_params)
|
||||
result_dict.setdefault('params', {}).update(all_space_params)
|
||||
elif space == 'roi':
|
||||
# TODO: get rid of OrderedDict when support for python 3.6 will be
|
||||
# dropped (dicts keep the order as the language feature)
|
||||
@ -120,10 +129,10 @@ class HyperoptTools():
|
||||
# OrderedDict is used to keep the numeric order of the items
|
||||
# in the dict.
|
||||
result_dict['minimal_roi'] = OrderedDict(
|
||||
(str(k), v) for k, v in space_params.items()
|
||||
(str(k), v) for k, v in all_space_params.items()
|
||||
)
|
||||
else: # 'stoploss', 'trailing'
|
||||
result_dict.update(space_params)
|
||||
result_dict.update(all_space_params)
|
||||
|
||||
@staticmethod
|
||||
def _params_pretty_print(params, space: str, header: str, non_optimized={}) -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user