After a nudge in the right direction from Grant Kiehne I made a new version of a minimum variance portfolio. It uses a Lagrangian to solve for the weights that minimize the variance. I used returns on the vwap for everything and the portfolio was randomly generated.
I'm not a huge fan of shorts so I added context.allow_shorts, which if False, the algo will use non-negative least squares regression to solve the Lagrangian. I also added the ability to re-invest cash but I'm thinking there's a cleaner way to do it. Ideas?
I'm pretty happy with the results I've seen so far, I'm gonna have to port it over to min data at some point to start paper trading. Does anybody have any idea how to stop that negative cash dip on the first day it invests? I commented out what I tried (line 51).
Dave