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}, + )