0

I have a portfolio of weights I am using quadprog in matlab. I have all the inputs for the quadprog optimizer. I am just having some trouble formulating the constraints

I would like my constraints to have a lower bound of either 0 or 1%, is there a way to do that while maintainng my objective function

Thanks!

qfd
  • 778
  • 2
  • 10
  • 24

1 Answers1

0

I am not sure if I understand your question well.

If your weights are already defined in terms of percentage, it is directly the definition of quadprog:

x = quadprog(H, f, [], [], [], [], lb, [])

So H, e, and f should be provided by the matlab description of:

quadprog(H,f) - returns a vector x that minimizes 1/2 * x' * H * x + f' * x. H must be positive definite for the problem to have a finite minimum."

And lb is a vector of the constraints. For instance if x is a vector 3 x 1, then lb = [0.01; 0.01; 0.01] in the case of the desired percentage is 0.01 (1%)

On the other hand, lets assume the sum_{i=1}^{n} w_i is not equal to 1. Therefore, w_i is not defined in terms of percentage.

Therefore, the constraint that you need is p_i (percentage)= w_i / (sum w_i) >= 0.01 (in the case of the lower bound be 1%).

Note that the constraint in this case is

w_i >= 0.01 * (sum w_i)

Or

-0.01 * (sum_{j=1}^{i-1} w_j) + 0.99 * w_i - 0.01 * (sum_{j=i+1}^{n} w_j) >= 0

Or

0.01 * (sum_{j=1}^{i-1} w_j) - 0.99 w_i + 0.01 * (sum_{j=i+1}^{n} w_j) <= 0

Therefore, this is a constraint of the type Ax <= b.

So

A_ij = 0.01 when i is different from j

A_ij = -0.99 when i = j and b = zeros(n, 1)

In this case you are using

x = quadprog(H, f, A, b)

I hope I helped you!

Daniel

mkierc
  • 1,193
  • 2
  • 15
  • 28
DanielTheRocketMan
  • 3,199
  • 5
  • 36
  • 65
  • Hi Daniel, I am trying to set the minimum to be either 1% or 0 nothing in between..Thats what I am struggling with – qfd Feb 13 '14 at 17:24
  • @hdg I am not understanding what u want or you are not understanding my solution above. Considere the case that all the weights are larger than 2% for instance. In this case, the constrained and the unconstrained problem have the same solutions. Now imagine the situation that the unconstrained problem has a weight equal to 0.5% and your constraint is 1%. So the unconstrained solution is not acceptable. So the constrained problem should consider the constraints presented above. I am not assuming that the lower bound is a number between 0 and 1%. If you have doubts about above, just ask! – DanielTheRocketMan Feb 14 '14 at 01:32
  • @hdg (continuation) Above I am assuming that either the weights are unconstrained or they are larger than 1% or larger than 0%; I am NOT assuming that they are larger than 0.5% for instance. – DanielTheRocketMan Feb 14 '14 at 01:35