From 107f00ff8f23f2721da9aa41d2a3fa9d71538832 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 15 Jul 2019 20:17:15 +0200 Subject: [PATCH] Add hyperopt option to clean temporary pickle files --- freqtrade/configuration/arguments.py | 10 +++++++++- freqtrade/configuration/configuration.py | 2 ++ freqtrade/optimize/hyperopt.py | 12 ++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/freqtrade/configuration/arguments.py b/freqtrade/configuration/arguments.py index 3e940ae2a..a3b2ca61f 100644 --- a/freqtrade/configuration/arguments.py +++ b/freqtrade/configuration/arguments.py @@ -223,6 +223,13 @@ AVAILABLE_CLI_OPTIONS = { metavar='INT', default=1, ), + "hyperopt_clean_state": Arg( + "--clean", + help="Remove temporary hyperopt files (should be used when the custom hyperopt file " + "was changed, or when changing the arguments for --min-trades or spaces.", + default=False, + action='store_true', + ), # List exchanges "print_one_column": Arg( '-1', '--one-column', @@ -309,7 +316,8 @@ ARGS_BACKTEST = ARGS_COMMON_OPTIMIZE + ["position_stacking", "use_max_market_pos ARGS_HYPEROPT = ARGS_COMMON_OPTIMIZE + ["hyperopt", "position_stacking", "epochs", "spaces", "use_max_market_positions", "print_all", "hyperopt_jobs", - "hyperopt_random_state", "hyperopt_min_trades"] + "hyperopt_random_state", "hyperopt_min_trades", + "hyperopt_clean_state"] ARGS_EDGE = ARGS_COMMON_OPTIMIZE + ["stoploss_range"] diff --git a/freqtrade/configuration/configuration.py b/freqtrade/configuration/configuration.py index 4959c2adc..ab8d018d5 100644 --- a/freqtrade/configuration/configuration.py +++ b/freqtrade/configuration/configuration.py @@ -284,6 +284,8 @@ class Configuration(object): self._args_to_config(config, argname='hyperopt_min_trades', logstring='Parameter --min-trades detected: {}') + self._args_to_config(config, argname='hyperopt_clean_state', + logstring='Removing hyperopt temp files') return config diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index e3683a66c..577180e3b 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -63,10 +63,22 @@ class Hyperopt(Backtesting): # Note, this is ratio. 3.85 stated above means 385Σ%. self.expected_max_profit = 3.0 + if self.config['hyperopt_clean_state']: + self.clean_hyperopt() # Previous evaluations self.trials_file = TRIALSDATA_PICKLE self.trials: List = [] + def clean_hyperopt(self): + """ + Remove hyperopt pickle files to restart hyperopt. + """ + for f in [TICKERDATA_PICKLE, TRIALSDATA_PICKLE]: + p = Path(f) + if p.is_file(): + logger.info(f"Removing `{p}`.") + p.unlink() + def get_args(self, params): dimensions = self.hyperopt_space() # Ensure the number of dimensions match