Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Regression Slopes

I based this on the idea that if a price is increasing, then the regression line of the last n prices should be positive (depending on the window). It stays in as long as the slope on a long window is positive and gets out when the slope on a short window goes negative. The idea is that the short window is an early warning that the long window is about to go negative. It has a trailing stop loss on the way up. I used sector ETFs for this test.

2 responses

Hey this is pretty good code. What kind of regression is quantopian giving you with reg_ ? can it do a cubic or is it only a quadratic regression?

did you think about going short when the slope was negative? or buying inverse ETFs when slope was negative?

sorry for so many questions but one more, how did you decide to use 250 and 190 for your window sizes?

Good questions Chris.

Adding to that ... I like this in part because of both long and short windows for slope.
Would like to know what it can do deciding to trade when slopes are above/below average by certain amounts (vs 0). Filled in some code however it needs the dataframe bit (for storing avg, lo, hi per security) to be able to handle more than one security, and that can also simplify, hope someone can help.