Closed sword134 closed 4 years ago
The window size should be one unit less than the dataframe size.
df_size = len(df)
window_size = df_size - 1
env = gym.make('stocks-v0', df=df, window_size=window_size, frame_bound=(window_size, df_size))
Doing exactly that I get the following error:
Traceback (most recent call last):
File "d:\ReinforcementLearning\BaseLines\Trading\RL Trading.py", line 225, in <module>
results = model.learn(int(100000))
File "D:\Anaconda\envs\RL\lib\site-packages\stable_baselines\deepq\dqn.py", line 219, in learn
new_obs, rew, done, info = self.env.step(env_action)
File "D:\Anaconda\envs\RL\lib\site-packages\gym_anytrading\envs\trading_env.py", line 76, in step
step_reward = self._calculate_reward(action)
File "d:\ReinforcementLearning\BaseLines\Trading\RL Trading.py", line 142, in _calculate_reward
current_price = self.prices[self._current_tick]
IndexError: index 3926 is out of bounds for axis 0 with size 3926
Sorry, the window size should be two units less than the dataframe size; One for the reset
method and another for the step
method. The code below works properly with stable_baselines
.
df_size = len(df)
window_size = df_size - 2
env = gym.make('stocks-v0', df=df, window_size=window_size, frame_bound=(window_size, df_size))
Hello, with the below code I am presented with the error stated in the title. I want my window to be as big as my df frame.
custom_env = gym.make('stocks-v0', df = data, window_size = 3927, frame_bound = (1, 3927))
The error: