From the course: Practical Python for Algorithmic Trading

Unlock the full course today

Join today to access over 23,400 courses taught by industry experts.

Anchored walk forward validation in backtesting

Anchored walk forward validation in backtesting - Python Tutorial

From the course: Practical Python for Algorithmic Trading

Anchored walk forward validation in backtesting

- [Instructor] To use the anchored walk forward validation in the backtesting strategy, we need to pre-process the data within the strategy class. First, we pre-process the training set whose data is taken from the backtest class. Therefore, self.data DF iloc to locate by the position from the very first day until let's say 600 days. And because this is the explanatory variable, I want all of the columns, but the last one. Remember that we take the data from DF. With this part of the code we are telling to take all of these columns. Now for the Y train, we do the same, but this time we select the last column. So far, we are only training the model on the first 600 days but we need to take action whether to buy or sell the stock. Even though we have those steps in these lines of code, they don't contain the anchored walk forward procedure. To do so, we need to create a new class, which I named walk forward anchored, and…

Contents