-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
32 lines (30 loc) · 879 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from erl_config import build_env
from trade_simulator import TradeSimulator, EvalTradeSimulator
import torch as th
env_args = {
"env_name": "TradeSimulator-v0",
"num_envs": 1,
"max_step": 1000,
"state_dim": 8 + 2, # factor_dim + (position, holding)
"action_dim": 3, # long, 0, short
"if_discrete": True,
"max_position": 1,
"slippage": 7e-7,
"num_sims": 1,
"step_gap": 1,
"env_class":TradeSimulator
}
env = build_env(TradeSimulator, env_args, -1)
device = th.device("cpu")
for i in range(10):
env.reset()
print("Episode " + str(i))
for j in range(100):
a = int(input())
a = th.zeros((1, 1), dtype=th.float32, device=device) + a
s, r, done, info = env.step(a)
print(s)
print(r)
print(done)
if done:
break