|
|
|
|
@ -27,10 +27,14 @@ def start_hyperopt_list(args: Dict[str, Any]) -> None:
|
|
|
|
|
filteroptions = {
|
|
|
|
|
'only_best': config.get('hyperopt_list_best', False),
|
|
|
|
|
'only_profitable': config.get('hyperopt_list_profitable', False),
|
|
|
|
|
'filter_min_trades': config.get('hyperopt_list_min_trades', 0),
|
|
|
|
|
'filter_max_trades': config.get('hyperopt_list_max_trades', 0),
|
|
|
|
|
'filter_min_avg_time': config.get('hyperopt_list_min_avg_time', None),
|
|
|
|
|
'filter_max_avg_time': config.get('hyperopt_list_max_avg_time', None),
|
|
|
|
|
'filter_min_avg_profit': config.get('hyperopt_list_min_avg_profit', None),
|
|
|
|
|
'filter_min_total_profit': config.get('hyperopt_list_min_total_profit', None)
|
|
|
|
|
'filter_max_avg_profit': config.get('hyperopt_list_max_avg_profit', None),
|
|
|
|
|
'filter_min_total_profit': config.get('hyperopt_list_min_total_profit', None),
|
|
|
|
|
'filter_max_total_profit': config.get('hyperopt_list_max_total_profit', None)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
trials_file = (config['user_data_dir'] /
|
|
|
|
|
@ -74,10 +78,14 @@ def start_hyperopt_show(args: Dict[str, Any]) -> None:
|
|
|
|
|
filteroptions = {
|
|
|
|
|
'only_best': config.get('hyperopt_list_best', False),
|
|
|
|
|
'only_profitable': config.get('hyperopt_list_profitable', False),
|
|
|
|
|
'filter_min_trades': config.get('hyperopt_list_min_trades', 0),
|
|
|
|
|
'filter_max_trades': config.get('hyperopt_list_max_trades', 0),
|
|
|
|
|
'filter_min_avg_time': config.get('hyperopt_list_min_avg_time', None),
|
|
|
|
|
'filter_max_avg_time': config.get('hyperopt_list_max_avg_time', None),
|
|
|
|
|
'filter_min_avg_profit': config.get('hyperopt_list_min_avg_profit', None),
|
|
|
|
|
'filter_min_total_profit': config.get('hyperopt_list_min_total_profit', None)
|
|
|
|
|
'filter_max_avg_profit': config.get('hyperopt_list_max_avg_profit', None),
|
|
|
|
|
'filter_min_total_profit': config.get('hyperopt_list_min_total_profit', None),
|
|
|
|
|
'filter_max_total_profit': config.get('hyperopt_list_max_total_profit', None)
|
|
|
|
|
}
|
|
|
|
|
no_header = config.get('hyperopt_show_no_header', False)
|
|
|
|
|
|
|
|
|
|
@ -119,6 +127,16 @@ def _hyperopt_filter_trials(trials: List, filteroptions: dict) -> List:
|
|
|
|
|
trials = [x for x in trials if x['is_best']]
|
|
|
|
|
if filteroptions['only_profitable']:
|
|
|
|
|
trials = [x for x in trials if x['results_metrics']['profit'] > 0]
|
|
|
|
|
if filteroptions['filter_min_trades'] > 0:
|
|
|
|
|
trials = [
|
|
|
|
|
x for x in trials
|
|
|
|
|
if x['results_metrics']['trade_count'] > filteroptions['filter_min_trades']
|
|
|
|
|
]
|
|
|
|
|
if filteroptions['filter_max_trades'] > 0:
|
|
|
|
|
trials = [
|
|
|
|
|
x for x in trials
|
|
|
|
|
if x['results_metrics']['trade_count'] < filteroptions['filter_max_trades']
|
|
|
|
|
]
|
|
|
|
|
if filteroptions['filter_min_avg_time'] is not None:
|
|
|
|
|
trials = [x for x in trials if x['results_metrics']['trade_count'] > 0]
|
|
|
|
|
trials = [
|
|
|
|
|
@ -138,12 +156,25 @@ def _hyperopt_filter_trials(trials: List, filteroptions: dict) -> List:
|
|
|
|
|
if x['results_metrics']['avg_profit']
|
|
|
|
|
> filteroptions['filter_min_avg_profit']
|
|
|
|
|
]
|
|
|
|
|
if filteroptions['filter_max_avg_profit'] is not None:
|
|
|
|
|
trials = [x for x in trials if x['results_metrics']['trade_count'] > 0]
|
|
|
|
|
trials = [
|
|
|
|
|
x for x in trials
|
|
|
|
|
if x['results_metrics']['avg_profit']
|
|
|
|
|
< filteroptions['filter_max_avg_profit']
|
|
|
|
|
]
|
|
|
|
|
if filteroptions['filter_min_total_profit'] is not None:
|
|
|
|
|
trials = [x for x in trials if x['results_metrics']['trade_count'] > 0]
|
|
|
|
|
trials = [
|
|
|
|
|
x for x in trials
|
|
|
|
|
if x['results_metrics']['profit'] > filteroptions['filter_min_total_profit']
|
|
|
|
|
]
|
|
|
|
|
if filteroptions['filter_max_total_profit'] is not None:
|
|
|
|
|
trials = [x for x in trials if x['results_metrics']['trade_count'] > 0]
|
|
|
|
|
trials = [
|
|
|
|
|
x for x in trials
|
|
|
|
|
if x['results_metrics']['profit'] < filteroptions['filter_max_total_profit']
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
logger.info(f"{len(trials)} " +
|
|
|
|
|
("best " if filteroptions['only_best'] else "") +
|
|
|
|
|
|