Revert --clean argument to --continue

This commit is contained in:
Matthias 2019-07-16 05:50:27 +02:00
parent c4e55d78d5
commit 7d62bb8c53
4 changed files with 32 additions and 11 deletions

View File

@ -223,10 +223,10 @@ 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.",
"hyperopt_continue": Arg(
"--continue",
help="Continue hyperopt from previous runs. "
"By default, temporary files will be removed and hyperopt will start from scratch.",
default=False,
action='store_true',
),
@ -325,7 +325,7 @@ 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_clean_state", "loss_function"]
"hyperopt_continue", "loss_function"]
ARGS_EDGE = ARGS_COMMON_OPTIMIZE + ["stoploss_range"]

View File

@ -285,8 +285,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')
self._args_to_config(config, argname='hyperopt_continue',
logstring='Hyperopt continue: {}')
self._args_to_config(config, argname='loss_function',
logstring='Using loss function: {}')

View File

@ -65,8 +65,11 @@ class Hyperopt(Backtesting):
# Note, this is ratio. 3.85 stated above means 385Σ%.
self.expected_max_profit = 3.0
if self.config.get('hyperopt_clean_state'):
if not self.config.get('hyperopt_continue'):
self.clean_hyperopt()
else:
logger.info("Continuing on previous hyperopt results.")
# Previous evaluations
self.trials_file = TRIALSDATA_PICKLE
self.trials: List = []
@ -99,6 +102,7 @@ class Hyperopt(Backtesting):
else:
logger.debug('Ignoring max_open_trades (--disable-max-market-positions was used) ...')
self.max_open_trades = 0
self.position_stacking = self.config.get('position_stacking', False),
def clean_hyperopt(self):
"""
@ -231,7 +235,7 @@ class Hyperopt(Backtesting):
'stake_amount': self.config['stake_amount'],
'processed': processed,
'max_open_trades': self.max_open_trades,
'position_stacking': self.config.get('position_stacking', False),
'position_stacking': self.position_stacking,
'start_date': min_date,
'end_date': max_date,
}

View File

@ -418,6 +418,7 @@ def test_start_calls_optimizer(mocker, default_conf, caplog) -> None:
assert hasattr(hyperopt, "advise_buy")
assert hasattr(hyperopt, "max_open_trades")
assert hyperopt.max_open_trades == default_conf['max_open_trades']
assert hasattr(hyperopt, "position_stacking")
def test_format_results(hyperopt):
@ -569,8 +570,24 @@ def test_clean_hyperopt(mocker, default_conf, caplog):
})
mocker.patch("freqtrade.optimize.hyperopt.Path.is_file", MagicMock(return_value=True))
unlinkmock = mocker.patch("freqtrade.optimize.hyperopt.Path.unlink", MagicMock())
hyp = Hyperopt(default_conf)
Hyperopt(default_conf)
hyp.clean_hyperopt()
assert unlinkmock.call_count == 2
assert log_has(f"Removing `{TICKERDATA_PICKLE}`.", caplog.record_tuples)
def test_continue_hyperopt(mocker, default_conf, caplog):
patch_exchange(mocker)
default_conf.update({'config': 'config.json.example',
'epochs': 1,
'timerange': None,
'spaces': 'all',
'hyperopt_jobs': 1,
'hyperopt_continue': True
})
mocker.patch("freqtrade.optimize.hyperopt.Path.is_file", MagicMock(return_value=True))
unlinkmock = mocker.patch("freqtrade.optimize.hyperopt.Path.unlink", MagicMock())
Hyperopt(default_conf)
assert unlinkmock.call_count == 0
assert log_has(f"Continuing on previous hyperopt results.", caplog.record_tuples)