[R-SIG-Finance] Static Portfolio Optimization
Jorge Nieves
jorge.nieves at moorecap.com
Thu Oct 1 22:33:59 CEST 2009
Thanks for your responses. I found the function "portfolio.optim" and
the tseries series package and a document with explanations. The
function indeed allows for shorts. However, I still do not see how to
pass into the function the vector of expected values and the covariance
matrix. The function's input is the time series themselves. It seems
that the function internally computes both the expected values and the
covariance matrix, and then it performs the optimization. Please
correct me if I am not reading right the function description and its
specifications.
Thanks,
Jorge Nieves
-----Original Message-----
From: Dirk Eddelbuettel [mailto:edd at debian.org]
Sent: Thursday, October 01, 2009 04:25 PM
To: markleeds at verizon.net
Cc: Jorge Nieves; r-sig-finance at stat.math.ethz.ch;
jessevel at andrew.cmu.edu
Subject: Re: [R-SIG-Finance] Static Portfolio Optimization
On 1 October 2009 at 15:01, markleeds at verizon.net wrote:
| I think I remember Adrian Trapletti implemented static portfolio
| optimization using quadprog in tseries. It's been a long time so I
| don't remember the details ( it may be restricted to long only but you
| can add variables to make<br />it handle long short ) but you may want
| to check tseries out.
Correct -- the tseries package has done since time immportal.
And some seven or eight years ago I sent Adrian a patch, styled after
the discussion in Huang and Litzenberger, that adds the ability to have
long and short positions.
Which Adrian promptly added and which has been there ever since:
R> head(as.zoo(EuStockMarkets))
DAX SMI CAC FTSE
1991(130) 1629 1678 1773 2444
1991(131) 1614 1688 1750 2460
1991(132) 1607 1679 1718 2448
1991(133) 1621 1684 1708 2470
1991(134) 1618 1687 1723 2485
1991(135) 1611 1672 1714 2467
R> X <- diff(log(as.zoo(EuStockMarkets)))
R> res <- portfolio.optim(X) ## Long only
R> res$pw
[1] 0.0000 0.3958 0.0000 0.6042
R> res <- portfolio.optim(X, shorts=TRUE) ## Long/Short
R> res$pw
[1] 0.02550 0.38213 -0.06377 0.65614
R>
This is arguably a better example than the one in help(portfolio.optim)
so maybe I should send Kurt a new patch :)
Dirk
--
Three out of two people have difficulties with fractions.
More information about the R-SIG-Finance
mailing list