In portfolio optimization forcing that 2 instrument can't be selected simultaneously

31 views
Skip to first unread message

Tal Shir

unread,
Mar 11, 2015, 7:45:11 AM3/11/15
to yal...@googlegroups.com
Hello,
In a Sharpe ratio maximization problem I want to find a way to constrain that if 1 specific security is selected another security must have a weight of zero. So both securities can't be allocated at the same instance.
Let me know if you have an idea...

This is how I'm doing it now but I'm sure there is a more efficient way to do it.
So the idea is that z(16) and z(18) can't be selected at the same time.

 Sharpe = [0 <= z, z'*(r) == 1,z(13)<=0.25*sum(z),z(16)*z(18)<=0.00001]; 
 optimize(Sharpe, z'*PCov*z);
  wS = value(z)/sum(value(z));

Thanks a lot!!
Tal

Johan Löfberg

unread,
Mar 11, 2015, 12:59:24 PM3/11/15
to yal...@googlegroups.com
I presume you actually have a more complex model. If it is just two securities which cannot be selected at the same time, simply solve two optimization problems where each one of them is set to 0.

In the general case, your nonlinear nonconvex formulation is not a good strategy (if you want to aim for a globally optimal solution). Much likely much better to pose it as a mixed-integer quadratic program, along the lines of

select = binvar(2,1);
Sharpe = [..., z(16) <= select(1), z(18) <= select(2), sum(select) == 1]

Likewise, YALMIP automatically will create an integer model if you simply use complements

Sharpe = [..., complements(z(16)>=0, z(18)>=0]

You might have to add an explcicit upper bound on z (z<=1) for YALMIP to derive a nice big-M model.

Tal Shir

unread,
Mar 11, 2015, 5:52:07 PM3/11/15
to yal...@googlegroups.com
Great,
Thanks a lot for this
Tal

Reply all
Reply to author
Forward
0 new messages