AminHP / gym-anytrading

The most simple, flexible, and comprehensive OpenAI Gym trading environment (Approved by OpenAI Gym)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to evaluate models

ShinyOrbThing opened this issue · comments

I have trained an A2C model on some simulated stock data, following the same steps as are shown in this notebook.

On the line containing "obs = obs[np.newaxis, ...]"

I get the following error:
TypeError: tuple indices must be integers or slices, not tuple

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

This code is based on an older version of gym-anytrading. You can install gym-anytrading<2.0.0, or change your code according to these examples.