diff --git a/freqtrade/configuration/arguments.py b/freqtrade/configuration/arguments.py index 44bc71038..a20ecaa43 100644 --- a/freqtrade/configuration/arguments.py +++ b/freqtrade/configuration/arguments.py @@ -47,7 +47,7 @@ ARGS_BUILD_STRATEGY = ["user_data_dir", "strategy", "template"] ARGS_BUILD_HYPEROPT = ["user_data_dir", "hyperopt", "template"] -ARGS_CONVERT_DATA = [] +ARGS_CONVERT_DATA = ["format_from", "format_to"] ARGS_DOWNLOAD_DATA = ["pairs", "pairs_file", "days", "download_trades", "exchange", "timeframes", "erase"] @@ -65,8 +65,9 @@ ARGS_HYPEROPT_LIST = ["hyperopt_list_best", "hyperopt_list_profitable", "print_c ARGS_HYPEROPT_SHOW = ["hyperopt_list_best", "hyperopt_list_profitable", "hyperopt_show_index", "print_json", "hyperopt_show_no_header"] -NO_CONF_REQURIED = ["convert-data", "download-data", "list-timeframes", "list-markets", - "list-pairs", "list-strategies", "hyperopt-list", "hyperopt-show", +NO_CONF_REQURIED = ["convert-data", "convert-trade-data", "download-data", + "list-timeframes", "list-markets", "list-pairs", + "list-strategies", "hyperopt-list", "hyperopt-show", "plot-dataframe", "plot-profit"] NO_CONF_ALLOWED = ["create-userdir", "list-exchanges", "new-hyperopt", "new-strategy"] @@ -256,10 +257,19 @@ class Arguments: # Add convert-data subcommand convert_data_cmd = subparsers.add_parser( 'convert-data', - help='Convert data from one format to another.', + help='Convert OHLCV data from one format to another.', parents=[_common_parser], ) - convert_data_cmd.set_defaults(func=start_convert_data) + convert_data_cmd.set_defaults(func=partial(start_convert_data, ohlcv=True)) + self._build_args(optionlist=ARGS_CONVERT_DATA, parser=convert_data_cmd) + + # Add convert-data subcommand + convert_data_cmd = subparsers.add_parser( + 'convert-trade-data', + help='Convert trade-data from one format to another.', + parents=[_common_parser], + ) + convert_data_cmd.set_defaults(func=partial(start_convert_data, ohlcv=False)) self._build_args(optionlist=ARGS_CONVERT_DATA, parser=convert_data_cmd) # Add Plotting subcommand diff --git a/freqtrade/configuration/cli_options.py b/freqtrade/configuration/cli_options.py index 4b6429f20..ffaf9ea66 100644 --- a/freqtrade/configuration/cli_options.py +++ b/freqtrade/configuration/cli_options.py @@ -332,6 +332,18 @@ AVAILABLE_CLI_OPTIONS = { 'desired timeframe as specified as --timeframes/-t.', action='store_true', ), + "format_from": Arg( + '--format-from', + help='Source format for data conversation.', + choices=constants.AVAILABLE_DATAHANDLERS, + required=True, + ), + "format_to": Arg( + '--format-to', + help='Destination format for data conversation.', + choices=constants.AVAILABLE_DATAHANDLERS, + required=True, + ), "exchange": Arg( '--exchange', help=f'Exchange name (default: `{constants.DEFAULT_EXCHANGE}`). ' diff --git a/freqtrade/utils.py b/freqtrade/utils.py index 82d781fe5..d02c80f7f 100644 --- a/freqtrade/utils.py +++ b/freqtrade/utils.py @@ -280,15 +280,19 @@ def convert_ohlcv_format(config: Dict[str, Any], convert_from: str, convert_to: trg.ohlcv_store(data) -def start_convert_data(args: Dict[str, Any]) -> None: +def start_convert_data(args: Dict[str, Any], ohlcv: bool = True) -> None: """ Convert data from one format to another """ config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE) from pprint import pprint pprint(config) - - # convert_trades_format(config, 'json', 'jsongz') + if ohlcv: + convert_ohlcv_format(config, + convert_from=args['format_from'], convert_to=args['format_to']) + else: + convert_trades_format(config, + convert_from=args['format_from'], convert_to=args['format_to']) def start_list_timeframes(args: Dict[str, Any]) -> None: