[R-sig-finance] Solve.QP

KAHRA HANNU hannu.kahra at mpsgr.it
Mon Jul 11 10:58:09 CEST 2005


Have a look at the portfolio.optim R code and how it applies solve.QP. Download the tseries version 1.9 package and unzip it. The tseries folder contains a folder called R that contains the tseries file. Have a look at the portfolio.optim function in the file.


Hannu Kahra
Progetti Speciali 
Monte Paschi Asset Management SGR S.p.A. 
Via San Vittore, 37
IT-20123 Milano, Italia 

Tel.: +39 02 43828 754
Mobile: +39 333 876 1558 
Fax: +39 02 43828 247 
E-mail: hannu.kahra at mpsgr.it 
Web: www.mpsam.it 

-----Original Message-----
From: r-sig-finance-bounces at stat.math.ethz.ch [mailto:r-sig-finance-bounces at stat.math.ethz.ch] On Behalf Of L.Isella
Sent: 10. heinäkuuta 2005 20:01
To: r-sig-finance at stat.math.ethz.ch
Subject: [R-sig-finance] Solve.QP

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: 
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)
\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

R-sig-finance at stat.math.ethz.ch mailing list

More information about the R-sig-finance mailing list