Automatically export hyperopt parameters

This commit is contained in:
Matthias
2021-06-29 20:22:30 +02:00
parent a2ccc1526e
commit 62cdbdc26a
6 changed files with 27 additions and 12 deletions

View File

@@ -489,6 +489,11 @@ class Hyperopt:
f"saved to '{self.results_file}'.")
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,
self.print_json)
else:

View File

@@ -10,7 +10,7 @@ import tabulate
from colorama import Fore, Style
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.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}")
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
def has_space(config: Dict[str, Any], space: str) -> bool:
"""