This was more of a one-off and was written several years ago. As such, it’s been lost in the ether.

I’m pretty busy these days, but whenever I find the chance, I might try to recreate it (and honestly reacquaint myself with it).

Best of luck!

N

This post is truly exceptional! Thanks for writing it. in the case of weights being above 1, what if I wanted not to apply a constraint but a linear penalty?

Said differently, I am willing to go above 1 when it comes to my total sum of weights only if it is very beneficial. For that reason a linear penalty would likely do the trick.

Any ideas there? ]]>

Thanks for the compliment!

Good point! I’ll respond with a hedged yes/no.

Yes, in that if you were pedantic in interpreting everything in their right units, you could say, “well, I only want half of the variance to contribute” (setting the risk-aversion parameter to 0.5).

No, in that in practice, the risk-aversion parameter is a hyper parameter you search over so the lack of multiplied-by-two gets glossed over. What I mean is that you’d permute your risk-aversion parameter, simulate/test over those permutation over some validation period, and “pick” one for which you were satisfied with the trading characteristics (whatever it may be).

All that being said, I think I’ll go ahead and change it just to cross-my-t’s-and-dont-my-i’s.

]]>(1/2)*x^T*Q*x – d^T*x

and we’re minimizing

x^T * Sigma * x – mu^T*x

shouldn’t we use Dmat = 2*Sigma, instead of Dmat = Sigma as you suggest?

Again, thanks for the post!

]]>That said, I’m revisiting math I’ve not seen in years and am picking up linear algebra on my own.

I want to expand my knowledge to more types of non-linear programming which will help me with more sophisticated types of portfolio constructions, but am having trouble with vernacular, due to lack of some foundational education. Any suggestions on resources, sites, strategies that would help me climb the curve?

Your input would be most appreciated.

]]>There’s actually a difference in how to implement that for when shorting is allowed and when it’s long only, where the latter is much easier.

Dealing with the latter case, if you look underneath the section of “No Heavy Concentration”, you’ll see that I have this line here

`bvec < - c(1, rep(0, nrow(Dmat)), rep(-0.15, nrow(Dmat)))`

Basically, I'm applying a limit of 0.15 across the entire board. If you wish for any to be zero or one, just specify the vector of limits by hand, e.g., `c(1,1,0.15,1,0,1,1,0.15)`

, where zero implies you don't want to hold a position.