Add second subcommand to allow conversation of ohlcv and trades data

seprately
This commit is contained in:
Matthias 2019-12-25 09:59:01 +01:00
parent c3064dfd2b
commit 2a6b542b09
3 changed files with 34 additions and 8 deletions

View File

@ -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

View File

@ -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}`). '

View File

@ -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: