[R-sig-finance] Solve.QP

L.Isella L.Isella at myrealbox.com
Sun Jul 10 20:00:40 CEST 2005


Dear All,
I am starting to use R for portfolio optimization.
I found the portfolio.optim package in tseries very useful, since it allows the user to use both the historical data to create the covariance matrix or to provide it directly.
However, I would like not to simply use it as a black box. Portfolio.optim relies on solve.QP.
Now, a typical problem in portfolio management is to minimize the variance of the portfolio: 
/frac{1}{2}W^T%*%CovMat%*%W,
where CovMat is the covariance matrix of my portfolio, W is the vector of the (unknown) weights.
The constraints are:
\sum_i W_i=1 (the portfolio is totally invested)
and 
\sum_i W_i\mu_i=\mu (\mu is the required variance of my portfolio, W_i and \mu_i the weight and the expected return of the i-th asset, respectively).
Then I could e.g. impose W_i>=0 for all i (no short-selling allowed).
Is it straightforward to implement these constraints on the weights as 
A%*%W>= b, where A is a matrix and b a vector?
Maybe it is a naive question and I am just trying to re-invent the wheel, but I will be grateful to anyone who can help clarify these issues to me.
Best Regards
Lorenzo



More information about the R-sig-finance mailing list