This is an adaptation of the algorithm described in:
Li, Bin, and Steven HOI. "On-Line Portfolio Selection with Moving Average Reversion." The 29th International Conference on Machine Learning (ICML2012), 2012.
http://icml.cc/2012/papers/168.pdf
To solve the portfolio optimization problem, it uses the Python module scipy.optimize.minimize instead of the analytic solution applied by the author.
Please note that the backtest is biased by the selection of some high-performance securities (i.e. intentional look-ahead bias).
Some things to try:
- Different securities
- Change the value of epsilon
context.eps = 1.005 # change epsilon here
- Change the length of the trailing window of prices:
prices = history(10,'1d','price').as_matrix(context.stocks)[0:-1,:]
- Re-allocate but don't re-balance, by changing to:
if np.dot(res.x,x_tilde) - context.eps > 0: rebalance_portfolio(context,allocation) else: return
- Compare the result to the algorithm used in the paper (do a Quantopian forum search on 'OLMAR' for applicable code)
Grant