torch, nn = try_import_torch() def env_creator(env_name): if env_name == "StocksEnv-v0": from lib.environ import StocksEnv as env else: raise NotImplementedError return env # register the env BARS_COUNT = 30 STOCKS = '/Users/user/Desktop/Market_Research/stock_data/stock_prices__min_train_NET.csv' stock_data = {"NIO": data.load_relative(STOCKS)} env = env_creator("StocksEnv-v0") tune.register_env('myEnv', lambda config: env(stock_data, bars_count=BARS_COUNT, state_1d=False)) config_model = sac.DEFAULT_CONFIG.copy() config_model["policy_model"] = sac.DEFAULT_CONFIG["policy_model"].copy() config_model["env"] = "myEnv" config_model["gamma"] = 1.0 config_model["no_done_at_end"] = True config_model["tau"] = 3e-3 config_model["target_network_update_freq"] = 32 config_model["num_workers"] = 1 # Run locally. config_model["twin_q"] = True config_model["clip_actions"] = True config_model["normalize_actions"] = True config_model["learning_starts"] = 0 config_model["prioritized_replay"] = True config_model["train_batch_size"] = 32
def env_creator(env_name): if env_name == "StocksEnv-v0": from lib.environ import StocksEnv as env else: raise NotImplementedError return env # register the env BARS_COUNT = 30 STOCKS = '/Users/user/Desktop/Market_Research/stock_data/stock_prices__min_train_NET.csv' stock_data = {"NIO": data.load_relative(STOCKS)} env = env_creator("StocksEnv-v0") tune.register_env( 'myEnv', lambda config: env(stock_data, bars_count=BARS_COUNT, state_1d=False)) #ray.shutdown() #ray.init(num_cpus=16, num_gpus=0, ignore_reinit_error=True) ModelCatalog.register_custom_model("my_model", TorchCustomModel) config_model = { "env": "myEnv", # Use GPUs iff `RLLIB_NUM_GPUS` env var set to > 0. "num_gpus": int(os.environ.get("RLLIB_NUM_GPUS", "0")), "model": { "custom_model": "my_model", "vf_share_layers": False, }, "batch_mode": "truncate_episodes", "sgd_minibatch_size": 32,