Ejemplo n.º 1
0
class TestRLTrader():
    def setup_class(self):
        self.parser = RLTraderCLI().get_parser()

    @mock.patch.object(RLTrader, 'initialize_data', return_value=True)
    @mock.patch.object(RLTrader, 'optimize', return_value=True)
    @mock.patch.object(RLTrader, 'initialize_optuna', return_value=True)
    def test_that_args_get_injected_correctly(self, data_mock, opt_mock,
                                              init_mock):
        args = self.parser.parse_args(['optimize'])
        sut = RLTrader(**vars(args), logger=MagicMock())
        sut.study_name = 'test'
        with mock.patch('lib.util.logger.init_logger'):
            assert (sut.tensorboard_path == args.tensorboard_path)
            assert (sut.params_db_path == args.params_db_path)
            assert (sut.model_verbose == args.model_verbose)
            assert (sut.nminibatches == args.nminibatches)
            assert (sut.train_split_percentage == args.train_split_percentage)
            assert (sut.input_data_path == args.input_data_path)
            assert (sut.model_verbose == args.model_verbose)
Ejemplo n.º 2
0
import numpy as np

from lib.RLTrader import RLTrader
from lib.cli.RLTraderCLI import RLTraderCLI
from lib.util.logger import init_logger

np.warnings.filterwarnings('ignore')
trader_cli = RLTraderCLI()
args = trader_cli.get_args()

if __name__ == '__main__':
    logger = init_logger(__name__, show_debug=args.debug)
    trader = RLTrader(**vars(args), logger=logger)

    if args.command == 'optimize':
        trader.optimize(n_trials=args.trials,
                        n_parallel_jobs=args.parallel_jobs)
    elif args.command == 'train':
        trader.train(n_epochs=args.epochs)
    elif args.command == 'test':
        trader.test(model_epoch=args.model_epoch, should_render=args.no_render)
    elif args.command == 'opt-train-test':
        trader.optimize(args.trials, args.parallel_jobs)
        trader.train(n_epochs=args.train_epochs,
                     test_trained_model=args.no_test,
                     render_trained_model=args.no_render)
Ejemplo n.º 3
0
 def setup_class(self):
     self.parser = RLTraderCLI().get_parser()