Skip to content
All library documents

Formulating Portfolio CVaR Constraints as a Linear Program

Article Quant Q&A · Author: RockScience

Summary

The discussion compares ways to optimize portfolio return while limiting Value at Risk (VaR) or Conditional Value at Risk (CVaR). It recommends treating expected return as a constraint while minimizing CVaR, and explains that scenario based CVaR can be represented with linear variables for the threshold loss and each scenario's excess loss. This makes linear programming available for portfolio risk control, including constraints applied to selected asset groups.

The answers distinguish this from VaR, which may require quadratic or other nonlinear constraints, and mention second order cone solvers and evolutionary search as alternatives. One answer gives a two step screening approach using mean variance efficient portfolios. The discussion is methodological rather than an empirical comparison: it supplies no performance results or validation data. It also cautions that scenario CVaR linear programs can become dense and large, so substantial problems may need column and constraint generation. Results depend on the return scenarios and portfolio specification.

Key ideas

  • Scenario based CVaR can be expressed through a loss threshold and excess loss variables, yielding linear constraints.
  • A return target can be paired with CVaR minimization to formulate portfolio risk control.
  • VaR constraints may require quadratic or nonlinear optimization methods.
  • Large scenario based CVaR models can become computationally demanding.
  • The suggested formulations depend on the chosen scenarios and portfolio groups.

Tags

Full text
# Portfolio optimisation with VaR or CVaR constraints using linear programming


# Portfolio optimisation with VaR or CVaR constraints using linear programming












I would like to optimize a portfolio allocation (maximizing the exposure or the expected return), but with VaR or CVaR contraints. (some parts of my portfolio cannot exceed a certain VaR)

How can I achieve that? Is there a way to turn the problem into a linear programming problem? or to approximate the results?

Any links or ideas are welcome.

## Answer by John (score 11, accepted)

https://quant.stackexchange.com/a/3938

In my experience, a VaR or CVaR portfolio optimization problem is usually best specified as minimizing the VaR or CVaR and then using a constraint for the expected return. As noted by Alexey, it is much better to use CVaR than VaR. The main benefit of a CVaR optimization is that it can be implemented as a linear programming problem. Another option I have tried is the technique in this paper:

http://www.math.uwaterloo.ca/~tfcolema/articles/bank_article.pdf

Another option is the two-step heuristic where one first finds the mean-variance efficient frontier and then you could calculate whatever are the relevant portfolio statistics on only the mean-variance efficient portfolios. In this way you could exclude portfolios that have too high a VaR or CVaR (or mixed CVaR deviation) for your consideration.

However, as you say you are particularly concerned about the VaR or CVaR of certain parts of your portfolio. As noted above, VaR constraints for different different groups of assets would require non-linear constraints. However, CVaR constraints for different assets could be calculated using linear constraints (though it would also be possible to implement a relatively slower methodology using non-linear constraints). For guidance on how to implement this as a linear constraint, it might help to follow

http://www.soa.org/library/proceedings/arch/2008/arch-2008-iss1-cox-lin.aspx

with the only difference that you would want to calculate the CVaR over the relevant groups of securities.

## Answer by David Nehme (score 9)

https://quant.stackexchange.com/a/3939

The VaR constraint is convex and quadratic and can be handled with any solver supports quadratic constraints, like Guribi, cplex (from IBM) or xpress (from FICO).

The CVaR can be formulated as a linear program if you are able to perform monte-carlo simulations on the returns. Briefly, the LP model is

\begin{eqnarray*} c &\ge& \alpha + {1 \over (1-\beta)|J|} \sum_{j\in J} z_j \\ z_j &\ge& \sum_{i \in I} r_{ij} x_i - \alpha \hspace{0.2in} \forall j \in J \end{eqnarray*} Where c is the cvar at $\beta$ confidence, $I$ is the set of investments, $x_i$ is the level of investment in $i$, $J$ is the set of monte-carlo scenarios, $r_{ij}$ is the unexpected loss of investment $i$ in simulation $j$. $\alpha$ is the loss of the $100 \cdot \beta$ percentile scenario, and ${1 \over (1-\beta)|J|} \sum_j z_j$ is the average unexpected loss (in excess of alpha) of the worst $(1-\beta)|J|$ scenarios.

The resulting LP instances are very dense and large, so it requires delayed column and constraint generation for non-trivial problems.

## Answer by Marc Shivers (score 4)

https://quant.stackexchange.com/a/3935

I think what you're looking for is a type of solver called a second-order cone program (SOCP) solver. This is just like a quadratic program (QP) solver, except the constraints can be quadratic as well as the objective function. There is an open-source implementation in python via the CVXOPT module.

## Answer by Alexey Kalmykov (score 4)

https://quant.stackexchange.com/a/3937

You can find a good example on CVaR optimization in the book "Portfolio Optimization with R/Rmetrics" By Diethelm Wuertz, Yohan Chalabi, William Chen, Andrew Ellis.

```
#load library fPortfolio
library(fPortfolio)

#use indicies LPP2005, see http://www.pictet.com/en/home/lpp_indices.html
lppData  <-  100*LPP2005.RET[,1:6]

#create portfolio specification
frontierSpec  <- portfolioSpec();

#optimization criteria - CVaR
setType(frontierSpec)  <- "CVAR"

#set optimization algorithm
setSolver(frontierSpec)  <- "solveRglpk"

#set confidence level CVaR
setAlpha(frontierSpec)  <- 0.05

#number of portfolios in efficient frontier
setNFrontierPoints(frontierSpec)  <- 25

#optimize, without shortselling
frontier <- portfolioFrontier(data = lppData, spec = frontierSpec, constraints="LongOnly");

#build efficient frontier graph
tailoredFrontierPlot(object=frontier,mText="Mean-CVaR Frontier (Long only)",risk="CVaR");
weightedReturnsPlot(frontier)
```

I don't recommend you to use VaR optimization for two reasons:

- VaR is not a subbaditive risk measure, therefore your portfolio could be highly undiversified.

- It's more challenging computationally than CVaR optimization

## Answer by Andr&#233; Christoffer Andersen (score 3)

https://quant.stackexchange.com/a/3936

You could define your optimization problem as a typical linear risk/return optimization problem(1), then use some predicted return as the return component and VaR or cVaR as the risk component. This will not be linear, however you can use an evolutionary algorithm, or some other exotic search algorithm, to maximize for return given a limit on VaR or cVar. The tricky part is to make a good utility/fitness function, i.e., a smooth one.

In essence what you will be doing is to generate a bunch of random feasible portfolios, making sure to throwing out any that have too large of a VaR. The remaining feasible portfolios are ranked based on the utility/fitness function. Keep some of the best once (survival of the fittest) and based on these make small random alterations to the portfolios (mutations). Then re-rank the portfolios. Redo this for several generations. Eventually you should be optimizing based on VaR. There are many tools and frameworks that can do this for you. I used Encog last time I did something like it.

```
(1) Utility(portfolio) = PredictedReturn(portoflio) - VaR(portoflio)
```

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.