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

alexios ghalanos alexios at 4dscape.com
Fri Mar 16 08:19:26 CET 2012


Cardinality constraints require binary variables (mixed integer solver) 
and you cannot achieve this with the standard quadprog package. The 
blogger whose url reference you cite makes use of a branch and bound 
(BNB) algorithm to achieve this which is available from his git repository.
For a more general review of the BNB with QP method for cardinality 
constrained portfolios see:
http://www.mit.edu/~dbertsim/papers/Optimization/Algorithm%20For%20Cardinality-Constrained%20Quadratic%20Optimization.pdf

Regards,
Alexios


On 15/03/2012 22:26, Terry Griffin wrote:
>
> 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
>
>
> Terry Griffin, Ph.D.
> terry.griffin at comcast.net
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.



More information about the R-SIG-Finance mailing list