diff --git a/freqtrade/commands/hyperopt_commands.py b/freqtrade/commands/hyperopt_commands.py index e5c9241f0..e60fb9d32 100755 --- a/freqtrade/commands/hyperopt_commands.py +++ b/freqtrade/commands/hyperopt_commands.py @@ -5,6 +5,7 @@ from typing import Any, Dict, List from colorama import init as colorama_init from freqtrade.configuration import setup_utils_configuration +from freqtrade.constants import FTHYPT_FILEVERSION from freqtrade.data.btanalysis import get_latest_hyperopt_file from freqtrade.enums import RunMode from freqtrade.exceptions import OperationalException @@ -133,13 +134,14 @@ def start_hyperopt_show(args: Dict[str, Any]) -> None: show_backtest_result(strategy_name, metrics, metrics['stake_currency']) - # Export parameters ... - # TODO: make this optional? otherwise it'll overwrite previous parameters ... - fn = HyperoptTools.get_strategy_filename(config, strategy_name) - if fn: - HyperoptTools.export_params(val, strategy_name, fn.with_suffix('.json')) - else: - logger.warn("Strategy not found, not exporting parameter file.") + if val.get(FTHYPT_FILEVERSION, 1) >= 2: + # Export parameters ... + # TODO: make this optional? otherwise it'll overwrite previous parameters ... + fn = HyperoptTools.get_strategy_filename(config, strategy_name) + if fn: + HyperoptTools.export_params(val, strategy_name, fn.with_suffix('.json')) + else: + logger.warn("Strategy not found, not exporting parameter file.") HyperoptTools.show_epoch_details(val, total_epochs, print_json, no_header, header_str="Epoch details") diff --git a/freqtrade/constants.py b/freqtrade/constants.py index 63cf3e870..bdbfbfad6 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -40,6 +40,7 @@ DEFAULT_DATAFRAME_COLUMNS = ['date', 'open', 'high', 'low', 'close', 'volume'] DEFAULT_TRADES_COLUMNS = ['timestamp', 'id', 'type', 'side', 'price', 'amount', 'cost'] LAST_BT_RESULT_FN = '.last_result.json' +FTHYPT_FILEVERSION = 'fthypt_fileversion' USERPATH_HYPEROPTS = 'hyperopts' USERPATH_STRATEGIES = 'strategies' diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index ea75028b4..23f47612b 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -20,7 +20,7 @@ from colorama import init as colorama_init from joblib import Parallel, cpu_count, delayed, dump, load, wrap_non_picklable_objects from pandas import DataFrame -from freqtrade.constants import DATETIME_PRINT_FORMAT, LAST_BT_RESULT_FN +from freqtrade.constants import DATETIME_PRINT_FORMAT, FTHYPT_FILEVERSION, LAST_BT_RESULT_FN from freqtrade.data.converter import trim_dataframes from freqtrade.data.history import get_timerange from freqtrade.misc import deep_merge_dicts, file_dump_json, plural @@ -167,7 +167,7 @@ class Hyperopt: if isinstance(x, np.integer): return int(x) return str(x) - + epoch[FTHYPT_FILEVERSION] = 2 with self.results_file.open('a') as f: rapidjson.dump(epoch, f, default=default_parser, number_mode=rapidjson.NM_NATIVE | rapidjson.NM_NAN) diff --git a/freqtrade/optimize/hyperopt_tools.py b/freqtrade/optimize/hyperopt_tools.py index a99859fd5..8f69fbcff 100755 --- a/freqtrade/optimize/hyperopt_tools.py +++ b/freqtrade/optimize/hyperopt_tools.py @@ -46,7 +46,8 @@ class HyperoptTools(): final_params = deep_merge_dicts(params['params_details'], final_params) final_params = { 'strategy_name': strategy_name, - 'params': final_params + 'params': final_params, + 'ft_stratparam_v': 1, } logger.info(f"Dumping parameters to {filename}") rapidjson.dump(final_params, filename.open('w'), indent=2)