This is an update on the OLMAR algorithm Grant and I have been working on over the last couple of months. We've been continuously updating and fixing bugs. I now went over the whole logic in detail and am highly confident that the implementation is correct.
The idea of the algorithm is that if a price of a stock diverged from its mavg, it will eventually revert to it (i.e. mean reversion). The portfolio is rebalanced in accordance to that. In more detail, the algorithm is finding the optimal portfolio weighting to maximize profits under the mean-reversion assumption. By doing so, the algo essentially implements a follow-the-loser strategy.
Secondly, this now uses the new set_universe() feature to remove selection bias. The algorithm needed to be changed a little bit to adjust for the changes in portfolio size which adds some complexity. Another problem is that the portfolio does not take into account that the sids can change. Maybe for each quarter the portfolio should be equally rebalanced? In any case though, this is a great feature as one can't just chose AAPL and go to town. I think it leads to more honest backtesting.
The paper describing the algorithm, which is one of my favorites so far, can be found here:
http://icml.cc/2012/papers/168.pdf
After thinking long and hard about it, there is actually a very nice intuitive understanding of what each term does. This previous paper goes into more detail about the intutions (the algorithm is not the same but the ideas are very similar):
http://www.cais.ntu.edu.sg/~chhoi/paper_pdf/PAMR_ML_final.pdf
There is a previous thread with discussions with the author of that paper here:
https://www.quantopian.com/posts/olmar-implementation-fixed-bug (note that this implementation contained a bug).
Ideas for improvements:
* Change mavg() to vwap(): high-volume stocks tend to be more volatile and the algorithm is prone to invest more into highly fluctuating stock.
* Change eps parameter: This is a critical parameter that adjusts how aggressively the portfolio gets rebalanced. Values closer to 1 are more conservative while a value like 5 leads to an allocation that puts everything into one basket.