From a3e045f69d028cb2ad9a26b6bce14343f321ec0d Mon Sep 17 00:00:00 2001 From: Joe Schr Date: Tue, 1 Feb 2022 19:31:38 +0100 Subject: [PATCH] Plotting: add alias `--backtest-filename` for `--export-filename` makes it easier to discover how to use this argument --- docs/plotting.md | 4 ++-- freqtrade/commands/arguments.py | 2 +- freqtrade/commands/cli_options.py | 16 +++++++++++----- freqtrade/configuration/configuration.py | 9 +++++++++ freqtrade/plot/plotting.py | 6 +++++- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/docs/plotting.md b/docs/plotting.md index a812f2429..ccfbb12cb 100644 --- a/docs/plotting.md +++ b/docs/plotting.md @@ -318,8 +318,8 @@ optional arguments: Specify what timerange of data to use. --export EXPORT Export backtest results, argument are: trades. Example: `--export=trades` - --export-filename PATH - Save backtest results to the file with this filename. + --export-filename PATH, --backtest-filename PATH + Use backtest results from this filename. Requires `--export` to be set as well. Example: `--export-filename=user_data/backtest_results/backtest _today.json` diff --git a/freqtrade/commands/arguments.py b/freqtrade/commands/arguments.py index 290865a04..26648ea6f 100644 --- a/freqtrade/commands/arguments.py +++ b/freqtrade/commands/arguments.py @@ -74,7 +74,7 @@ ARGS_PLOT_DATAFRAME = ["pairs", "indicators1", "indicators2", "plot_limit", "db_url", "trade_source", "export", "exportfilename", "timerange", "timeframe", "no_trades"] -ARGS_PLOT_PROFIT = ["pairs", "timerange", "export", "exportfilename", "db_url", +ARGS_PLOT_PROFIT = ["pairs", "timerange", "export", "exportfilename", "backtestfilename", "db_url", "trade_source", "timeframe", "plot_auto_open"] ARGS_INSTALL_UI = ["erase_ui_only", 'ui_version'] diff --git a/freqtrade/commands/cli_options.py b/freqtrade/commands/cli_options.py index fc5542c52..f081e809c 100644 --- a/freqtrade/commands/cli_options.py +++ b/freqtrade/commands/cli_options.py @@ -182,11 +182,17 @@ AVAILABLE_CLI_OPTIONS = { ), "exportfilename": Arg( - '--export-filename', - help='Save backtest results to the file with this filename. ' - 'Requires `--export` to be set as well. ' - 'Example: `--export-filename=user_data/backtest_results/backtest_today.json`', - metavar='PATH', + "--export-filename", + help="Save backtest results to the file with this filename. " + "Requires `--export` to be set as well. " + "Example: `--export-filename=user_data/backtest_results/backtest_today.json`", + metavar="PATH", + ), + "backtestfilename": Arg( + "--backtest-filename", + help="Use backtest results from this filename." + "Example: `--backtest-filename=user_data/backtest_results/backtest_today.json`", + metavar="PATH", ), "disableparamexport": Arg( '--disable-param-export', diff --git a/freqtrade/configuration/configuration.py b/freqtrade/configuration/configuration.py index 3ac2e3ddd..5bff9a91c 100644 --- a/freqtrade/configuration/configuration.py +++ b/freqtrade/configuration/configuration.py @@ -430,6 +430,15 @@ class Configuration: self._args_to_config(config, argname='dataformat_trades', logstring='Using "{}" to store trades data.') + if self.args.get('backtestfilename'): + self._args_to_config(config, argname='backtestfilename', + logstring='Fetching backtest results from {} ...') + config['backtestfilename'] = Path(config['backtestfilename']) + else: + config['backtestfilename'] = (config['user_data_dir'] + / 'backtest_results') + + def _process_data_options(self, config: Dict[str, Any]) -> None: self._args_to_config(config, argname='new_pairs_days', diff --git a/freqtrade/plot/plotting.py b/freqtrade/plot/plotting.py index 3b322696c..17cc11550 100644 --- a/freqtrade/plot/plotting.py +++ b/freqtrade/plot/plotting.py @@ -61,7 +61,11 @@ def init_plotscript(config, markets: List, startup_candles: int = 0): startup_candles, min_date) no_trades = False - filename = config.get('exportfilename') + for arg_name in ['exportfilename', 'backtestfilename']: + filename = config.get(arg_name) + if filename is not None: + break + if config.get('no_trades', False): no_trades = True elif config['trade_source'] == 'file':