From 62c55b18631398c7447b5eed355fa495f0a299af Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 14 Jul 2020 06:55:34 +0200 Subject: [PATCH] Enhance formatting, Add pair filter --- docs/data-download.md | 5 ++++- freqtrade/commands/arguments.py | 2 +- freqtrade/commands/data_commands.py | 6 +++++- tests/commands/test_commands.py | 21 +++++++++++++++++++-- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/docs/data-download.md b/docs/data-download.md index 7fbad0b6c..a2bbec837 100644 --- a/docs/data-download.md +++ b/docs/data-download.md @@ -166,6 +166,7 @@ You can get a list of downloaded data using the `list-data` subcommand. usage: freqtrade list-data [-h] [-v] [--logfile FILE] [-V] [-c PATH] [-d PATH] [--userdir PATH] [--exchange EXCHANGE] [--data-format-ohlcv {json,jsongz}] + [-p PAIRS [PAIRS ...]] optional arguments: -h, --help show this help message and exit @@ -174,6 +175,9 @@ optional arguments: --data-format-ohlcv {json,jsongz} Storage format for downloaded candle (OHLCV) data. (default: `json`). + -p PAIRS [PAIRS ...], --pairs PAIRS [PAIRS ...] + Show profits for only these pairs. Pairs are space- + separated. Common arguments: -v, --verbose Verbose mode (-vv for more, -vvv to get all messages). @@ -190,7 +194,6 @@ Common arguments: Path to directory with historical backtesting data. --userdir PATH, --user-data-dir PATH Path to userdata directory. - ``` #### Example list-data diff --git a/freqtrade/commands/arguments.py b/freqtrade/commands/arguments.py index a49d917a5..e6f6f8167 100644 --- a/freqtrade/commands/arguments.py +++ b/freqtrade/commands/arguments.py @@ -54,7 +54,7 @@ ARGS_BUILD_HYPEROPT = ["user_data_dir", "hyperopt", "template"] ARGS_CONVERT_DATA = ["pairs", "format_from", "format_to", "erase"] ARGS_CONVERT_DATA_OHLCV = ARGS_CONVERT_DATA + ["timeframes"] -ARGS_LIST_DATA = ["exchange", "dataformat_ohlcv"] +ARGS_LIST_DATA = ["exchange", "dataformat_ohlcv", "pairs"] ARGS_DOWNLOAD_DATA = ["pairs", "pairs_file", "days", "download_trades", "exchange", "timeframes", "erase", "dataformat_ohlcv", "dataformat_trades"] diff --git a/freqtrade/commands/data_commands.py b/freqtrade/commands/data_commands.py index d3f70b9ec..13b796a1e 100644 --- a/freqtrade/commands/data_commands.py +++ b/freqtrade/commands/data_commands.py @@ -105,10 +105,14 @@ def start_list_data(args: Dict[str, Any]) -> None: paircombs = dhc.ohlcv_get_available_data(config['datadir']) + if args['pairs']: + paircombs = [comb for comb in paircombs if comb[0] in args['pairs']] + print(f"Found {len(paircombs)} pair / timeframe combinations.") groupedpair = defaultdict(list) for pair, timeframe in sorted(paircombs, key=lambda x: (x[0], timeframe_to_minutes(x[1]))): groupedpair[pair].append(timeframe) print(tabulate([(pair, ', '.join(timeframes)) for pair, timeframes in groupedpair.items()], - headers=("pairs", "timeframe"))) + headers=("Pair", "Timeframe"), + tablefmt='psql', stralign='right')) diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index 9c741e102..ffced956d 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -1056,8 +1056,25 @@ def test_start_list_data(testdatadir, capsys): start_list_data(pargs) captured = capsys.readouterr() assert "Found 16 pair / timeframe combinations." in captured.out - assert "\npairs timeframe\n" in captured.out - assert "\nUNITTEST/BTC 1m, 5m, 8m, 30m\n" in captured.out + assert "\n| Pair | Timeframe |\n" in captured.out + assert "\n| UNITTEST/BTC | 1m, 5m, 8m, 30m |\n" in captured.out + + args = [ + "list-data", + "--data-format-ohlcv", + "json", + "--pairs", "XRP/ETH", + "--datadir", + str(testdatadir), + ] + pargs = get_args(args) + pargs['config'] = None + start_list_data(pargs) + captured = capsys.readouterr() + assert "Found 2 pair / timeframe combinations." in captured.out + assert "\n| Pair | Timeframe |\n" in captured.out + assert "UNITTEST/BTC" not in captured.out + assert "\n| XRP/ETH | 1m, 5m |\n" in captured.out @pytest.mark.usefixtures("init_persistence")