Add trade subparser (and make subparser a requirement)
This commit is contained in:
parent
2a535b72ff
commit
cb37f43277
@ -99,12 +99,19 @@ class Arguments:
|
||||
# Build main command
|
||||
self.parser = argparse.ArgumentParser(description='Free, open source crypto trading bot',
|
||||
parents=[_common_parser])
|
||||
self._build_args(optionlist=ARGS_MAIN, parser=self.parser)
|
||||
|
||||
from freqtrade.optimize import start_backtesting, start_hyperopt, start_edge
|
||||
from freqtrade.utils import start_create_userdir, start_download_data, start_list_exchanges
|
||||
from freqtrade.utils import (start_create_userdir, start_download_data,
|
||||
start_list_exchanges, start_trading)
|
||||
from freqtrade.plot.plot_utils import start_plot_dataframe, start_plot_profit
|
||||
|
||||
subparsers = self.parser.add_subparsers(dest='subparser')
|
||||
subparsers = self.parser.add_subparsers(dest='subparser', required=True)
|
||||
|
||||
# Add trade subcommand
|
||||
trade_cmd = subparsers.add_parser('trade', help='Trade module.',
|
||||
parents=[_common_parser])
|
||||
trade_cmd.set_defaults(func=start_trading)
|
||||
self._build_args(optionlist=ARGS_MAIN, parser=trade_cmd)
|
||||
|
||||
# Add backtesting subcommand
|
||||
backtesting_cmd = subparsers.add_parser('backtesting', help='Backtesting module.',
|
||||
@ -149,7 +156,6 @@ class Arguments:
|
||||
self._build_args(optionlist=ARGS_DOWNLOAD_DATA, parser=download_data_cmd)
|
||||
|
||||
# Add Plotting subcommand
|
||||
from freqtrade.plot.plot_utils import start_plot_dataframe, start_plot_profit
|
||||
plot_dataframe_cmd = subparsers.add_parser('plot-dataframe',
|
||||
help='Plot candles with indicators.',
|
||||
parents=[_common_parser],
|
||||
|
@ -33,6 +33,17 @@ def setup_utils_configuration(args: Dict[str, Any], method: RunMode) -> Dict[str
|
||||
return config
|
||||
|
||||
|
||||
def start_trading(args: Dict[str, Any]) -> int:
|
||||
"""
|
||||
Main entry point for trading mode
|
||||
"""
|
||||
from freqtrade.worker import Worker
|
||||
# Load and run worker
|
||||
worker = Worker(args)
|
||||
worker.run()
|
||||
return 0
|
||||
|
||||
|
||||
def start_list_exchanges(args: Dict[str, Any]) -> None:
|
||||
"""
|
||||
Print available exchanges
|
||||
@ -47,7 +58,7 @@ def start_list_exchanges(args: Dict[str, Any]) -> None:
|
||||
f"{', '.join(available_exchanges())}")
|
||||
|
||||
|
||||
def start_create_userdir(args: Dict[str, Any]) -> None:
|
||||
def start_create_userdir(args: Dict[str, Any]) -> int:
|
||||
"""
|
||||
Create "user_data" directory to contain user data strategies, hyperopts, ...)
|
||||
:param args: Cli args from Arguments()
|
||||
@ -57,7 +68,7 @@ def start_create_userdir(args: Dict[str, Any]) -> None:
|
||||
create_userdata_dir(args["user_data_dir"], create_dir=True)
|
||||
else:
|
||||
logger.warning("`create-userdir` requires --userdir to be set.")
|
||||
sys.exit(1)
|
||||
return 1
|
||||
|
||||
|
||||
def start_download_data(args: Dict[str, Any]) -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user