From 636bd5acb5e8b66dab60879c50343a26dc8e15c6 Mon Sep 17 00:00:00 2001 From: Fredrik Rydin Date: Sat, 8 Feb 2020 23:21:42 +0100 Subject: [PATCH 1/7] Added filter options to "hyperopt-list" in order to easier find epochs. --profitable Select only profitable epochs. --min-avg-time INT Select epochs on above average time. --max-avg-time INT Select epochs on under average time. --min-avg-profit FLOAT Select epochs on above average profit. --min-total-profit FLOAT Select epochs on above total profit. --- docs/utils.md | 24 +++++++++--- freqtrade/commands/arguments.py | 3 +- freqtrade/commands/cli_options.py | 24 ++++++++++++ freqtrade/commands/hyperopt_commands.py | 47 ++++++++++++++++++------ freqtrade/configuration/configuration.py | 12 ++++++ 5 files changed, 91 insertions(+), 19 deletions(-) diff --git a/docs/utils.md b/docs/utils.md index b0559f9cc..71039f174 100644 --- a/docs/utils.md +++ b/docs/utils.md @@ -135,15 +135,27 @@ Common arguments: ``` ``` freqtrade list-hyperopts --help -usage: freqtrade list-hyperopts [-h] [-v] [--logfile FILE] [-V] [-c PATH] - [-d PATH] [--userdir PATH] - [--hyperopt-path PATH] [-1] +usage: freqtrade hyperopt-list [-h] [-v] [--logfile FILE] [-V] [-c PATH] + [-d PATH] [--userdir PATH] [--best] + [--profitable] [--min-avg-time INT] + [--max-avg-time INT] [--min-avg-profit FLOAT] + [--min-total-profit FLOAT] [--no-color] + [--print-json] [--no-details] optional arguments: -h, --help show this help message and exit - --hyperopt-path PATH Specify additional lookup path for Hyperopt and - Hyperopt Loss functions. - -1, --one-column Print output in one column. + --best Select only best epochs. + --profitable Select only profitable epochs. + --min-avg-time INT Select epochs on above average time. + --max-avg-time INT Select epochs on under average time. + --min-avg-profit FLOAT + Select epochs on above average profit. + --min-total-profit FLOAT + Select epochs on above total profit. + --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. + --no-details Do not print best epoch details. Common arguments: -v, --verbose Verbose mode (-vv for more, -vvv to get all messages). diff --git a/freqtrade/commands/arguments.py b/freqtrade/commands/arguments.py index 1931a51be..2d02058f1 100644 --- a/freqtrade/commands/arguments.py +++ b/freqtrade/commands/arguments.py @@ -59,7 +59,8 @@ ARGS_PLOT_DATAFRAME = ["pairs", "indicators1", "indicators2", "plot_limit", ARGS_PLOT_PROFIT = ["pairs", "timerange", "export", "exportfilename", "db_url", "trade_source", "ticker_interval"] -ARGS_HYPEROPT_LIST = ["hyperopt_list_best", "hyperopt_list_profitable", "print_colorized", +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_min_total_profit", "print_colorized", "print_json", "hyperopt_list_no_details"] ARGS_HYPEROPT_SHOW = ["hyperopt_list_best", "hyperopt_list_profitable", "hyperopt_show_index", diff --git a/freqtrade/commands/cli_options.py b/freqtrade/commands/cli_options.py index 6d8d13129..0c6d64691 100644 --- a/freqtrade/commands/cli_options.py +++ b/freqtrade/commands/cli_options.py @@ -398,6 +398,30 @@ AVAILABLE_CLI_OPTIONS = { help='Select only best epochs.', action='store_true', ), + "hyperopt_list_min_avg_time": Arg( + '--min-avg-time', + help='Select epochs on above average time.', + type=check_int_nonzero, + metavar='INT', + ), + "hyperopt_list_max_avg_time": Arg( + '--max-avg-time', + help='Select epochs on under average time.', + type=check_int_nonzero, + metavar='INT', + ), + "hyperopt_list_min_avg_profit": Arg( + '--min-avg-profit', + help='Select epochs on above average profit.', + type=float, + metavar='FLOAT', + ), + "hyperopt_list_min_total_profit": Arg( + '--min-total-profit', + help='Select epochs on above total profit.', + type=float, + metavar='FLOAT', + ), "hyperopt_list_no_details": Arg( '--no-details', help='Do not print best epoch details.', diff --git a/freqtrade/commands/hyperopt_commands.py b/freqtrade/commands/hyperopt_commands.py index 5c6f25848..8472fcfe1 100644 --- a/freqtrade/commands/hyperopt_commands.py +++ b/freqtrade/commands/hyperopt_commands.py @@ -19,13 +19,20 @@ def start_hyperopt_list(args: Dict[str, Any]) -> None: config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE) - only_best = config.get('hyperopt_list_best', False) - only_profitable = config.get('hyperopt_list_profitable', False) print_colorized = config.get('print_colorized', False) print_json = config.get('print_json', False) no_details = config.get('hyperopt_list_no_details', False) no_header = False + 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) + } + trials_file = (config['user_data_dir'] / 'hyperopt_results' / 'hyperopt_results.pickle') @@ -33,7 +40,7 @@ def start_hyperopt_list(args: Dict[str, Any]) -> None: trials = Hyperopt.load_previous_results(trials_file) total_epochs = len(trials) - trials = _hyperopt_filter_trials(trials, only_best, only_profitable) + trials = _hyperopt_filter_trials(trials, filteroptions) # TODO: fetch the interval for epochs to print from the cli option epoch_start, epoch_stop = 0, None @@ -44,7 +51,7 @@ def start_hyperopt_list(args: Dict[str, Any]) -> None: try: # Human-friendly indexes used here (starting from 1) for val in trials[epoch_start:epoch_stop]: - Hyperopt.print_results_explanation(val, total_epochs, not only_best, print_colorized) + Hyperopt.print_results_explanation(val, total_epochs, not filteroptions['only_best'], print_colorized) except KeyboardInterrupt: print('User interrupted..') @@ -63,8 +70,14 @@ def start_hyperopt_show(args: Dict[str, Any]) -> None: config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE) - only_best = config.get('hyperopt_list_best', False) - only_profitable = config.get('hyperopt_list_profitable', False) + 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) + } no_header = config.get('hyperopt_show_no_header', False) trials_file = (config['user_data_dir'] / @@ -74,7 +87,7 @@ def start_hyperopt_show(args: Dict[str, Any]) -> None: trials = Hyperopt.load_previous_results(trials_file) total_epochs = len(trials) - trials = _hyperopt_filter_trials(trials, only_best, only_profitable) + trials = _hyperopt_filter_trials(trials, filteroptions) trials_epochs = len(trials) n = config.get('hyperopt_show_index', -1) @@ -97,18 +110,28 @@ def start_hyperopt_show(args: Dict[str, Any]) -> None: header_str="Epoch details") -def _hyperopt_filter_trials(trials: List, only_best: bool, only_profitable: bool) -> List: +def _hyperopt_filter_trials(trials: List, filteroptions: dict) -> List: """ Filter our items from the list of hyperopt results """ - if only_best: + if filteroptions['only_best']: trials = [x for x in trials if x['is_best']] - if only_profitable: + 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']['duration'] > filteroptions['filter_min_avg_time']] + if filteroptions['filter_max_avg_time'] > 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']['avg_profit'] > filteroptions['filter_min_avg_profit']] + if filteroptions['filter_min_total_profit'] > 0: + trials = [x for x in trials if x['results_metrics']['profit'] > filteroptions['filter_min_total_profit']] + logger.info(f"{len(trials)} " + - ("best " if only_best else "") + - ("profitable " if only_profitable else "") + + ("best " if filteroptions['only_best'] else "") + + ("profitable " if filteroptions['only_profitable'] else "") + "epochs found.") return trials diff --git a/freqtrade/configuration/configuration.py b/freqtrade/configuration/configuration.py index a8b7638c8..f7e87f3a1 100644 --- a/freqtrade/configuration/configuration.py +++ b/freqtrade/configuration/configuration.py @@ -310,6 +310,18 @@ class Configuration: self._args_to_config(config, argname='hyperopt_list_profitable', logstring='Parameter --profitable detected: {}') + self._args_to_config(config, argname='hyperopt_list_min_avg_time', + logstring='Parameter --min-avg-time detected: {}') + + self._args_to_config(config, argname='hyperopt_list_max_avg_time', + logstring='Parameter --max-avg-time detected: {}') + + self._args_to_config(config, argname='hyperopt_list_min_avg_profit', + logstring='Parameter --min-avg-profit detected: {}') + + self._args_to_config(config, argname='hyperopt_list_min_total_profit', + logstring='Parameter --min-total-profit detected: {}') + self._args_to_config(config, argname='hyperopt_list_no_details', logstring='Parameter --no-details detected: {}') From c96acd6ca02b6e0dc5cd1e28c78ad0b3be648fe1 Mon Sep 17 00:00:00 2001 From: Fredrik Rydin Date: Sun, 9 Feb 2020 00:16:11 +0100 Subject: [PATCH 2/7] Fixed to pass PEP8 --- freqtrade/commands/arguments.py | 7 ++++--- freqtrade/commands/hyperopt_commands.py | 28 ++++++++++++++++++------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/freqtrade/commands/arguments.py b/freqtrade/commands/arguments.py index 2d02058f1..6d0c16d88 100644 --- a/freqtrade/commands/arguments.py +++ b/freqtrade/commands/arguments.py @@ -59,9 +59,10 @@ ARGS_PLOT_DATAFRAME = ["pairs", "indicators1", "indicators2", "plot_limit", ARGS_PLOT_PROFIT = ["pairs", "timerange", "export", "exportfilename", "db_url", "trade_source", "ticker_interval"] -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_min_total_profit", "print_colorized", - "print_json", "hyperopt_list_no_details"] +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_min_total_profit", + "print_colorized", "print_json", "hyperopt_list_no_details"] ARGS_HYPEROPT_SHOW = ["hyperopt_list_best", "hyperopt_list_profitable", "hyperopt_show_index", "print_json", "hyperopt_show_no_header"] diff --git a/freqtrade/commands/hyperopt_commands.py b/freqtrade/commands/hyperopt_commands.py index 8472fcfe1..f5fcc971f 100644 --- a/freqtrade/commands/hyperopt_commands.py +++ b/freqtrade/commands/hyperopt_commands.py @@ -32,7 +32,7 @@ def start_hyperopt_list(args: Dict[str, Any]) -> None: '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) } - + trials_file = (config['user_data_dir'] / 'hyperopt_results' / 'hyperopt_results.pickle') @@ -51,7 +51,8 @@ def start_hyperopt_list(args: Dict[str, Any]) -> None: try: # Human-friendly indexes used here (starting from 1) for val in trials[epoch_start:epoch_stop]: - Hyperopt.print_results_explanation(val, total_epochs, not filteroptions['only_best'], print_colorized) + Hyperopt.print_results_explanation(val, total_epochs, + not filteroptions['only_best'], print_colorized) except KeyboardInterrupt: print('User interrupted..') @@ -121,14 +122,27 @@ def _hyperopt_filter_trials(trials: List, filteroptions: dict) -> List: if not filteroptions['only_best']: if filteroptions['filter_min_avg_time'] > 0: - trials = [x for x in trials if x['results_metrics']['duration'] > filteroptions['filter_min_avg_time']] + 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']['duration'] < filteroptions['filter_max_avg_time']] + 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']['avg_profit'] > filteroptions['filter_min_avg_profit']] + 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']['profit'] > filteroptions['filter_min_total_profit']] - + 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 "") + ("profitable " if filteroptions['only_profitable'] else "") + From c648ec7c0c76e09d57bee0e52bf820bb0d9adf01 Mon Sep 17 00:00:00 2001 From: Fredrik Rydin Date: Sun, 9 Feb 2020 14:18:56 +0100 Subject: [PATCH 3/7] Added test cases and fixed a minor bug --- freqtrade/commands/hyperopt_commands.py | 6 +++ tests/commands/test_commands.py | 59 ++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/freqtrade/commands/hyperopt_commands.py b/freqtrade/commands/hyperopt_commands.py index f5fcc971f..38e1fa429 100644 --- a/freqtrade/commands/hyperopt_commands.py +++ b/freqtrade/commands/hyperopt_commands.py @@ -120,24 +120,30 @@ def _hyperopt_filter_trials(trials: List, filteroptions: dict) -> List: if filteroptions['only_profitable']: trials = [x for x in trials if x['results_metrics']['profit'] > 0] + print(trials[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'] diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index c59799190..fb15c3d7f 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -778,7 +778,64 @@ def test_hyperopt_list(mocker, capsys, hyperopt_results): assert all(x not in captured.out for x in [" 1/12", " 3/12", " 4/12", " 5/12", " 6/12", " 7/12", " 8/12", " 9/12", " 11/12", " 12/12"]) - + args = [ + "hyperopt-list", + "--profitable", + "--no-details", + "--min-avg-profit", "0.11" + ] + pargs = get_args(args) + pargs['config'] = None + start_hyperopt_list(pargs) + captured = capsys.readouterr() + assert all(x in captured.out + for x in [" 2/12"]) + assert all(x not in captured.out + for x in [" 1/12", " 3/12", " 4/12", " 5/12", " 6/12", " 7/12", " 8/12", " 9/12", + " 10/12", " 11/12", " 12/12"]) + args = [ + "hyperopt-list", + "--no-details", + "--min-total-profit", "0.4" + ] + 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", + "--profitable", + "--no-details", + "--min-avg-time", "2000" + ] + 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-avg-time", "1500" + ] + pargs = get_args(args) + pargs['config'] = None + start_hyperopt_list(pargs) + captured = capsys.readouterr() + assert all(x in captured.out + for x in [" 2/12", " 6/12"]) + assert all(x not in captured.out + for x in [" 1/12", " 3/12", " 4/12", " 5/12", " 7/12", " 8/12" + " 9/12", " 10/12", " 11/12", " 12/12"]) def test_hyperopt_show(mocker, capsys, hyperopt_results): mocker.patch( From eb3783dc0095740ccf973cbec351a67951cfcda5 Mon Sep 17 00:00:00 2001 From: Fredrik Rydin Date: Sun, 9 Feb 2020 14:30:29 +0100 Subject: [PATCH 4/7] Fixed a blank line issue :-( --- tests/commands/test_commands.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index fb15c3d7f..db8a9289a 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -837,6 +837,7 @@ def test_hyperopt_list(mocker, capsys, hyperopt_results): for x in [" 1/12", " 3/12", " 4/12", " 5/12", " 7/12", " 8/12" " 9/12", " 10/12", " 11/12", " 12/12"]) + def test_hyperopt_show(mocker, capsys, hyperopt_results): mocker.patch( 'freqtrade.optimize.hyperopt.Hyperopt.load_previous_results', From 5bf4c5869b81c39176efc7fe6705cebb02a7f489 Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Sun, 9 Feb 2020 19:32:09 +0100 Subject: [PATCH 5/7] Update hyperopt_commands.py Missed a debug print --- freqtrade/commands/hyperopt_commands.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/freqtrade/commands/hyperopt_commands.py b/freqtrade/commands/hyperopt_commands.py index 38e1fa429..cdfdb5ca6 100644 --- a/freqtrade/commands/hyperopt_commands.py +++ b/freqtrade/commands/hyperopt_commands.py @@ -120,8 +120,6 @@ def _hyperopt_filter_trials(trials: List, filteroptions: dict) -> List: if filteroptions['only_profitable']: trials = [x for x in trials if x['results_metrics']['profit'] > 0] - print(trials[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] From c924e4d519253a400218d95b7f17a64da27e5da6 Mon Sep 17 00:00:00 2001 From: Fredrik Rydin Date: Mon, 10 Feb 2020 20:54:31 +0100 Subject: [PATCH 6/7] Updated based on feedback: - Profit commands now use float - Compatible with --best - Corrected wrong information in docs --- docs/utils.md | 134 ++++++++++++++++++------ freqtrade/commands/cli_options.py | 8 +- freqtrade/commands/hyperopt_commands.py | 68 ++++++------ 3 files changed, 140 insertions(+), 70 deletions(-) diff --git a/docs/utils.md b/docs/utils.md index 71039f174..5bb3a0e53 100644 --- a/docs/utils.md +++ b/docs/utils.md @@ -36,6 +36,38 @@ optional arguments: └── sample_strategy.py ``` +## Create new config + +Creates a new configuration file, asking some questions which are important selections for a configuration. + +``` +usage: freqtrade new-config [-h] [-c PATH] + +optional arguments: + -h, --help show this help message and exit + -c PATH, --config PATH + Specify configuration file (default: `config.json`). Multiple --config options may be used. Can be set to `-` + to read config from stdin. +``` + +!!! Warning + Only vital questions are asked. Freqtrade offers a lot more configuration possibilities, which are listed in the [Configuration documentation](configuration.md#configuration-parameters) + +### Create config examples + +``` +$ freqtrade new-config --config config_binance.json + +? Do you want to enable Dry-run (simulated trades)? Yes +? Please insert your stake currency: BTC +? Please insert your stake amount: 0.05 +? Please insert max_open_trades (Integer or 'unlimited'): 5 +? Please insert your ticker interval: 15m +? Please insert your display Currency (for reporting): USD +? Select exchange binance +? Do you want to enable Telegram? No +``` + ## Create new strategy Creates a new strategy from a template similar to SampleStrategy. @@ -135,27 +167,15 @@ Common arguments: ``` ``` freqtrade list-hyperopts --help -usage: freqtrade hyperopt-list [-h] [-v] [--logfile FILE] [-V] [-c PATH] - [-d PATH] [--userdir PATH] [--best] - [--profitable] [--min-avg-time INT] - [--max-avg-time INT] [--min-avg-profit FLOAT] - [--min-total-profit FLOAT] [--no-color] - [--print-json] [--no-details] +usage: freqtrade list-hyperopts [-h] [-v] [--logfile FILE] [-V] [-c PATH] + [-d PATH] [--userdir PATH] + [--hyperopt-path PATH] [-1] optional arguments: -h, --help show this help message and exit - --best Select only best epochs. - --profitable Select only profitable epochs. - --min-avg-time INT Select epochs on above average time. - --max-avg-time INT Select epochs on under average time. - --min-avg-profit FLOAT - Select epochs on above average profit. - --min-total-profit FLOAT - Select epochs on above total profit. - --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. - --no-details Do not print best epoch details. + --hyperopt-path PATH Specify additional lookup path for Hyperopt and + Hyperopt Loss functions. + -1, --one-column Print output in one column. Common arguments: -v, --verbose Verbose mode (-vv for more, -vvv to get all messages). @@ -232,20 +252,31 @@ All exchanges supported by the ccxt library: _1btcxe, acx, adara, allcoin, anxpr Use the `list-timeframes` subcommand to see the list of ticker intervals (timeframes) available for the exchange. ``` -usage: freqtrade list-timeframes [-h] [--exchange EXCHANGE] [-1] +usage: freqtrade list-timeframes [-h] [-v] [--logfile FILE] [-V] [-c PATH] [-d PATH] [--userdir PATH] [--exchange EXCHANGE] [-1] optional arguments: - -h, --help show this help message and exit - --exchange EXCHANGE Exchange name (default: `bittrex`). Only valid if no - config is provided. - -1, --one-column Print output in one column. + -h, --help show this help message and exit + --exchange EXCHANGE Exchange name (default: `bittrex`). Only valid if no config is provided. + -1, --one-column Print output in one column. + +Common arguments: + -v, --verbose Verbose mode (-vv for more, -vvv to get all messages). + --logfile FILE Log to the file specified. Special values are: 'syslog', 'journald'. See the documentation for more details. + -V, --version show program's version number and exit + -c PATH, --config PATH + Specify configuration file (default: `config.json`). Multiple --config options may be used. Can be set to `-` + to read config from stdin. + -d PATH, --datadir PATH + Path to directory with historical backtesting data. + --userdir PATH, --user-data-dir PATH + Path to userdata directory. ``` * Example: see the timeframes for the 'binance' exchange, set in the configuration file: ``` -$ freqtrade -c config_binance.json list-timeframes +$ freqtrade list-timeframes -c config_binance.json ... Timeframes available for the exchange `binance`: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M ``` @@ -269,14 +300,16 @@ You can print info about any pair/market with these subcommands - and you can fi These subcommands have same usage and same set of available options: ``` -usage: freqtrade list-markets [-h] [--exchange EXCHANGE] [--print-list] - [--print-json] [-1] [--print-csv] +usage: freqtrade list-markets [-h] [-v] [--logfile FILE] [-V] [-c PATH] + [-d PATH] [--userdir PATH] [--exchange EXCHANGE] + [--print-list] [--print-json] [-1] [--print-csv] [--base BASE_CURRENCY [BASE_CURRENCY ...]] [--quote QUOTE_CURRENCY [QUOTE_CURRENCY ...]] [-a] -usage: freqtrade list-pairs [-h] [--exchange EXCHANGE] [--print-list] - [--print-json] [-1] [--print-csv] +usage: freqtrade list-pairs [-h] [-v] [--logfile FILE] [-V] [-c PATH] + [-d PATH] [--userdir PATH] [--exchange EXCHANGE] + [--print-list] [--print-json] [-1] [--print-csv] [--base BASE_CURRENCY [BASE_CURRENCY ...]] [--quote QUOTE_CURRENCY [QUOTE_CURRENCY ...]] [-a] @@ -295,6 +328,22 @@ optional arguments: Specify quote currency(-ies). Space-separated list. -a, --all Print all pairs or market symbols. By default only active ones are shown. + +Common arguments: + -v, --verbose Verbose mode (-vv for more, -vvv to get all messages). + --logfile FILE Log to the file specified. Special values are: + 'syslog', 'journald'. See the documentation for more + details. + -V, --version show program's version number and exit + -c PATH, --config PATH + Specify configuration file (default: `config.json`). + Multiple --config options may be used. Can be set to + `-` to read config from stdin. + -d PATH, --datadir PATH + Path to directory with historical backtesting data. + --userdir PATH, --user-data-dir PATH + Path to userdata directory. + ``` By default, only active pairs/markets are shown. Active pairs/markets are those that can currently be traded @@ -316,7 +365,7 @@ $ freqtrade list-pairs --quote USD --print-json human-readable list with summary: ``` -$ freqtrade -c config_binance.json list-pairs --all --base BTC ETH --quote USDT USD --print-list +$ freqtrade list-pairs -c config_binance.json --all --base BTC ETH --quote USDT USD --print-list ``` * Print all markets on exchange "Kraken", in the tabular format: @@ -364,17 +413,40 @@ You can list the hyperoptimization epochs the Hyperopt module evaluated previous ``` usage: freqtrade hyperopt-list [-h] [-v] [--logfile FILE] [-V] [-c PATH] [-d PATH] [--userdir PATH] [--best] - [--profitable] [--no-color] [--print-json] - [--no-details] + [--profitable] [--min-avg-time FLOAT] + [--max-avg-time FLOAT] [--min-avg-profit FLOAT] + [--min-total-profit FLOAT] [--no-color] + [--print-json] [--no-details] optional arguments: -h, --help show this help message and exit --best Select only best epochs. --profitable Select only profitable epochs. + --min-avg-time FLOAT Select epochs on above average time. + --max-avg-time FLOAT Select epochs on under average time. + --min-avg-profit FLOAT + Select epochs on above average profit. + --min-total-profit FLOAT + Select epochs on above total profit. --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. --no-details Do not print best epoch details. + +Common arguments: + -v, --verbose Verbose mode (-vv for more, -vvv to get all messages). + --logfile FILE Log to the file specified. Special values are: + 'syslog', 'journald'. See the documentation for more + details. + -V, --version show program's version number and exit + -c PATH, --config PATH + Specify configuration file (default: `config.json`). + Multiple --config options may be used. Can be set to + `-` to read config from stdin. + -d PATH, --datadir PATH + Path to directory with historical backtesting data. + --userdir PATH, --user-data-dir PATH + Path to userdata directory. ``` ### Examples diff --git a/freqtrade/commands/cli_options.py b/freqtrade/commands/cli_options.py index 0c6d64691..154404821 100644 --- a/freqtrade/commands/cli_options.py +++ b/freqtrade/commands/cli_options.py @@ -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', diff --git a/freqtrade/commands/hyperopt_commands.py b/freqtrade/commands/hyperopt_commands.py index cdfdb5ca6..ed0728bf6 100644 --- a/freqtrade/commands/hyperopt_commands.py +++ b/freqtrade/commands/hyperopt_commands.py @@ -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 "") + From f2520c11e70c3f0717bdd842f7b7cdeb5482ab0a Mon Sep 17 00:00:00 2001 From: Fredrik Rydin Date: Mon, 10 Feb 2020 21:19:25 +0100 Subject: [PATCH 7/7] Used wrong utils.md as base --- docs/utils.md | 83 +++++++-------------------------------------------- 1 file changed, 11 insertions(+), 72 deletions(-) diff --git a/docs/utils.md b/docs/utils.md index 5bb3a0e53..4bb2fdafb 100644 --- a/docs/utils.md +++ b/docs/utils.md @@ -36,38 +36,6 @@ optional arguments: └── sample_strategy.py ``` -## Create new config - -Creates a new configuration file, asking some questions which are important selections for a configuration. - -``` -usage: freqtrade new-config [-h] [-c PATH] - -optional arguments: - -h, --help show this help message and exit - -c PATH, --config PATH - Specify configuration file (default: `config.json`). Multiple --config options may be used. Can be set to `-` - to read config from stdin. -``` - -!!! Warning - Only vital questions are asked. Freqtrade offers a lot more configuration possibilities, which are listed in the [Configuration documentation](configuration.md#configuration-parameters) - -### Create config examples - -``` -$ freqtrade new-config --config config_binance.json - -? Do you want to enable Dry-run (simulated trades)? Yes -? Please insert your stake currency: BTC -? Please insert your stake amount: 0.05 -? Please insert max_open_trades (Integer or 'unlimited'): 5 -? Please insert your ticker interval: 15m -? Please insert your display Currency (for reporting): USD -? Select exchange binance -? Do you want to enable Telegram? No -``` - ## Create new strategy Creates a new strategy from a template similar to SampleStrategy. @@ -252,31 +220,20 @@ All exchanges supported by the ccxt library: _1btcxe, acx, adara, allcoin, anxpr Use the `list-timeframes` subcommand to see the list of ticker intervals (timeframes) available for the exchange. ``` -usage: freqtrade list-timeframes [-h] [-v] [--logfile FILE] [-V] [-c PATH] [-d PATH] [--userdir PATH] [--exchange EXCHANGE] [-1] +usage: freqtrade list-timeframes [-h] [--exchange EXCHANGE] [-1] optional arguments: - -h, --help show this help message and exit - --exchange EXCHANGE Exchange name (default: `bittrex`). Only valid if no config is provided. - -1, --one-column Print output in one column. - -Common arguments: - -v, --verbose Verbose mode (-vv for more, -vvv to get all messages). - --logfile FILE Log to the file specified. Special values are: 'syslog', 'journald'. See the documentation for more details. - -V, --version show program's version number and exit - -c PATH, --config PATH - Specify configuration file (default: `config.json`). Multiple --config options may be used. Can be set to `-` - to read config from stdin. - -d PATH, --datadir PATH - Path to directory with historical backtesting data. - --userdir PATH, --user-data-dir PATH - Path to userdata directory. + -h, --help show this help message and exit + --exchange EXCHANGE Exchange name (default: `bittrex`). Only valid if no + config is provided. + -1, --one-column Print output in one column. ``` * Example: see the timeframes for the 'binance' exchange, set in the configuration file: ``` -$ freqtrade list-timeframes -c config_binance.json +$ freqtrade -c config_binance.json list-timeframes ... Timeframes available for the exchange `binance`: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M ``` @@ -300,16 +257,14 @@ You can print info about any pair/market with these subcommands - and you can fi These subcommands have same usage and same set of available options: ``` -usage: freqtrade list-markets [-h] [-v] [--logfile FILE] [-V] [-c PATH] - [-d PATH] [--userdir PATH] [--exchange EXCHANGE] - [--print-list] [--print-json] [-1] [--print-csv] +usage: freqtrade list-markets [-h] [--exchange EXCHANGE] [--print-list] + [--print-json] [-1] [--print-csv] [--base BASE_CURRENCY [BASE_CURRENCY ...]] [--quote QUOTE_CURRENCY [QUOTE_CURRENCY ...]] [-a] -usage: freqtrade list-pairs [-h] [-v] [--logfile FILE] [-V] [-c PATH] - [-d PATH] [--userdir PATH] [--exchange EXCHANGE] - [--print-list] [--print-json] [-1] [--print-csv] +usage: freqtrade list-pairs [-h] [--exchange EXCHANGE] [--print-list] + [--print-json] [-1] [--print-csv] [--base BASE_CURRENCY [BASE_CURRENCY ...]] [--quote QUOTE_CURRENCY [QUOTE_CURRENCY ...]] [-a] @@ -328,22 +283,6 @@ optional arguments: Specify quote currency(-ies). Space-separated list. -a, --all Print all pairs or market symbols. By default only active ones are shown. - -Common arguments: - -v, --verbose Verbose mode (-vv for more, -vvv to get all messages). - --logfile FILE Log to the file specified. Special values are: - 'syslog', 'journald'. See the documentation for more - details. - -V, --version show program's version number and exit - -c PATH, --config PATH - Specify configuration file (default: `config.json`). - Multiple --config options may be used. Can be set to - `-` to read config from stdin. - -d PATH, --datadir PATH - Path to directory with historical backtesting data. - --userdir PATH, --user-data-dir PATH - Path to userdata directory. - ``` By default, only active pairs/markets are shown. Active pairs/markets are those that can currently be traded @@ -365,7 +304,7 @@ $ freqtrade list-pairs --quote USD --print-json human-readable list with summary: ``` -$ freqtrade list-pairs -c config_binance.json --all --base BTC ETH --quote USDT USD --print-list +$ freqtrade -c config_binance.json list-pairs --all --base BTC ETH --quote USDT USD --print-list ``` * Print all markets on exchange "Kraken", in the tabular format: