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

Here is something I tried. Get a bunch of stocks, identify statistical risk factors and create a portfolio such that its exposure to all factors is zero. It should by nature be mean reverting. Unfortunately the opportunity is scant and there are long periods without any trades.

I want to try this on several portfolios (3 at the moment) such as 50/60 portfolios so that there is opportunity every day. My python skills are rusty. Could someone modify this algorithm so that it can scale to 50 or 60 portfolios without duplicating code for each portfolio like I did?

4 responses

Improved version 2 sharpe.

Hi Pravin, here is the requested change (and possibly some additional bugs, you can never trust code changes ;)
thanks for sharing your ideas

Thank you very much Luca. Code is cleaner and easily scalable now. Many thanks again.

10 million 1 portfolio 2 years with Luca's code. It suffers very few losses but opportunity is scant with just one portfolio.