[R-SIG-Finance] Static Portfolio Optimization

Dirk Eddelbuettel edd at debian.org
Thu Oct 1 22:25:08 CEST 2009


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