From 15e36a20e1948e891a1c7956e5db3a6e09b1c26b Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 30 Jun 2021 19:48:34 +0200 Subject: [PATCH] Improve naming of default hyperopt serializer --- freqtrade/optimize/hyperopt.py | 4 ++-- freqtrade/optimize/hyperopt_tools.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index 1f50d9a16..73a04a8cb 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -28,7 +28,7 @@ from freqtrade.optimize.backtesting import Backtesting from freqtrade.optimize.hyperopt_auto import HyperOptAuto from freqtrade.optimize.hyperopt_interface import IHyperOpt # noqa: F401 from freqtrade.optimize.hyperopt_loss_interface import IHyperOptLoss # noqa: F401 -from freqtrade.optimize.hyperopt_tools import HyperoptTools, hyperopt_parser +from freqtrade.optimize.hyperopt_tools import HyperoptTools, hyperopt_serializer from freqtrade.optimize.optimize_reports import generate_strategy_stats from freqtrade.resolvers.hyperopt_resolver import HyperOptLossResolver, HyperOptResolver @@ -167,7 +167,7 @@ class Hyperopt: """ epoch[FTHYPT_FILEVERSION] = 2 with self.results_file.open('a') as f: - rapidjson.dump(epoch, f, default=hyperopt_parser, + rapidjson.dump(epoch, f, default=hyperopt_serializer, number_mode=rapidjson.NM_NATIVE | rapidjson.NM_NAN) f.write("\n") diff --git a/freqtrade/optimize/hyperopt_tools.py b/freqtrade/optimize/hyperopt_tools.py index 7a0b00d01..006bc4ce0 100755 --- a/freqtrade/optimize/hyperopt_tools.py +++ b/freqtrade/optimize/hyperopt_tools.py @@ -22,7 +22,7 @@ logger = logging.getLogger(__name__) NON_OPT_PARAM_APPENDIX = " # value loaded from strategy" -def hyperopt_parser(x): +def hyperopt_serializer(x): if isinstance(x, np.integer): return int(x) return str(x) @@ -60,7 +60,8 @@ class HyperoptTools(): } logger.info(f"Dumping parameters to {filename}") rapidjson.dump(final_params, filename.open('w'), indent=2, - default=hyperopt_parser, number_mode=rapidjson.NM_NATIVE | rapidjson.NM_NAN + default=hyperopt_serializer, + number_mode=rapidjson.NM_NATIVE | rapidjson.NM_NAN ) @staticmethod