initial push

This commit is contained in:
Yazeed Al Oyoun 2020-03-22 02:22:06 +01:00
parent fb4e9b3938
commit 1976aaf13e
6 changed files with 84 additions and 5 deletions

View File

@ -426,9 +426,9 @@ usage: freqtrade hyperopt-list [-h] [-v] [--logfile FILE] [-V] [-c PATH]
[--max-trades INT] [--min-avg-time FLOAT] [--max-trades INT] [--min-avg-time FLOAT]
[--max-avg-time FLOAT] [--min-avg-profit FLOAT] [--max-avg-time FLOAT] [--min-avg-profit FLOAT]
[--max-avg-profit FLOAT] [--max-avg-profit FLOAT]
[--min-total-profit FLOAT] [--min-total-profit FLOAT] [--max-total-profit FLOAT]
[--max-total-profit FLOAT] [--no-color] [--min-objective FLOAT] [--max-objective FLOAT]
[--print-json] [--no-details] [--no-color] [--print-json] [--no-details]
[--export-csv FILE] [--export-csv FILE]
optional arguments: optional arguments:
@ -447,6 +447,10 @@ optional arguments:
Select epochs on above total profit. Select epochs on above total profit.
--max-total-profit FLOAT --max-total-profit FLOAT
Select epochs on below total profit. Select epochs on below total profit.
--min-objective FLOAT
Select epochs on above objective (- is added by default).
--max-objective FLOAT
Select epochs on below objective (- is added by default).
--no-color Disable colorization of hyperopt results. May be --no-color Disable colorization of hyperopt results. May be
useful if you are redirecting output to a file. useful if you are redirecting output to a file.
--print-json Print best result detailization in JSON format. --print-json Print best result detailization in JSON format.

View File

@ -69,6 +69,7 @@ ARGS_HYPEROPT_LIST = ["hyperopt_list_best", "hyperopt_list_profitable",
"hyperopt_list_min_avg_time", "hyperopt_list_max_avg_time", "hyperopt_list_min_avg_time", "hyperopt_list_max_avg_time",
"hyperopt_list_min_avg_profit", "hyperopt_list_max_avg_profit", "hyperopt_list_min_avg_profit", "hyperopt_list_max_avg_profit",
"hyperopt_list_min_total_profit", "hyperopt_list_max_total_profit", "hyperopt_list_min_total_profit", "hyperopt_list_max_total_profit",
"hyperopt_list_min_objective", "hyperopt_list_max_objective",
"print_colorized", "print_json", "hyperopt_list_no_details", "print_colorized", "print_json", "hyperopt_list_no_details",
"export_csv"] "export_csv"]

View File

@ -484,6 +484,18 @@ AVAILABLE_CLI_OPTIONS = {
type=float, type=float,
metavar='FLOAT', metavar='FLOAT',
), ),
"hyperopt_list_min_objective": Arg(
'--min-objective',
help='Select epochs on above objective.',
type=float,
metavar='FLOAT',
),
"hyperopt_list_max_objective": Arg(
'--max-objective',
help='Select epochs on below objective.',
type=float,
metavar='FLOAT',
),
"hyperopt_list_no_details": Arg( "hyperopt_list_no_details": Arg(
'--no-details', '--no-details',
help='Do not print best epoch details.', help='Do not print best epoch details.',

View File

@ -35,9 +35,16 @@ def start_hyperopt_list(args: Dict[str, Any]) -> None:
'filter_min_avg_profit': config.get('hyperopt_list_min_avg_profit', None), 'filter_min_avg_profit': config.get('hyperopt_list_min_avg_profit', None),
'filter_max_avg_profit': config.get('hyperopt_list_max_avg_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_min_total_profit': config.get('hyperopt_list_min_total_profit', None),
'filter_max_total_profit': config.get('hyperopt_list_max_total_profit', None) 'filter_max_total_profit': config.get('hyperopt_list_max_total_profit', None),
'filter_min_objective': config.get('hyperopt_list_min_objective', None),
'filter_max_objective': config.get('hyperopt_list_max_objective', None)
} }
if filteroptions['filter_min_objective'] is not None:
filteroptions['filter_min_objective'] = -filteroptions['filter_min_objective']
if filteroptions['filter_max_objective'] is not None:
filteroptions['filter_max_objective'] = -filteroptions['filter_max_objective']
trials_file = (config['user_data_dir'] / trials_file = (config['user_data_dir'] /
'hyperopt_results' / 'hyperopt_results.pickle') 'hyperopt_results' / 'hyperopt_results.pickle')
@ -92,9 +99,16 @@ def start_hyperopt_show(args: Dict[str, Any]) -> None:
'filter_min_avg_profit': config.get('hyperopt_list_min_avg_profit', None), 'filter_min_avg_profit': config.get('hyperopt_list_min_avg_profit', None),
'filter_max_avg_profit': config.get('hyperopt_list_max_avg_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_min_total_profit': config.get('hyperopt_list_min_total_profit', None),
'filter_max_total_profit': config.get('hyperopt_list_max_total_profit', None) 'filter_max_total_profit': config.get('hyperopt_list_max_total_profit', None),
'filter_min_objective': config.get('hyperopt_list_min_objective', None),
'filter_max_objective': config.get('hyperopt_list_max_objective', None)
} }
if filteroptions['filter_min_objective'] is not None:
filteroptions['filter_min_objective'] = -filteroptions['filter_min_objective']
if filteroptions['filter_max_objective'] is not None:
filteroptions['filter_max_objective'] = -filteroptions['filter_max_objective']
# Previous evaluations # Previous evaluations
trials = Hyperopt.load_previous_results(trials_file) trials = Hyperopt.load_previous_results(trials_file)
total_epochs = len(trials) total_epochs = len(trials)
@ -175,6 +189,20 @@ def _hyperopt_filter_trials(trials: List, filteroptions: dict) -> List:
x for x in trials x for x in trials
if x['results_metrics']['profit'] < filteroptions['filter_max_total_profit'] if x['results_metrics']['profit'] < filteroptions['filter_max_total_profit']
] ]
if filteroptions['filter_min_objective'] is not None:
trials = [x for x in trials if x['results_metrics']['trade_count'] > 0]
# trials = [x for x in trials if x['loss'] != 20]
trials = [
x for x in trials
if x['loss'] < filteroptions['filter_min_objective']
]
if filteroptions['filter_max_objective'] is not None:
trials = [x for x in trials if x['results_metrics']['trade_count'] > 0]
# trials = [x for x in trials if x['loss'] != 20]
trials = [
x for x in trials
if x['loss'] > filteroptions['filter_max_objective']
]
logger.info(f"{len(trials)} " + logger.info(f"{len(trials)} " +
("best " if filteroptions['only_best'] else "") + ("best " if filteroptions['only_best'] else "") +

View File

@ -334,6 +334,12 @@ class Configuration:
self._args_to_config(config, argname='hyperopt_list_max_total_profit', self._args_to_config(config, argname='hyperopt_list_max_total_profit',
logstring='Parameter --max-total-profit detected: {}') logstring='Parameter --max-total-profit detected: {}')
self._args_to_config(config, argname='hyperopt_list_min_objective',
logstring='Parameter --min-objective detected: {}')
self._args_to_config(config, argname='hyperopt_list_max_objective',
logstring='Parameter --max-objective detected: {}')
self._args_to_config(config, argname='hyperopt_list_no_details', self._args_to_config(config, argname='hyperopt_list_no_details',
logstring='Parameter --no-details detected: {}') logstring='Parameter --no-details detected: {}')

View File

@ -868,6 +868,34 @@ def test_hyperopt_list(mocker, capsys, hyperopt_results):
pargs['config'] = None pargs['config'] = None
start_hyperopt_list(pargs) start_hyperopt_list(pargs)
captured = capsys.readouterr() captured = capsys.readouterr()
assert all(x in captured.out
for x in [" 1/12", " 2/12", " 3/12", " 5/12", " 6/12", " 7/12", " 8/12",
" 9/12", " 11/12"])
assert all(x not in captured.out
for x in [" 4/12", " 10/12", " 12/12"])
args = [
"hyperopt-list",
"--no-details",
"--min-objective", "0.1"
]
pargs = get_args(args)
pargs['config'] = None
start_hyperopt_list(pargs)
captured = capsys.readouterr()
assert all(x in captured.out
for x in [" 10/12"])
assert all(x not in captured.out
for x in [" 1/12", " 2/12", " 3/12", " 4/12", " 5/12", " 6/12", " 7/12", " 8/12",
" 9/12", " 11/12", " 12/12"])
args = [
"hyperopt-list",
"--no-details",
"--max-objective", "0.1"
]
pargs = get_args(args)
pargs['config'] = None
start_hyperopt_list(pargs)
captured = capsys.readouterr()
assert all(x in captured.out assert all(x in captured.out
for x in [" 1/12", " 2/12", " 3/12", " 5/12", " 6/12", " 7/12", " 8/12", for x in [" 1/12", " 2/12", " 3/12", " 5/12", " 6/12", " 7/12", " 8/12",
" 9/12", " 11/12"]) " 9/12", " 11/12"])