mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Introduce File versions to hyperopt result files
This commit is contained in:
parent
a7e9e362b7
commit
d4514f5f16
|
@ -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")
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user