From 3f04930f383272f588bd33d455b10f832cf16c18 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 16 Jun 2019 13:19:06 +0200 Subject: [PATCH] Require pairs argument --- freqtrade/arguments.py | 7 +++++++ freqtrade/tests/test_arguments.py | 17 +++++++++++++---- scripts/plot_dataframe.py | 5 +++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/freqtrade/arguments.py b/freqtrade/arguments.py index fde372b63..cef38784d 100644 --- a/freqtrade/arguments.py +++ b/freqtrade/arguments.py @@ -519,6 +519,13 @@ class Arguments(object): """ Parses given arguments for plot_dataframe """ + self.parser.add_argument( + '-p', '--pairs', + help='Show profits for only this pairs. Pairs are comma-separated.', + dest='pairs', + required=True, + default=None + ) self.parser.add_argument( '--indicators1', help='Set indicators from your strategy you want in the first row of the graph. Separate ' diff --git a/freqtrade/tests/test_arguments.py b/freqtrade/tests/test_arguments.py index d1b96a923..d584a9e01 100644 --- a/freqtrade/tests/test_arguments.py +++ b/freqtrade/tests/test_arguments.py @@ -191,13 +191,22 @@ def test_plot_dataframe_options() -> None: '--indicators1', 'sma10,sma100', '--indicators2', 'macd,fastd,fastk', '--plot-limit', '30', + '-p', 'UNITTEST/BTC', ] arguments = Arguments(args, '') arguments.plot_dataframe_options() - args = arguments.parse_args(True) - assert args.indicators1 == "sma10,sma100" - assert args.indicators2 == "macd,fastd,fastk" - assert args.plot_limit == 30 + pargs = arguments.parse_args(True) + assert pargs.indicators1 == "sma10,sma100" + assert pargs.indicators2 == "macd,fastd,fastk" + assert pargs.plot_limit == 30 + assert pargs.pairs == "UNITTEST/BTC" + + # Pop pairs argument + args = args[:-2] + arguments = Arguments(args, '') + arguments.plot_dataframe_options() + with pytest.raises(SystemExit, match=r'2'): + arguments.parse_args(True) def test_check_int_positive() -> None: diff --git a/scripts/plot_dataframe.py b/scripts/plot_dataframe.py index d37d63c32..c44f2aa4b 100755 --- a/scripts/plot_dataframe.py +++ b/scripts/plot_dataframe.py @@ -89,7 +89,7 @@ def get_tickers_data(strategy, exchange, pairs: List[str], timerange: TimeRange, ticker_interval=ticker_interval, refresh_pairs=_CONF.get('refresh_pairs', False), timerange=timerange, - exchange=Exchange(_CONF), + exchange=exchange, live=live, ) @@ -132,6 +132,8 @@ def analyse_and_plot_pairs(args: Namespace): :return: None """ strategy, exchange, pairs = get_trading_env(args) + pairs = args.pairs.split(',') + # Set timerange to use timerange = Arguments.parse_timerange(args.timerange) ticker_interval = strategy.ticker_interval @@ -170,7 +172,6 @@ def plot_parse_args(args: List[str]) -> Namespace: :return: args: Array with all arguments """ arguments = Arguments(args, 'Graph dataframe') - arguments.scripts_options() arguments.plot_dataframe_options() arguments.common_args_parser() arguments.optimizer_shared_options(arguments.parser)