This is the fourth in my series updating Sentdex's Tutorial for Quantopian 2. It covers videos 14-17.
Here's the first post. Here's the second. Here's the third.
The strategy uses an ensemble of machine learning classifiers combined with a trend-regime confirmation. While the last algorithm had the most complicated entry/exit rules, this algorithm has by far the most complex data manipulation. When Sentdex does his tutorials, it seems like he's essentially performing a 'stream of consciousness' coding- and while that probably helps him get such a high output volume- it leaves a lot of room for refactoring.
While in previous updates, most of that refactoring was in signal processing and order execution, most of the changes here are in data processing. Instead of recalculating the entire feature set every day, I do a bulk feature creation at the beginning and then appropriately drop off stale data and add in new data.
Note- the order entry that he uses on this algorithm is extremely simple. There is a lot of room for you to play with more complex entry/exit logic to improve on the algorithm.
In terms of syntax updates, it's the two major ones again history()
and data[stock].mav()
get converted into the appropriate new call of data.history(stock,'price',days,'1d')
.
As always, if you have any questions, don't hesitate to ask.