Updated based on feedback:

- Profit commands now use float
- Compatible with --best
- Corrected wrong information in docs
This commit is contained in:
Fredrik Rydin
2020-02-10 20:54:31 +01:00
parent 5bf4c5869b
commit c924e4d519
3 changed files with 140 additions and 70 deletions

View File

@@ -401,14 +401,14 @@ AVAILABLE_CLI_OPTIONS = {
"hyperopt_list_min_avg_time": Arg(
'--min-avg-time',
help='Select epochs on above average time.',
type=check_int_nonzero,
metavar='INT',
type=float,
metavar='FLOAT',
),
"hyperopt_list_max_avg_time": Arg(
'--max-avg-time',
help='Select epochs on under average time.',
type=check_int_nonzero,
metavar='INT',
type=float,
metavar='FLOAT',
),
"hyperopt_list_min_avg_profit": Arg(
'--min-avg-profit',

View File

@@ -27,10 +27,10 @@ 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_avg_time': config.get('hyperopt_list_min_avg_time', 0),
'filter_max_avg_time': config.get('hyperopt_list_max_avg_time', 0),
'filter_min_avg_profit': config.get('hyperopt_list_min_avg_profit', 0.0),
'filter_min_total_profit': config.get('hyperopt_list_min_total_profit', 0.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)
}
trials_file = (config['user_data_dir'] /
@@ -74,10 +74,10 @@ 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_avg_time': config.get('hyperopt_list_min_avg_time', 0),
'filter_max_avg_time': config.get('hyperopt_list_max_avg_time', 0),
'filter_min_avg_profit': config.get('hyperopt_list_min_avg_profit', 0),
'filter_min_total_profit': config.get('hyperopt_list_min_total_profit', 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)
}
no_header = config.get('hyperopt_show_no_header', False)
@@ -119,33 +119,31 @@ 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 not filteroptions['only_best']:
if filteroptions['filter_min_avg_time'] > 0:
trials = [x for x in trials if x['results_metrics']['trade_count'] > 0]
trials = [
x for x in trials
if x['results_metrics']['duration'] > filteroptions['filter_min_avg_time']
]
if filteroptions['filter_max_avg_time'] > 0:
trials = [x for x in trials if x['results_metrics']['trade_count'] > 0]
trials = [
x for x in trials
if x['results_metrics']['duration'] < filteroptions['filter_max_avg_time']
]
if filteroptions['filter_min_avg_profit'] > 0:
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_min_avg_profit']
]
if filteroptions['filter_min_total_profit'] > 0:
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_min_avg_time'] 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']['duration'] > filteroptions['filter_min_avg_time']
]
if filteroptions['filter_max_avg_time'] 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']['duration'] < filteroptions['filter_max_avg_time']
]
if filteroptions['filter_min_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_min_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']
]
logger.info(f"{len(trials)} " +
("best " if filteroptions['only_best'] else "") +