Fix hyperopt output

closes #4892
This commit is contained in:
Matthias 2021-05-07 20:23:11 +02:00
parent 4a7d7a5779
commit 513be11fd9
2 changed files with 16 additions and 1 deletions

View File

@ -157,7 +157,8 @@ class HyperoptTools():
result = '{\n'
for k, param in p.items():
result += " " * indent + f'"{k}": {param},'
result += " " * indent + f'"{k}": '
result += f'"{param}",' if isinstance(param, str) else f'{param},'
if k in non_optimized:
result += " # value loaded from strategy"
result += "\n"

View File

@ -1156,3 +1156,17 @@ def test_SKDecimal():
assert space.transform([2.0]) == [200]
assert space.transform([1.0]) == [100]
assert space.transform([1.5, 1.6]) == [150, 160]
def test___pprint():
params = {'buy_std': 1.2, 'buy_rsi': 31, 'buy_enable': True, 'buy_what': 'asdf'}
non_params = {'buy_notoptimied': 55}
x = HyperoptTools._pprint(params, non_params)
assert x == """{
"buy_std": 1.2,
"buy_rsi": 31,
"buy_enable": True,
"buy_what": "asdf",
"buy_notoptimied": 55, # value loaded from strategy
}"""