Minimum tracking error portfolio optimization problem and lite backtest Here is the full PDF of the IPython notebook and a zip file of the IPython notebook and supporting files themselves. Note that the notebook requires a recent GitHub snapshot of statsmodels. I also use the quadratic programming solver in CVXOPT for the portfolio optimization application: if you don't have CVXOPT, you can change it to use the brute force BFGS optimizer (though it's about 50x slower).
See my prior blog post with some more details about installing and getting set up with the IPython notebook.