Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Correlation Threshold Algorithm with a hint of #Fundamentals

Hi Quantopians,

This is my first approach to quant finance. I wanted to create an algorithm that:

  1. Had few handpicked parameters
  2. Chose unbiasedly the lowest absolutely correlating set of stocks from a wide range of stocks
  3. Only went long and avoided any kind of chartist/momentum strategy

Nevertheless I believe that the stringent requirements I put in (2) made the problem very hard to solve, so I would have had to go and look for portfolio absolute correlations for about C(500,5) ~ 256B combinations which was obviously a no-go. I decided to drastically simplify the problem by allowing a absolute correlation threshold and a minimum number of stocks for the portfolio to be taken into account.

In practice my algorithm will find, given a universe (which I decided to fill with highly market capitalized non-financial, non-real-estate companies thanks to the #Fundamentals), a set of 4-5 stocks which have a correlation of maximum .2 (but you can of course tweak the parameters). The algo uses a 1-month price history to compute correlation and rebalances every month.

Results are extremely interesting: in my simplified version of the problem there seems to be no empirical proof of the fact that low correlation = better returns in the long run (which is something often assumed). Nevertheless the variance of the returns seems to be slightly lower (compressed losses and gains w.r.t. baseline). Even though markets are often assumed to be efficient, any simple momentum strategy can outperform this algorithm, which in theory should be more solid in the long run.

@Quantopian team:
- Great platform :-)
- If I use set_universe from the dollar universe I can have a pool of 500 stocks to choose from. If I use the #Fundamentals I can only update my universe with up to 200 stocks, which is a bit annoying (I'd love to be able to use more stocks to create my portfolios!).
- I tried to use signals and multithreading to prevent timeout exceptions, but none of the modules was available so I had to use a very basic timeout-checking solution. I think it would be great if you could provide some kind of event handler for timeouts.