Automatically export hyperopt parameters
This commit is contained in:
parent
a2ccc1526e
commit
62cdbdc26a
@ -29,7 +29,7 @@ ARGS_HYPEROPT = ARGS_COMMON_OPTIMIZE + ["hyperopt", "hyperopt_path",
|
|||||||
"epochs", "spaces", "print_all",
|
"epochs", "spaces", "print_all",
|
||||||
"print_colorized", "print_json", "hyperopt_jobs",
|
"print_colorized", "print_json", "hyperopt_jobs",
|
||||||
"hyperopt_random_state", "hyperopt_min_trades",
|
"hyperopt_random_state", "hyperopt_min_trades",
|
||||||
"hyperopt_loss"]
|
"hyperopt_loss", "disableparamexport"]
|
||||||
|
|
||||||
ARGS_EDGE = ARGS_COMMON_OPTIMIZE + ["stoploss_range"]
|
ARGS_EDGE = ARGS_COMMON_OPTIMIZE + ["stoploss_range"]
|
||||||
|
|
||||||
@ -85,7 +85,8 @@ ARGS_HYPEROPT_LIST = ["hyperopt_list_best", "hyperopt_list_profitable",
|
|||||||
"hyperoptexportfilename", "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", "hyperoptexportfilename", "hyperopt_show_no_header"]
|
"print_json", "hyperoptexportfilename", "hyperopt_show_no_header",
|
||||||
|
"disableparamexport"]
|
||||||
|
|
||||||
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",
|
||||||
|
@ -178,6 +178,11 @@ AVAILABLE_CLI_OPTIONS = {
|
|||||||
'Example: `--export-filename=user_data/backtest_results/backtest_today.json`',
|
'Example: `--export-filename=user_data/backtest_results/backtest_today.json`',
|
||||||
metavar='PATH',
|
metavar='PATH',
|
||||||
),
|
),
|
||||||
|
"disableparamexport": Arg(
|
||||||
|
'--disable-param-export',
|
||||||
|
help="Disable automatic hyperopt parameter export.",
|
||||||
|
action='store_true',
|
||||||
|
),
|
||||||
"fee": Arg(
|
"fee": Arg(
|
||||||
'--fee',
|
'--fee',
|
||||||
help='Specify fee ratio. Will be applied twice (on trade entry and exit).',
|
help='Specify fee ratio. Will be applied twice (on trade entry and exit).',
|
||||||
|
@ -5,7 +5,6 @@ from typing import Any, Dict, List
|
|||||||
from colorama import init as colorama_init
|
from colorama import init as colorama_init
|
||||||
|
|
||||||
from freqtrade.configuration import setup_utils_configuration
|
from freqtrade.configuration import setup_utils_configuration
|
||||||
from freqtrade.constants import FTHYPT_FILEVERSION
|
|
||||||
from freqtrade.data.btanalysis import get_latest_hyperopt_file
|
from freqtrade.data.btanalysis import get_latest_hyperopt_file
|
||||||
from freqtrade.enums import RunMode
|
from freqtrade.enums import RunMode
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
@ -134,14 +133,7 @@ def start_hyperopt_show(args: Dict[str, Any]) -> None:
|
|||||||
show_backtest_result(strategy_name, metrics,
|
show_backtest_result(strategy_name, metrics,
|
||||||
metrics['stake_currency'])
|
metrics['stake_currency'])
|
||||||
|
|
||||||
if val.get(FTHYPT_FILEVERSION, 1) >= 2:
|
HyperoptTools.try_export_params(config, strategy_name, val)
|
||||||
# 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,
|
HyperoptTools.show_epoch_details(val, total_epochs, print_json, no_header,
|
||||||
header_str="Epoch details")
|
header_str="Epoch details")
|
||||||
|
@ -260,6 +260,8 @@ class Configuration:
|
|||||||
self._args_to_config(config, argname='export',
|
self._args_to_config(config, argname='export',
|
||||||
logstring='Parameter --export detected: {} ...')
|
logstring='Parameter --export detected: {} ...')
|
||||||
|
|
||||||
|
self._args_to_config(config, argname='disableparamexport',
|
||||||
|
logstring='Parameter --disableparamexport detected: {} ...')
|
||||||
# Edge section:
|
# Edge section:
|
||||||
if 'stoploss_range' in self.args and self.args["stoploss_range"]:
|
if 'stoploss_range' in self.args and self.args["stoploss_range"]:
|
||||||
txt_range = eval(self.args["stoploss_range"])
|
txt_range = eval(self.args["stoploss_range"])
|
||||||
|
@ -489,6 +489,11 @@ class Hyperopt:
|
|||||||
f"saved to '{self.results_file}'.")
|
f"saved to '{self.results_file}'.")
|
||||||
|
|
||||||
if self.current_best_epoch:
|
if self.current_best_epoch:
|
||||||
|
HyperoptTools.try_export_params(
|
||||||
|
self.config,
|
||||||
|
self.backtesting.strategy.get_strategy_name(),
|
||||||
|
self.current_best_epoch)
|
||||||
|
|
||||||
HyperoptTools.show_epoch_details(self.current_best_epoch, self.total_epochs,
|
HyperoptTools.show_epoch_details(self.current_best_epoch, self.total_epochs,
|
||||||
self.print_json)
|
self.print_json)
|
||||||
else:
|
else:
|
||||||
|
@ -10,7 +10,7 @@ import tabulate
|
|||||||
from colorama import Fore, Style
|
from colorama import Fore, Style
|
||||||
from pandas import isna, json_normalize
|
from pandas import isna, json_normalize
|
||||||
|
|
||||||
from freqtrade.constants import USERPATH_STRATEGIES
|
from freqtrade.constants import FTHYPT_FILEVERSION, USERPATH_STRATEGIES
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
from freqtrade.misc import deep_merge_dicts, round_coin_value, round_dict, safe_value_fallback2
|
from freqtrade.misc import deep_merge_dicts, round_coin_value, round_dict, safe_value_fallback2
|
||||||
|
|
||||||
@ -52,6 +52,16 @@ class HyperoptTools():
|
|||||||
logger.info(f"Dumping parameters to {filename}")
|
logger.info(f"Dumping parameters to {filename}")
|
||||||
rapidjson.dump(final_params, filename.open('w'), indent=2)
|
rapidjson.dump(final_params, filename.open('w'), indent=2)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def try_export_params(config: Dict[str, Any], strategy_name: str, val: Dict):
|
||||||
|
if val.get(FTHYPT_FILEVERSION, 1) >= 2 and not config.get('disableparamexport', False):
|
||||||
|
# Export 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.")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def has_space(config: Dict[str, Any], space: str) -> bool:
|
def has_space(config: Dict[str, Any], space: str) -> bool:
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user