I have my input parameters mu (mean vector μ), Q (covariance matrix Q), and tau (risk tolerance τ) and I need to return the vector h (asset weights) that maximizes the following utility function U defined by:
U(h)= −1/2h^T*Q*h + τ*h^T*μ
subject to constraints:
0 ≤ h ≤ 0.1 for all h
and sum of all h is equal to 1: h^T*e = 1
TAU contains numbers from zero to 0.5 in steps of 0.001. How do I define the parameters: Dmat, dvec, Amat and bvec for this problem? I know the finance concepts but not how to program it correctly.
Thank you
This doesn't work as I still have negative weights indicative of short selling :(
frontieropti <- c(NULL)
i <- 1
for (i in 1:nrow(TAU)){
solQP <- solve.QP(Dmat,TAU[i]*mu, Amat, bvec, meq = 1, factorized = F)
sol <- c(i,solQP$value)
frontieropti <- rbind(frontieropti,sol)
i <- i +1
}
solQP <- solve.QP(Dmat, TAU[1]*mu, Amat, bvec, meq = 1, factorized = F)
solQP