Saturday, May 23, 2015

r - Portfolio Optimization - Zero beta portfolio


I am trying to solve a optimization portfolio in R in which I do the following constraints:




  • Set weight sum to within a boundary

  • Set return to a certain value

  • Set portfolio beta to 0


The purpose is then to minimize risk subject to the constraints above.


While I have no trouble in doing that my issue comes next. I want to make the weights such that the portfolio's total exposure to a factor is 0. Imagine asset a has a beta of 0.3, asset b has 0.7 and asset c -0.3. How can I set this constraint? My issue is that using quadprog I can only add an external parameter vector(mean returns in this case). Is there a way to go around this issue or am i seeing thing s the wrong way?


The code I have so far is as follows :


6 assets and six mean returns. Also, a 6*6 var-cov matrix. The upper weight bound is lev_ub and the lower bound is lev_lb. Returns_full is the vector with returns.


dvec = matrix(colMeans(returns_full),ncol = 1)
Dmat = cov(returns_full)

A.Constraint1 <- matrix(c(1,1,1,1,1,1), ncol=1)
A.Constraint2 = matrix(c(1,1,1,1,1,1), ncol=1)
Amat <- cbind(A.Equality1,A.Equality2, dvec)
bvec <- c(-lev_ub,lev_lb,target_return)
qp <- solve.QP(Dmat, dvec, Amat, bvec, meq=0)

My issue comes now from the fact that assume I have another vector of length 6 with one beta for each asset. I want to make it such that the sum of the product of weights and betas is zero or,in other words, set the total portfolio beta to 0. How can I add this constraint ?




No comments:

Post a Comment

technique - How credible is wikipedia?

I understand that this question relates more to wikipedia than it does writing but... If I was going to use wikipedia for a source for a res...