Fix a rare error in save_result : ValueError: Out of range float values are not JSON compliant

freqtrade/freqtrade/optimize/hyperopt.py", line 166, in _save_result
    rapidjson.dump(epoch, f, default=str, number_mode=rapidjson.NM_NATIVE)
ValueError: Out of range float values are not JSON compliant
This commit is contained in:
Priveyes 2021-05-23 18:49:07 +02:00 committed by GitHub
parent ae037b0ec1
commit 6f990c5976
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -163,7 +163,7 @@ class Hyperopt:
:param epoch: result dictionary for this epoch. :param epoch: result dictionary for this epoch.
""" """
with self.results_file.open('a') as f: with self.results_file.open('a') as f:
rapidjson.dump(epoch, f, default=str, number_mode=rapidjson.NM_NATIVE) rapidjson.dump(epoch, f, default=str, number_mode=rapidjson.NM_NATIVE | rapidjson.NM_NAN)
f.write("\n") f.write("\n")
self.num_epochs_saved += 1 self.num_epochs_saved += 1