From 5a9f87ac6354b17d8d93bf340a67cd3211cc3d78 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 13 Aug 2024 06:44:28 +0200 Subject: [PATCH] feat: add start_list_trades_data command to output trades data --- freqtrade/commands/__init__.py | 1 + freqtrade/commands/data_commands.py | 53 ++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/freqtrade/commands/__init__.py b/freqtrade/commands/__init__.py index 48ee18e93..ec145eb5f 100644 --- a/freqtrade/commands/__init__.py +++ b/freqtrade/commands/__init__.py @@ -15,6 +15,7 @@ from freqtrade.commands.data_commands import ( start_convert_trades, start_download_data, start_list_data, + start_list_trades_data, ) from freqtrade.commands.db_commands import start_convert_db from freqtrade.commands.deploy_commands import ( diff --git a/freqtrade/commands/data_commands.py b/freqtrade/commands/data_commands.py index 344b97076..ba5f3563a 100644 --- a/freqtrade/commands/data_commands.py +++ b/freqtrade/commands/data_commands.py @@ -118,6 +118,10 @@ def start_list_data(args: Dict[str, Any]) -> None: List available OHLCV data """ + if args["download_trades"]: + start_list_trades_data(args) + return + config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE) from freqtrade.data.history import get_datahandler @@ -127,7 +131,6 @@ def start_list_data(args: Dict[str, Any]) -> None: paircombs = dhc.ohlcv_get_available_data( config["datadir"], config.get("trading_mode", TradingMode.SPOT) ) - if args["pairs"]: paircombs = [comb for comb in paircombs if comb[0] in args["pairs"]] title = f"Found {len(paircombs)} pair / timeframe combinations." @@ -171,3 +174,51 @@ def start_list_data(args: Dict[str, Any]) -> None: summary=title, table_kwargs={"min_width": 50}, ) + + +def start_list_trades_data(args: Dict[str, Any]) -> None: + """ + List available Trades data + """ + + config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE) + + from freqtrade.data.history import get_datahandler + + dhc = get_datahandler(config["datadir"], config["dataformat_trades"]) + + paircombs = dhc.trades_get_available_data( + config["datadir"], config.get("trading_mode", TradingMode.SPOT) + ) + + if args["pairs"]: + paircombs = [comb for comb in paircombs if comb in args["pairs"]] + + title = f"Found trades data for {len(paircombs)} pairs." + if not config.get("show_timerange"): + print_rich_table( + [(pair, config.get("candle_type_def", CandleType.SPOT)) for pair in sorted(paircombs)], + ("Pair", "Type"), + title, + table_kwargs={"min_width": 50}, + ) + else: + paircombs1 = [ + (pair, *dhc.trades_data_min_max(pair, config.get("trading_mode", TradingMode.SPOT))) + for pair in paircombs + ] + print_rich_table( + [ + ( + pair, + config.get("candle_type_def", CandleType.SPOT), + start.strftime(DATETIME_PRINT_FORMAT), + end.strftime(DATETIME_PRINT_FORMAT), + str(length), + ) + for pair, start, end, length in sorted(paircombs1, key=lambda x: (x[0])) + ], + ("Pair", "Type", "From", "To", "Trades"), + summary=title, + table_kwargs={"min_width": 50}, + )