(TypeError: tuple indices must be integers or slices, not tuple) Stable-baselines3 gym

85 Views Asked by At

Hi I am trying to make Trading Agent using an old YouTube video but when testing the Agent I get a TypeError.

Building the Environment works

state = env.reset()
try:
    while True: 
        action = env.action_space.sample()
        result = env.step(action)

        n_state, reward, done, _, info = result
        if done: 
            print("info", info)
            break

except Exception as e:
    print("An error occurred:", e)

But not the Evaluation

env = gym.make('stocks-v0', df=df, frame_bound=(90,110), window_size=5)
obs = env.reset()
while True: 
    obs = obs[np.newaxis, ...]
    action, _states = model.predict(obs)
    obs, rewards, done, info = env.step(action)
    if done:
        print("info", info)
        break

ChatGPT was no help it helped with the building tho eventually. link to original: https://github.com/nicknochnack/Reinforcement-Learning-for-Trading/blob/main/Reinforcement%20Learning%20GME%20Trading%20Tutorial.ipynb

0

There are 0 best solutions below