Here is an attempt to implement the ideas in this research paper titled "Identifying small mean reverting portfolios": http://www.di.ens.fr/~aspremon/PDF/MeanRevVec.pdf
The gist of the paper is that given N stocks in a universe, the algorithm identifies k stocks that are mean reverting (stationary). As a proof of concept, the attached code does not implement a trading strategy but only logs if the smaller portfolio is stationary or not.
Unfortunately, the optimization using cvxopt for this algo is quite intensive and quantopian blows up with out of memory or timeouts if universe contains more than 15 or so stocks. I think this algo will work well if universe is large (>50 stocks) and we select a basket of 8-10 stocks that are mean reverting.
Please play around with it and let me know if you identify any defects.