ClementPerroud / Gym-Trading-Env

A simple, easy, customizable Gymnasium environment for trading.
https://gym-trading-env.readthedocs.io/
MIT License
304 stars 66 forks source link

MultiDatasetTradingEnv - Look ahead issue? #7

Open livecat-ai opened 1 year ago

livecat-ai commented 1 year ago

Hi Clement,

From what I understand reading the docs for the MultiDatasetTradingEnv:

If this is the case are we introducing look ahead bias. Since at the end of the first episode we have already seen into the future. Would it be more realistic to iterate over all the datasets at time t, advance to time t+1 and again iterate over all the datasets up to time T?

Do you have any thoughts on this?

Best John.

Karlheinzniebuhr commented 1 year ago

Hi Clement,

From what I understand reading the docs for the MultiDatasetTradingEnv:

  • The env selects a dataset and then advances through the time steps until done.
  • It then selects another dataset and repeats the above.

If this is the case are we introducing look ahead bias. Since at the end of the first episode we have already seen into the future. Would it be more realistic to iterate over all the datasets at time t, advance to time t+1 and again iterate over all the datasets up to time T?

Do you have any thoughts on this?

Best John.

During training there is more than one pass, so even if you switch between datasets, the model will do thousands of iterations on them again later. I think what you mean is that during evaluation there should be no lookahead, but afaik that won't happen since you would backtest a model on individual test datasets (not seen during training)