AminHP / gym-anytrading

The most simple, flexible, and comprehensive OpenAI Gym trading environment (Approved by OpenAI Gym)
MIT License
2.09k stars 459 forks source link

Unable to evaluate models #98

Closed ShinyOrbThing closed 4 months ago

ShinyOrbThing commented 5 months ago

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
AminHP commented 5 months ago

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.

ShinyOrbThing commented 5 months ago

Thanks @AminHP.