Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Predicting Price Movements via Regimes and Machine Learning

The basic idea behind this strategy was that machine learning techniques could be used to identify what regime a stock is currently in and use that to predict future price movements.

I took several window sizes (roughly multiples of 30 trading days) into the past and computed the normalized trend line, the volatility around the trend line, and the classical volatility of the stock over these windows.

This set of data is then clustered via k-means clustering to identify a set of regimes.

Vectors are made from the current regime of each lookback window size and passed into a Random Forest. The y vector here is either a the return realized N (30) days into the future, or some categorization based on return bucketing. The distinction between these is whether the Random Forest is used as a regressor or classifier.

Based on the output of the Random Forest, we choose to go long/short/flat the stock.

6 responses

I should point out that this strategy did not lever up at all, so these returns aren't artificially inflated by leverage.

Hi, do you have a chart of your Positions? I would like to see how active the system is.

Negative beta. Wonderful.

I just tried the algo with Tesla (TSLA). July 2011 to Nov 2016, algo -25.5% while stock up 555%. Picking the right stock is crucial (love the car anyway).

by changing the random_state yields a different result. 274.62% by luck? not sure.

Keith - thanks. Wow, from +274% to now up only +3.8% :(