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.

How to train models within the backtest

How to train models within the backtest - Python Tutorial

From the course: Practical Python for Algorithmic Trading

How to train models within the backtest

- [Instructor] To create a back test report from an investment strategy where we train the model within the strategy and evaluate on another dataset, we need to modify the init function of the strategy class. The first thing is to declare the decision tree regressor with the max depth of 15 and the random state to be 42, as before. And now we should train the model with self model fit. We need to pass X equals to the X train and Y equals to the Y train. We execute to create the strategies and now at the time to run the back test on a dataset that we need to choose now. And we will choose the X test where we have the required data frame for the back test class. Therefore X test, we set the limit by one, limit cell minus five, with the following lines of code. We get the results, select until the return percentage, change the name of the column, and here we have the report. We do the same on the training back test. Instead of…

Contents