Support loading results from a specific hyperopt history file
This commit is contained in:
parent
c42a924df8
commit
3cb1a9a5a9
@ -75,10 +75,10 @@ ARGS_HYPEROPT_LIST = ["hyperopt_list_best", "hyperopt_list_profitable",
|
|||||||
"hyperopt_list_min_total_profit", "hyperopt_list_max_total_profit",
|
"hyperopt_list_min_total_profit", "hyperopt_list_max_total_profit",
|
||||||
"hyperopt_list_min_objective", "hyperopt_list_max_objective",
|
"hyperopt_list_min_objective", "hyperopt_list_max_objective",
|
||||||
"print_colorized", "print_json", "hyperopt_list_no_details",
|
"print_colorized", "print_json", "hyperopt_list_no_details",
|
||||||
"export_csv"]
|
"hyperoptexportfilename", "export_csv"]
|
||||||
|
|
||||||
ARGS_HYPEROPT_SHOW = ["hyperopt_list_best", "hyperopt_list_profitable", "hyperopt_show_index",
|
ARGS_HYPEROPT_SHOW = ["hyperopt_list_best", "hyperopt_list_profitable", "hyperopt_show_index",
|
||||||
"print_json", "hyperopt_show_no_header"]
|
"print_json", "hyperoptexportfilename", "hyperopt_show_no_header"]
|
||||||
|
|
||||||
NO_CONF_REQURIED = ["convert-data", "convert-trade-data", "download-data", "list-timeframes",
|
NO_CONF_REQURIED = ["convert-data", "convert-trade-data", "download-data", "list-timeframes",
|
||||||
"list-markets", "list-pairs", "list-strategies", "list-data",
|
"list-markets", "list-pairs", "list-strategies", "list-data",
|
||||||
|
@ -263,6 +263,12 @@ AVAILABLE_CLI_OPTIONS = {
|
|||||||
metavar='NAME',
|
metavar='NAME',
|
||||||
default=constants.DEFAULT_HYPEROPT_LOSS,
|
default=constants.DEFAULT_HYPEROPT_LOSS,
|
||||||
),
|
),
|
||||||
|
"hyperoptexportfilename": Arg(
|
||||||
|
'--hyperopt-filename',
|
||||||
|
help='Hyperopt result filename.'
|
||||||
|
'Example: `--hyperopt-filename=hyperopt_results_2020-09-27_16-20-48.pickle`',
|
||||||
|
metavar='PATH',
|
||||||
|
),
|
||||||
# List exchanges
|
# List exchanges
|
||||||
"print_one_column": Arg(
|
"print_one_column": Arg(
|
||||||
'-1', '--one-column',
|
'-1', '--one-column',
|
||||||
|
@ -41,7 +41,9 @@ def start_hyperopt_list(args: Dict[str, Any]) -> None:
|
|||||||
'filter_max_objective': config.get('hyperopt_list_max_objective', None),
|
'filter_max_objective': config.get('hyperopt_list_max_objective', None),
|
||||||
}
|
}
|
||||||
|
|
||||||
results_file = get_latest_hyperopt_file(config['user_data_dir'] / 'hyperopt_results')
|
results_file = get_latest_hyperopt_file(
|
||||||
|
config['user_data_dir'] / 'hyperopt_results',
|
||||||
|
config.get('hyperoptexportfilename'))
|
||||||
|
|
||||||
# Previous evaluations
|
# Previous evaluations
|
||||||
epochs = Hyperopt.load_previous_results(results_file)
|
epochs = Hyperopt.load_previous_results(results_file)
|
||||||
@ -80,7 +82,10 @@ def start_hyperopt_show(args: Dict[str, Any]) -> None:
|
|||||||
|
|
||||||
print_json = config.get('print_json', False)
|
print_json = config.get('print_json', False)
|
||||||
no_header = config.get('hyperopt_show_no_header', False)
|
no_header = config.get('hyperopt_show_no_header', False)
|
||||||
results_file = get_latest_hyperopt_file(config['user_data_dir'] / 'hyperopt_results')
|
results_file = get_latest_hyperopt_file(
|
||||||
|
config['user_data_dir'] / 'hyperopt_results',
|
||||||
|
config.get('hyperoptexportfilename'))
|
||||||
|
|
||||||
|
|
||||||
n = config.get('hyperopt_show_index', -1)
|
n = config.get('hyperopt_show_index', -1)
|
||||||
|
|
||||||
|
@ -263,6 +263,9 @@ class Configuration:
|
|||||||
self._args_to_config(config, argname='hyperopt_path',
|
self._args_to_config(config, argname='hyperopt_path',
|
||||||
logstring='Using additional Hyperopt lookup path: {}')
|
logstring='Using additional Hyperopt lookup path: {}')
|
||||||
|
|
||||||
|
self._args_to_config(config, argname='hyperoptexportfilename',
|
||||||
|
logstring='Using hyperopt file: {}')
|
||||||
|
|
||||||
self._args_to_config(config, argname='epochs',
|
self._args_to_config(config, argname='epochs',
|
||||||
logstring='Parameter --epochs detected ... '
|
logstring='Parameter --epochs detected ... '
|
||||||
'Will run Hyperopt with for {} epochs ...'
|
'Will run Hyperopt with for {} epochs ...'
|
||||||
|
@ -81,7 +81,7 @@ def get_latest_hyperopt_filename(directory: Union[Path, str]) -> str:
|
|||||||
return 'hyperopt_results.pickle'
|
return 'hyperopt_results.pickle'
|
||||||
|
|
||||||
|
|
||||||
def get_latest_hyperopt_file(directory: Union[Path, str]) -> Path:
|
def get_latest_hyperopt_file(directory: Union[Path, str], predef_filename: str = None) -> Path:
|
||||||
"""
|
"""
|
||||||
Get latest hyperopt export based on '.last_result.json'.
|
Get latest hyperopt export based on '.last_result.json'.
|
||||||
:param directory: Directory to search for last result
|
:param directory: Directory to search for last result
|
||||||
@ -91,6 +91,9 @@ def get_latest_hyperopt_file(directory: Union[Path, str]) -> Path:
|
|||||||
* `directory/.last_result.json` does not exist
|
* `directory/.last_result.json` does not exist
|
||||||
* `directory/.last_result.json` has the wrong content
|
* `directory/.last_result.json` has the wrong content
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if predef_filename:
|
||||||
|
return directory / predef_filename
|
||||||
return directory / get_latest_hyperopt_filename(directory)
|
return directory / get_latest_hyperopt_filename(directory)
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ from freqtrade.data.btanalysis import (BT_DATA_COLUMNS,
|
|||||||
create_cum_profit,
|
create_cum_profit,
|
||||||
extract_trades_of_period,
|
extract_trades_of_period,
|
||||||
get_latest_backtest_filename,
|
get_latest_backtest_filename,
|
||||||
|
get_latest_hyperopt_file,
|
||||||
load_backtest_data, load_trades,
|
load_backtest_data, load_trades,
|
||||||
load_trades_from_db)
|
load_trades_from_db)
|
||||||
from freqtrade.data.history import load_data, load_pair_history
|
from freqtrade.data.history import load_data, load_pair_history
|
||||||
@ -43,6 +44,14 @@ def test_get_latest_backtest_filename(testdatadir, mocker):
|
|||||||
get_latest_backtest_filename(testdatadir)
|
get_latest_backtest_filename(testdatadir)
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_latest_hyperopt_file(testdatadir, mocker):
|
||||||
|
res = get_latest_hyperopt_file(testdatadir / 'does_not_exist', 'testfile.pickle')
|
||||||
|
assert res == testdatadir / 'does_not_exist/testfile.pickle'
|
||||||
|
|
||||||
|
res = get_latest_hyperopt_file(testdatadir.parent)
|
||||||
|
assert res == testdatadir.parent / "hyperopt_results.pickle"
|
||||||
|
|
||||||
|
|
||||||
def test_load_backtest_data_old_format(testdatadir):
|
def test_load_backtest_data_old_format(testdatadir):
|
||||||
|
|
||||||
filename = testdatadir / "backtest-result_test.json"
|
filename = testdatadir / "backtest-result_test.json"
|
||||||
|
Loading…
Reference in New Issue
Block a user