2

I'm using CVXOPT to do quadratic programming to compute the optimal weights of a potfolio using mean-variance optimization. There is a great example at http://abel.ee.ucla.edu/cvxopt/userguide/coneprog.html#quadratic-programming. However, the arguments are in a regularized form (according to the author). The example is a basic version. I am looking to do a bit of a more complex problem where:

min:

x'Sx  

s.t.:

x'a >= g  
x'1 = 0  
x >= -Wb  
x <= c1 - Wb  

where:
x: active weights of assets (active weight = portfolio weight - benchmark weight)  
S: covariance matrix of asset returns  
a: expected stock excess returns  
g: target gain  
Wb: weights of assets in the benchmark  
c: upper limit (weight) of any asset in the portfolio  

Assume all the variables are computed or known.

The basic example presented in the documentation:

min:  

x'Sx  

s.t.  

p'x >= g  
1'x = 1

Where p are the asset returns.

What I do not know (referring to the code at http://abel.ee.ucla.edu/cvxopt/examples/book/portfolio.html and optimization problem above):

1.I think these arguments setup the constraints but I'm not entirely sure:

G = matrix(0.0, (n,n))
G[::n+1] = -1.0
h = matrix(0.0, (n,1))
A = matrix(1.0, (1,n))
b = matrix(1.0)

2.I believe this is part of the minimization problem in "regulated form", which I'm not sure what means:

mus = [ 10**(5.0*t/N-1.0) for t in xrange(N) ]

3.What the arguments to qp are (solver.qp is the quadratic optimizer):

xs = [ qp(mu*S, -pbar, G, h, A, b)['x'] for mu in mus ]

Looking at the documentation, I'm pretty sure that mu*S (the first argument) is the objective function to be minimzed and -pbar are the returns. This looks like a maximization problem however (maximizing negative returns).

I do not know, however how the other arguments are used.

I am looking for help using the optimizer given my minimization problem and constraints above.

Jason Strimpel
  • 14,670
  • 21
  • 76
  • 106

1 Answers1

1

I read the docs and I think you have to use the function with the following parameters. I assume that x has size n:

P = S
q = (0,....0)

A = (1, ...... 1)
b = (0)

G is vertically stacked from

 -a
 +I_n
 -I_n

where I_n is the identity matrix of size n x n . And the corresponding right hand side h is

  -g
  Wb
  ...
  Wb
  C1-Wb
  ...
  C1-Wb

That is: one -g, n times Wb and n times C1-Wb.

HTH.

rocksportrocker
  • 7,251
  • 2
  • 31
  • 48
  • Thanks for the response, but I'm not following for `G` and `h`... For `G`, what do you mean `-a, ... -a`? and `+I_n`? For `h`, I'm not clear at all. Also, what is your logic for your thoughts? – Jason Strimpel Sep 27 '11 at 20:47
  • I just formulated your problem so that it matches the specification given by your link to cvxopt. – rocksportrocker Sep 28 '11 at 05:15
  • -a .... -a was wrong. I_n is the identity matrix of size n, that is the matrix is zero outside the diagonl. The diagonal contains only ones. – rocksportrocker Sep 28 '11 at 05:17
  • h is a vector. it's entries are given as I described it. The first entry is -g, then n times Wb, then n times "C1-Wb" – rocksportrocker Sep 28 '11 at 05:18