[R-SIG-Finance] Portfolio cardinality constraints using solve.QP

Terry Griffin terry.griffin at comcast.net
Thu Mar 15 23:26:30 CET 2012

Dear List, 

There has been some interest in imposing cardinality constraints in a portfolio optimization such that optimal portfolios are constrained to a minimum and maximum number of assets; recent literature has suggested genetic algorithms. One blogger suggested how this can be accomplished with R: http://systematicinvestor.wordpress.com/2011/10/20/minimum-investment-and-number-of-assets-portfolio-cardinality-constraints/ 

However, I am not sure how this can be accomplished in portfolio.optim function from tseries (and thus solve.QP from quadprog). 

The usage for portfolio.optim does not appear to have the capability of cardinality constraints… 

portfolio.optim(x, pm = mean(x), riskless = FALSE, shorts = FALSE, rf = 0.0, reslow = NULL, reshigh = NULL, covmat = cov(x), ...) 

… so I examined the usage of solve.QP and have considered whether it would be possible to modify Amat and/or bvec to accommodate the cardinally constraint? 

solve.QP(Dmat, dvec, Amat, bvec, meq=0, factorized=FALSE)

Any suggestions on how to perform this with solve.QP or other alternative is appreciated. 

Thank you, 


Terry Griffin, Ph.D.
terry.griffin at comcast.net 

More information about the R-SIG-Finance mailing list