Add a Zero-Beta Constraint to Mean-Variance Portfolio Optimization
Summary
The document explains how to include a zero factor-exposure requirement in a mean-variance portfolio optimization. For asset weights collected in a vector and asset betas in another vector, portfolio beta is their dot product. Setting that product to zero imposes the desired neutrality constraint alongside a budget condition and a target-return condition, while portfolio variance remains the objective to minimize.
One answer points to a portfolio optimization package with a factor-exposure constraint. Another writes the quadratic program directly, and a further example shows how equality constraints are represented in R's quadratic programming interface: each constraint contributes a coefficient vector and a right-hand-side value, with the equality count configured accordingly. The examples illustrate the formulation, but feasibility depends on the available assets, bounds, and target return; the document does not assess a particular portfolio's solution or out-of-sample behavior.
Key ideas
- Portfolio beta is the weighted sum of the assets' individual betas.
- A zero-beta constraint is expressed as the beta vector dotted with the weight vector equaling zero.
- The constraint can be combined with a budget constraint and a target-return requirement.
- In quadratic programming, equality constraints need coefficient vectors, right-hand sides, and the correct equality count.
- The optimization may be infeasible depending on asset exposures, weight bounds, and target return.
Tags
Full text
# Portfolio Optimization - Zero beta portfolio
# 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 ?
## Answer by Kyle Balkissoon (score 2)
https://quant.stackexchange.com/a/16251
Use PortfolioAnalytics
See my previous response here: https://quant.stackexchange.com/a/16002/2154 , you will find links to the documentation there.
You can use the constraint function to add a factor exposure constraint of 0.
use add.constraint(your_portfolio_name,type='factor_exposure',B = your_vector_of_betas,lower=0,upper=0)
## Answer by Wintermute (score 0)
https://quant.stackexchange.com/a/16253
Say we have $n$ assets. Suppose that the covariance matrix is $\Sigma$. Now suppose that $x$ is the vector of weights of your assets, $\mu$ is the vector of mean returns on the assets, $\mathbb{1}$ is the vector of all ones, $B$ is the vector of betas on each asset, and $\tau$ your target return. You want to solve the following quadratic program $$Min_x\;\; \frac{1}{2}x^T\Sigma x$$ Under the constraints $$x^T \mathbb{1}=1$$ $$\mu^Tx \geq \tau$$ $$B^Tx=0$$ The constraint $B^Tx=0$ will ensure that the portfolios beta is zero.
## Answer by WaltS (score 0)
https://quant.stackexchange.com/a/16259
You have the budget constaint on the sum of weights, the constraint that the portfolio return equal the target return, and the constraint on beta. With three equality constraints, you can set a row in Amat for each constraint, and then take the transpose to pass to solve.QP. bvec is set to the right-hand side of the constraint equations and the parameter meq equals the number of equality constraints. An example for you problem is shown below:
```
target_return <- 0.0002
num_assets <- 6
dvec <- rep(0,num_assets) # dvec = 0 when minimizing only the variance
Dmat <- cov(return_full)
Amat <- matrix(rep(1, num_assets), ncol=num_assets) # budget constraint: sum of wts = 1
Amat <- rbind(Amat, c(.3, .7, -.3, 1, 1.1, 1.3) ) # beta constraint: sum of wt*beta = 0
Amat <- rbind(Amat, colMeans(return_full) ) # portfolio return = target_return
# Amat <- rbind(Amat, diag(1,nrow=num_assets, ncol=num_assets) ) # would be used for long-only solutions: wts >= 0
Amat <- t(Amat)
bvec <- c(budget = 1, beta = 0, return = target_return ) # rhs of constraint eqns
# bvec <- c(bvec, rep(0,num_assets) ) # would be used with long-only constraint
qp <- solve.QP(Dmat, dvec, Amat, bvec, meq=3)
```Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.