-1

Yet another portfolio optimization question...

Im trying to maximize the return of a portfolio of four assets given the restrictions sum(P) = 1, MaxW <= 0.55 and MinW >= 0.05 using quadprog.

The average returns over the period are

avgR <- c(0.0008990382, 0.0002285502, 0.0001120934, 0.0001540948) 

while the covariance matrix is

covM <-  matrix(c(2.876044e-04, 6.758444e-05, 4.382673e-05, 1.167429e-04,
                6.758444e-05, 2.331315e-04, 5.797771e-05, 1.087006e-04,
                4.382673e-05, 5.797771e-05, 2.568974e-04, 8.544499e-05,
                1.167429e-04, 1.087006e-04, 8.544499e-05, 2.085108e-03), ncol=4)

I have come this far

require(quadprog)

nAssets <- length(avgR)
Dmat <- 2 * covM

upperB <- 0.55
lowerB <- 0.05
ub <- rep(upperB, nAssets)
lb <- rep(lowerB, nAssets)

dvec <- avgR

Amat <- rbind(1, diag(nAssets), -diag(nAssets))

bvec <- c(1, lb, -ub)

solve <- solve.QP(Dmat = Dmat, dvec = dvec, Amat = t(Amat), bvec = bvec, meq = 1)
solve$solution

Which returns

0.55000000 0.33032755 0.06967245 0.05000000

as optimal allocation.

Using the same data in Excel I get another solution (with a higher return);

0.55 0.35 0.05 0.05

However, setting the upper bound to 0.65 both R and Excel return the same solution;

0.65 0.25 0.05 0.05

What am I missing?

Pierre
  • 671
  • 8
  • 25

1 Answers1

0

I solved it by setting

dvec <- avgR * 100

so it seems to be some rounding error...

Pierre
  • 671
  • 8
  • 25