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

trading_env step(action) returns previous observation #66

Closed henrydeclety closed 2 years ago

henrydeclety commented 2 years ago

Going through your code for TradingEnv, something seems odd to me, the function step(action) is supposed to return the next observation right?

In step(action), if it is using prices[self._current_tick] to calculate the reward given by action, the it should return the observation which contains the data point at self._current_tick right? In that case shouldn't get_observation be

def _get_observation(self):
        return self.signal_features[(self._current_tick-self.window_size+1):self._current_tick+1]

instead of

def _get_observation(self):
        return self.signal_features[(self._current_tick-self.window_size):self._current_tick]

?

Thank you for your help

AminHP commented 2 years ago

Hi @henrydeclety,

I think you are right. I had fixed the issue in my other repo but forgot to update it here. Thanks for noticing. I released a new version.