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.

Create library for backtesting strategies

Create library for backtesting strategies - Python Tutorial

From the course: Practical Python for Algorithmic Trading

Create library for backtesting strategies

- [Instructor] To create a library of strategies, we only need to create a new file that is encoded with dot pi. And we will call it, for example, strategies. Now within this file, we will copy paste the strategies that we previously created, the regression, and also the WalkForwardAnchored. And, we need to import the objects we are using, such as the DecisionTreeRegressor and the strategy. So from back testing, import Strategy. And from sklearn.tree import DecisionTreeRegressor. Let's close the panel, to have a clearer view. And now it's time to create the unanchored walk forward class. Which, instead of anchoring a fixed day at the beginning of the dataset to train the model, the days in the anchored approach are moving along with the test set. We create the class in the strategies lettering. We can duplicate this class. We call it Unanchored. And the only thing that changes in this approach is how we select the X and…

Contents