From 98cf98693468c57335ad38fa9e5b6b9ac02ec66f Mon Sep 17 00:00:00 2001 From: kryofly Date: Fri, 12 Jan 2018 10:52:44 +0100 Subject: [PATCH] misc options parsing split up --- freqtrade/misc.py | 122 ++++++++++++++++++++++++---------------------- 1 file changed, 65 insertions(+), 57 deletions(-) diff --git a/freqtrade/misc.py b/freqtrade/misc.py index 3d70f6b25..92fe39ef2 100644 --- a/freqtrade/misc.py +++ b/freqtrade/misc.py @@ -110,6 +110,14 @@ def common_args_parser(description: str): type=str, metavar='PATH', ) + parser.add_argument( + '-dd', '--datadir', + help='path to backtest data (default freqdata/tests/testdata', + dest='datadir', + default=os.path.join('freqtrade', 'tests', 'testdata'), + type=str, + metavar='PATH', + ) return parser @@ -126,14 +134,6 @@ def parse_args(args: List[str], description: str): action='store_true', dest='dry_run_db', ) - parser.add_argument( - '-dd', '--datadir', - help='path to backtest data (default freqdata/tests/testdata', - dest='datadir', - default=os.path.join('freqtrade', 'tests', 'testdata'), - type=str, - metavar='PATH', - ) parser.add_argument( '--dynamic-whitelist', help='dynamically generate and update whitelist \ @@ -149,6 +149,61 @@ def parse_args(args: List[str], description: str): return parser.parse_args(args) +def backtesting_options(parser: argparse.ArgumentParser) -> None: + parser.add_argument( + '-l', '--live', + action='store_true', + dest='live', + help='using live data', + ) + parser.add_argument( + '-i', '--ticker-interval', + help='specify ticker interval in minutes (default: 5)', + dest='ticker_interval', + default=5, + type=int, + metavar='INT', + ) + parser.add_argument( + '--realistic-simulation', + help='uses max_open_trades from config to simulate real world limitations', + action='store_true', + dest='realistic_simulation', + ) + parser.add_argument( + '-r', '--refresh-pairs-cached', + help='refresh the pairs files in tests/testdata with the latest data from Bittrex. \ + Use it if you want to run your backtesting with up-to-date data.', + action='store_true', + dest='refresh_pairs', + ) + + +def hyperopt_options(parser: argparse.ArgumentParser) -> None: + parser.add_argument( + '-e', '--epochs', + help='specify number of epochs (default: 100)', + dest='epochs', + default=100, + type=int, + metavar='INT', + ) + parser.add_argument( + '--use-mongodb', + help='parallelize evaluations with mongodb (requires mongod in PATH)', + dest='mongodb', + action='store_true', + ) + parser.add_argument( + '-i', '--ticker-interval', + help='specify ticker interval in minutes (default: 5)', + dest='ticker_interval', + default=5, + type=int, + metavar='INT', + ) + + def build_subcommands(parser: argparse.ArgumentParser) -> None: """ Builds and attaches all subcommands """ from freqtrade.optimize import backtesting, hyperopt @@ -158,59 +213,12 @@ def build_subcommands(parser: argparse.ArgumentParser) -> None: # Add backtesting subcommand backtesting_cmd = subparsers.add_parser('backtesting', help='backtesting module') backtesting_cmd.set_defaults(func=backtesting.start) - backtesting_cmd.add_argument( - '-l', '--live', - action='store_true', - dest='live', - help='using live data', - ) - backtesting_cmd.add_argument( - '-i', '--ticker-interval', - help='specify ticker interval in minutes (default: 5)', - dest='ticker_interval', - default=5, - type=int, - metavar='INT', - ) - backtesting_cmd.add_argument( - '--realistic-simulation', - help='uses max_open_trades from config to simulate real world limitations', - action='store_true', - dest='realistic_simulation', - ) - backtesting_cmd.add_argument( - '-r', '--refresh-pairs-cached', - help='refresh the pairs files in tests/testdata with the latest data from Bittrex. \ - Use it if you want to run your backtesting with up-to-date data.', - action='store_true', - dest='refresh_pairs', - ) + backtesting_options(backtesting_cmd) # Add hyperopt subcommand hyperopt_cmd = subparsers.add_parser('hyperopt', help='hyperopt module') hyperopt_cmd.set_defaults(func=hyperopt.start) - hyperopt_cmd.add_argument( - '-e', '--epochs', - help='specify number of epochs (default: 100)', - dest='epochs', - default=100, - type=int, - metavar='INT', - ) - hyperopt_cmd.add_argument( - '--use-mongodb', - help='parallelize evaluations with mongodb (requires mongod in PATH)', - dest='mongodb', - action='store_true', - ) - hyperopt_cmd.add_argument( - '-i', '--ticker-interval', - help='specify ticker interval in minutes (default: 5)', - dest='ticker_interval', - default=5, - type=int, - metavar='INT', - ) + hyperopt_options(hyperopt_cmd) # Required json-schema for user specified config