Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Moving Linear Regression with Slope and R-squared Custom Factors?

Is there a way I can make a moving linear regression of just price for each stock, and compute the slope and r-squared of the line as custom factors? I'm thinking something like this example with visa. I want the slope and r-squared as custom factors so I can use .top() or .bottom() for my universe.

2 responses

This is a good starting point that you can adapt to your needs

Thanks Luca! This it.