mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
initial push
This commit is contained in:
parent
fb4e9b3938
commit
1976aaf13e
|
@ -426,9 +426,9 @@ usage: freqtrade hyperopt-list [-h] [-v] [--logfile FILE] [-V] [-c PATH]
|
|||
[--max-trades INT] [--min-avg-time FLOAT]
|
||||
[--max-avg-time FLOAT] [--min-avg-profit FLOAT]
|
||||
[--max-avg-profit FLOAT]
|
||||
[--min-total-profit FLOAT]
|
||||
[--max-total-profit FLOAT] [--no-color]
|
||||
[--print-json] [--no-details]
|
||||
[--min-total-profit FLOAT] [--max-total-profit FLOAT]
|
||||
[--min-objective FLOAT] [--max-objective FLOAT]
|
||||
[--no-color] [--print-json] [--no-details]
|
||||
[--export-csv FILE]
|
||||
|
||||
optional arguments:
|
||||
|
@ -447,6 +447,10 @@ optional arguments:
|
|||
Select epochs on above total profit.
|
||||
--max-total-profit FLOAT
|
||||
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
|
||||
useful if you are redirecting output to a file.
|
||||
--print-json Print best result detailization in JSON format.
|
||||
|
|
|
@ -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_profit", "hyperopt_list_max_avg_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",
|
||||
"export_csv"]
|
||||
|
||||
|
|
|
@ -484,6 +484,18 @@ AVAILABLE_CLI_OPTIONS = {
|
|||
type=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(
|
||||
'--no-details',
|
||||
help='Do not print best epoch details.',
|
||||
|
|
|
@ -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_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)
|
||||
'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'] /
|
||||
'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_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)
|
||||
'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
|
||||
trials = Hyperopt.load_previous_results(trials_file)
|
||||
total_epochs = len(trials)
|
||||
|
@ -175,6 +189,20 @@ def _hyperopt_filter_trials(trials: List, filteroptions: dict) -> List:
|
|||
x for x in trials
|
||||
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)} " +
|
||||
("best " if filteroptions['only_best'] else "") +
|
||||
|
|
|
@ -334,6 +334,12 @@ class Configuration:
|
|||
self._args_to_config(config, argname='hyperopt_list_max_total_profit',
|
||||
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',
|
||||
logstring='Parameter --no-details detected: {}')
|
||||
|
||||
|
|
|
@ -868,6 +868,34 @@ def test_hyperopt_list(mocker, capsys, hyperopt_results):
|
|||
pargs['config'] = None
|
||||
start_hyperopt_list(pargs)
|
||||
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
|
||||
for x in [" 1/12", " 2/12", " 3/12", " 5/12", " 6/12", " 7/12", " 8/12",
|
||||
" 9/12", " 11/12"])
|
||||
|
|
Loading…
Reference in New Issue
Block a user