diff --git a/lib/cli/RLTraderCLI.py b/lib/cli/RLTraderCLI.py index eba08b3..20e8165 100644 --- a/lib/cli/RLTraderCLI.py +++ b/lib/cli/RLTraderCLI.py @@ -1,11 +1,27 @@ import argparse import os import multiprocessing +from configparser import ConfigParser + class RLTraderCLI: def __init__(self): + config_parser = argparse.ArgumentParser(add_help=False) + config_parser.add_argument("-f", "--from-config", help="Specify config file", metavar="FILE") + args, remaining_argv = config_parser.parse_known_args() + defaults = {} + + if args.from_config: + config = ConfigParser.SafeConfigParser() + config.read([args.from_config]) + defaults = dict(config.items("Defaults")) + formatter = argparse.ArgumentDefaultsHelpFormatter - self.parser = argparse.ArgumentParser(description='Trainer', formatter_class=formatter) + self.parser = argparse.ArgumentParser( + formatter_class=formatter, + parents=[config_parser], + description=__doc__ + ) self.parser.add_argument("--data-provider", "-o", type=str, default="static") self.parser.add_argument("--input-data-path", "-t", type=str, default="data/input/coinbase-1h-btc-usd.csv") @@ -15,7 +31,7 @@ def __init__(self): self.parser.add_argument('--train-split-percentage', type=int, default=0.8, help='Train set percentage') self.parser.add_argument('--verbose-model', type=int, default=1, help='Verbose model') self.parser.add_argument('--params-db-path', type=str, default='sqlite:///data/params.db', - help='Params path') + help='Params path') self.parser.add_argument( '--tensor-board-path', type=str, @@ -32,12 +48,14 @@ def __init__(self): opt_train_test_parser.add_argument('--train-epochs', type=int, default=10, help='Train for how many epochs') opt_train_test_parser.add_argument('--no-render', action='store_false', help='Should render the model') opt_train_test_parser.add_argument('--no-test', action='store_false', help='Should test the model') - opt_train_test_parser.add_argument('--proc-number', type=int, default=multiprocessing.cpu_count(), help='How many processes to spawn') + opt_train_test_parser.add_argument('--proc-number', type=int, default=multiprocessing.cpu_count(), + help='How many processes to spawn') optimize_parser = subparsers.add_parser('optimize', description='Optimize model parameters') optimize_parser.add_argument('--trials', type=int, default=1, help='Number of trials') optimize_parser.add_argument('--parallel-jobs', type=int, default=1, help='How many jobs in parallel') - optimize_parser.add_argument('--proc-number', type=int, default=multiprocessing.cpu_count(), help='How many processes to spawn') + optimize_parser.add_argument('--proc-number', type=int, default=multiprocessing.cpu_count(), + help='How many processes to spawn') optimize_parser.add_argument('--verbose-model', type=int, default=1, help='Verbose model', dest='model_verbose') @@ -47,6 +65,7 @@ def __init__(self): test_parser = subparsers.add_parser('test', description='Test model') test_parser.add_argument('--model-epoch', type=int, default=1, help='Model epoch index') test_parser.add_argument('--no-render', action='store_false', help='Do not render test') + self.parser.set_defaults(**defaults) def get_args(self): return self.parser.parse_args() diff --git a/requirements.base.txt b/requirements.base.txt new file mode 100644 index 0000000..0b25d07 --- /dev/null +++ b/requirements.base.txt @@ -0,0 +1,14 @@ +numpy +pandas +sklearn +matplotlib +gym +stable_baselines +optuna +ta +statsmodels==0.10.0rc2 +empyrical +ccxt +psycopg2 +deco +configparser \ No newline at end of file diff --git a/requirements.no-gpu.txt b/requirements.no-gpu.txt index 9ad3e5d..cd59df3 100644 --- a/requirements.no-gpu.txt +++ b/requirements.no-gpu.txt @@ -1,13 +1,2 @@ -numpy -pandas -sklearn -matplotlib -gym -stable_baselines -optuna -ta -statsmodels==0.10.0rc2 -empyrical +-r requirements.base.yml tensorflow -ccxt -deco \ No newline at end of file diff --git a/requirements.tests.txt b/requirements.tests.txt index f8017f2..d6995e2 100644 --- a/requirements.tests.txt +++ b/requirements.tests.txt @@ -1,3 +1,2 @@ -r requirements.no-gpu.txt -pytest -deco \ No newline at end of file +pytest \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 9ff48e3..7fe5336 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,14 +1,2 @@ -numpy -pandas -sklearn -matplotlib -gym -stable_baselines -optuna -ta -statsmodels==0.10.0rc2 -empyrical -tensorflow-gpu -ccxt -psycopg2 -deco \ No newline at end of file +-r requirements.base.yml +tensorflow-gpu \ No newline at end of file