8 Other risk measures

In the definitions (2.1)-(2.4) of the classical MVO problem the variance (or standard deviation) of portfolio return is used as the measure of risk, making computation easy and convenient. If we assume that the portfolio return is normally distributed, then the variance is in fact the optimal risk measure, because then MVO can take into account all information about return. Moreover, if T is large compared to N, the sample mean and covariance matrix are maximum likelihood estimates (MLE), implying that the optimal portfolio resulting from estimated inputs will also be a MLE of the true optimal portfolio [Lau01].

Empirical observations suggest however, that the distribution of linear return is often skewed, and even if it is elliptically symmetric, it can have fat tails and can exhibit tail dependence [1]. As the distribution moves away from normality, the performance of a variance based portfolio estimator can quickly degrade.

No perfect risk measure exists, though. Depending on the distribution of return, different measures can be more appropriate in different situations, capturing different characteristics of risk. Return of diversified equity portfolios are often approximately symmetric over periods of institutional interest. Options, swaps, hedge funds, and private equity have return distributions that are unlikely to be symmetric. Also less symmetric are distributions of fixed-income and real estate index returns, and diversified equity portfolios over long time horizons [MM08].

The measures presented here are expectations, meaning that optimizing them would lead to stochastic optimization problems in general. As a simplification, we consider only their sample average approximation by assuming that a set of linear return scenarios are given.

8.1 Deviation measures

This class of measures quantify the variability around the mean of the return distribution, similar to variance. If we associate investment risk with the uncertainty of return, then such measures could be ideal.

Let X,Y be random variables of investment returns, and let D be a mapping. The general properties that deviation measures should satisfy are [RUZ06]:

  1. Positivity: D(X)0 with D(X)=0 only if X=cR,

  2. Translation invariance: D(X+c)=D(X), cR,

  3. Subadditivity: D(X+Y)D(X)+D(Y),

  4. Positive homogeneity: D(cX)=cD(X), c0

Note that positive homegeneity and subadditivity imply the convexity of D.

8.1.1 Robust statistics

A group of deviation measures are robust statistics. Maximum likelihood estimators are highly sensitive to deviations from the assumed distribution. Thus if the return is not normally distributed, robust portfolio estimators can be an alternative. These are less efficient than MLE for normal distribution, but their performance degrades less quickly under departures from normality. One suitable class of estimators to express portfolio risk are M-estimators [VD09]:

Dδ(Rx)=minqE[δ(Rxq)],

where δ is a convex loss function with unique minimum at zero. It has the sample average approximation minq1Tk=1Tδ(xTrkq).

8.1.1.1 Variance

Choosing δvar(y)=12y2 we get Dδvar, a different expression for the portfolio variance. The optimal q in this case is the portfolio mean return μx. This gives us a way to perform standard mean–variance optimization directly using scenario data, without the need for a sample covariance matrix:

(8.1)minimize12Tk=1T(xTrkq)2subject toxF.

By defining new variables tk+=max(xTrkq,0) and tk=max(xTrk+q,0), then using Sec. 13.1.1.1 (Maximum function) we arrive at a QO model:

(8.2)minimize12Tt+2+12Tt2xTRq=t+t,t+,t0,subject toxF,

where R=[r1,,rT] is the scenario matrix, where each column is a scenario. The norms can be further modeled by the rotated quadratic cone; see in Sec. 13.1.1.9 (Squared Euclidean norm). While this formulation does not need covariance estimation, it can still suffer from computational inefficiency because the number of variables and the number of constraints depend on the sample size T.

8.1.1.2 α-shortfall

Choosing δsf,α(y)=αymin(y,0) or equivalently δsf,α(y)=αmax(y,0)+(1α)max(y,0) for α(0,1) will give the α-shortfall Dδsf,α studied in [Lau01]. The optimal q will be the α-quantile of the portfolio return. α-shortfall is a deviation measure with favorable robustness properties when the portfolio return has an asymmetric distribution, fat tailed symmetric distribution, or exhibits multivariate tail-dependence. The α parameter adjusts the level of asymmetry in the δ function, allowing us to penalize upside and downside returns differently.

Portfolio optimization using sample α-shortfall can be formulated as

(8.3)minimizeαTk=1T(xTrkq)1Tk=1Tmin(xTrkq,0)subject toxF

By defining new variables tk=max(xTrk+q,0), and model accoring to Sec. 13.1.1.1 (Maximum function) we arrive at an LO model:

(8.4)minimizeα(xTμq)+1Tk=1TtktxTrk+q,t0,subject toxF.

A drawback of this model is that the number of constraints depends on the sample size T, resulting in computational inefficiency for large number of samples.

For elliptically symmetric return distributions the α-shortfall is equivalent to the variance in the sense that the corresponding sample portfolio estimators will be estimating the same portfolio. In fact for normal distribution, the α-shortfall is proportional to the portfolio variance: Dδsf,α=ϕ(qα)αDδvar, where ϕ(qα) is the value of the standard normal density function at its α-quantile.

However when return is symmetric but not normally distributed, the sample portfolio estimators for α-shortfall can have less estimation error than sample portfolio estimators for variance.

8.1.1.3 MAD

A special case of α-shortfall is for α=0.5. The function δMAD(y)=12|y| gives us DδMAD, which is called the mean absolute deviation (MAD) measure or the L1-risk. For this case the optimal q will be the median of the portfolio return, and the sample MAD portfolio optimization problem can be formulated as

(8.5)minimize12Tk=1T|xTrkq|subject toxF.

After modeling the absolute value based on Sec. 13.1.1.3 (Absolute value) we arrive at the following LO:

(8.6)minimize12Tk=1Ttksubject toxTRqt,xTRqt,xF,

where R is the return data matrix with one observation rk, k=1,,T in each column. Note that the number of constraints in this LO problem again depends on the sample size T.

For normally distributed returns, the MAD is proportional to the variance: DδMAD=2πDδvar.

The L1-risk can also be applied without minimizing over q. We can just let q to be the sample portfolio mean instead, i. e., q=xTμ [KY91].

8.1.1.4 Risk measure from the Huber function

Another robust portfolio estimator can be obtained for the case of symmetric return distributions using the Huber function

δH(y)={y2,|y|c2c|y|c2,|y|>c,

yielding the risk measure DδH. A different form of the Huber function is δH(y)=minuu2+2c|yu|, which leads to a QO formulation:

(8.7)minimize1Tk=1Tuk2+1Tk=1T2c|xTrkquk|subject toxF.

Modeling the absolute value based on Sec. 13.1.1.3 (Absolute value) we get

(8.8)minimize1Tk=1Tuk2+1Tk=1T2ctksubject toxTRqut,xTRqut,xF.

Note that the size of this problem depends on the number of samples T.

8.1.2 Downside deviation measures

In financial context many distributions are skewed. Investors might only be concerned with negative deviations (losses) relative to the expected portfolio return μx, or in general with falling short of some benchmark return rbm. In these cases downside deviation measures are more appropriate.

A class of downside deviation measures are lower partial moments of order n:

LPMn(rbm)=E(max(rbmRx,0)n),

where rbm is some given target return. The discrete version of this measure is k=1Tpkmax(rbmxTrk,0)n, where rk is a scenario of the portfolio return Rx occurring with probability pk.

We have the following special cases:

  • LPM0 is the probability of loss relative to the target return rbm. LPM0 is an incomplete measure of risk, because it does not provide any indication of how severe the shortfall can be, should it occur. Therefore it is best used as a constraint while optimizing for a different risk measure. This way LPM0 can still provide information about the risk tolerance of the investor.

  • LPM1 is the expected loss, also called target shortfall.

  • LPM2 is called target semi-variance.

While lower partial moments only consider outcomes below the target rbm, the optimization still uses the entire distribution of Rx. The right tail of the distribution (representing the outcomes above the target) is captured in the mean μx of the distribution.

The LPMn optimization problem can be formulated as [Lau01]

(8.9)minimizek=1Tpkmax(rbmxTrk,0)nsubject toxF.

If we define the new variables tk=max(rbmxTrk,0), then for n=1 we arrive at an LO and for n=2 we arrive at a QO problem:

(8.10)minimizek=1Tpk(tk)nsubject totrbmxTR,t0,xF,

where t is T dimensional vector. Thus there will be N+T variables, and the number of constraints will also depend on the sample size T.

Contrary to the variance, LPMn measures are consistent with more general classes of investor utility functions, and assume less about the return distribution. Thus they better reflect investor preferences and are valid under a broader range of conditions [Har91].

However, LPMs are only useful for skewed distributions. If the return distribution is symmetric, LPM1 and LPM2 based portfolio estimates will be equivalent to MAD and variance based ones. In particular the MAD for a random variable with density f(x) will be the same as LPM1 of a random variable with density f(x)+f(x). Also, the mean-LPM optimization model is very sensitive to the changes in the target value.

8.2 Tail risk measures

Tail risk measures try to capture the risk of extreme events. The measures described below are commonly defined for random variables treating loss as positive number, so to apply them on security returns R we have to flip the sign and define loss as L=R.

Let X,Y be random variables of investment losses, and let τ be a mapping. The formal properties that a reasonable tail risk measure should satisfy are the following [FS02]:

  1. Monotonicity: If XY, then τ(X)τ(Y),

  2. Translation invariance: τ(X+m)=τ(X)+m, mR,

  3. Subadditivity: τ(X+Y)τ(X)+τ(Y),

  4. Positive homogeneity: τ(cX)=cτ(X), c0

If τ satisfies these properties then it is called coherent risk measure. If we relax condition 3 and 4 to the property of convexity, then we get the more general class of convex risk measures. Not all risk measures used in practice satisfy these properties, violation of condition 1 and/or 2 is typical. However, in the context of portfolio selection these are less critical, the property of convexity is most important to achieve risk diversification [Lau01].

8.2.1 Value-at-Risk

Denote the α-quantile of a random variable L by qα(L)=inf{x|P(Lx)α}. If L is the loss over a given time horizon, then the value-at-risk (VaR) of L with confidence level α (or risk level 1α) is defined to be

VaRα(L)=qα(L).

This is the amount of loss (a positive number) over the given time horizon that will not be exceeded with probability α. However, VaR does not give information about the magnitude of loss in case of the 1α probability event when losses are greater than qα(L). Also it is not a coherent risk measure (it does not respect convexity property), meaning it can discourage diversification. [2] In other words, portfolio VaR may not be lower than the sum of the VaRs of the individual securities.

8.2.2 Conditional Value-at-Risk

A modification of VaR that is a coherent risk measure is conditional value-at-risk (CVaR). CVaR is the average of the 1α fraction of worst case losses, i. e., the losses equal to or exceeding VaRα(L). Its most general definition (applicable also for loss distributions with possible discontinuities) can be found in [RU02]. Let λα=11α(P(Lqα(L))α). Then the CVaR of L with confidence level α will be

CVaRα(L)=λαqα(L)+(1λα)E(L|L>qα(L)),

which is a linear combination of VaR and the quantity called mean shortfall. The latter is also not coherent on its own.

If the distribution function P(Lq) is continuous at qα(L) then λα=0. If there is discontinuity and we have to account for a probability mass concentrated at qα(L), then λα is nonzero in general. This is often the case in practice, when the loss distribution is discrete, for example for scenario based approximations.

8.2.2.1 CVaR for discrete distribution

Suppose that the loss distribution is described by points q1<<qT with nonzero probabilities p1,,pT, and iα{1,,T} is the index such that i=1iα1pi<αi=1iαpi. Then VaRα(L)=qiα and

(8.11)CVaRα(L)=λαqiα+(1λα)1i>iαpii>iαpiqi==11α((i=1iαpiα)qiα+i>iαpiqi),

where λα=11α(i=1iαpiα). As a special case, if we assume that pi=1T, i. e., we have a sample average approximation, then the above formula simplifies with iα=αT.

It can be seen that VaRα(L)CVaRα(L) always holds. CVaR is also consistent with second-order stochastic dominance (SSD), i. e., the CVaR efficient portfolios are the ones actually preferred by some wealth-seeking risk-averse investors.

8.2.2.2 Portfolio optimization with CVaR

If we substitute portfolio loss scenarios into formula (8.11), we can see that the quantile (RTx)iα will depend on x. It follows that the ordering of the scenarios and the index iα will also depend on x, making it difficult to optimize. However, note that formula (8.11) is actually the linear combination of largest elements of the vector q. We can thus apply Sec. 13.1.1.5 (Linear combination of largest elements) to get the dual form of CVaRα(L), which is an LO problem:

(8.12)minimizet+11αpTusubject tou+tq,u0.

Note that problem (8.12) is equivalent to

(8.13)mint t+11αipimax(0,qit).

This convex function (8.13) is exactly the one found in [RU00], where it is also proven to be valid for continuous probability distributions as well.

Now we can substitute the portfolio return into q, and optimize over x to find the portfolio that minimizes CVaR:

(8.14)minimizet+11αpTusubject tou+tRTx,u0,xF.

Because CVaR is represented as a convex function in formula (8.13), we can also formulate an LO to maximize expected return, while limiting risk in terms of CVaR:

(8.15)maximizeμTxsubject tot+11αpTuγ,u+tRTx,u0,xF.

The drawback of optimizing CVaR using problems (8.14) or (8.15) is that both the number of variables and the number of constraints depend on the number of scenarios T. This can make the LO model computationally expensive for very large number of samples. For example if the distribution of return is not known, we might need to obtain or simulate a substantial amount of samples, depending on the confidence level α.

8.2.3 Entropic Value-at-Risk

A more general risk measure in this class is the entropic value-at-risk (EVaR). EVaR is also a coherent risk measure, with additional favorable monotonicity properties; see in [AJ12]. It is defined as the tightest upper bound on VaR obtained from the Chernoff inequality:

(8.16)EVaRα(L)=infs>01slog(ML(s)1α),

where ML(s)=E(esL) is the moment generating function of L. The EVaR incorporates losses both less and greater than the VaR simultaneously, thus it always holds that CVaRα(L)EVaRα(L).

8.2.3.1 EVaR for discrete distribution

Based on the definition (8.16), the discrete version of the EVaR will be

(8.17)EVaRα(L)=infs>01slog(ipiesqi1α),

We can make formula (8.17) convex by substituting a new variable t=1s:

(8.18)EVaRα(L)=inft>0tlog(ipieqi/t)tlog(1α).

We can transform formula (8.18) into a conic optimization problem by substituting the first term of the objective with a new variable z and adding the new constraint zEVaRα(L). Then we apply the rule Sec. 13.1.1.15 (Perspective of log-sum-exp):

(8.19)minimizeztlog(1α),subject toi=1Tpiuit,(ui,t,qiz)Kexp, i=1,,T,t0.

8.2.3.2 Portfolio optimization with EVaR

Now we can substitute the portfolio return into q, and optimize over x to find the portfolio that minimizes EVaR:

(8.20)minimizeztlog(1α)subject toi=1Tpiuit,(ui,t,riTxz)Kexp, i=1,,T,t0,μTxrmin,xF.

Because EVaR is represented as a convex function (8.18), we can also formulate a conic problem to maximize expected return, while limiting risk in terms of EVaR:

(8.21)maximizeμTxsubject toztlog(1α),γ,i=1Tpiuit,(ui,t,riTxz)Kexp, i=1,,T,t0,xF.

A disadvantage of the EVaR conic model is that it still depends on T in the number of exponential cone contraints.

Note that if we assume the return distribution to be a Gaussian mixture, we can find a different approach to computing EVaR. See in Sec. 8.3.2 (EVaR using Gaussian mixture return).

8.2.4 Relationship between risk measures

Suppose that τ(X) is a coherent tail risk measure that additionally satisfies τ(X)>E(X). Suppose also that D(X) is a deviation measure that additionally satisfies D(X)E(X) for all X0. Then these subclasses of risk measures can be related through the following identities:

(8.22)D(X)=τ(XE(X))τ(X)=D(X)E(X)

For example, α-shortfall and CVaR is related this way. Details can be found in [RUZ06].

8.2.5 Practical considerations

Many risk measures in this chapter can be computed in practice through scenario based approximations. The relevant optimization problems can then be conveniently formulated as LO or QO problems. The advantage of these models is that they do not need a covariance matrix estimate. The simplification of the problem structure, however, comes at the cost of increasing the problem dimension by introducing a number of new variables and constraints proportional to the number of scenarios T.

If T is large, this can lead to computational burden not only because of the increased number of variables and constraints, but also because the scenario matrix R also depending on T becomes very non-sparse, making the solution process less efficient.

If T is too small, specifically T<N, then there will be fewer scenarios then parameters to estimate. This makes the portfolio optimization problem very imprecise, and prone to overfit the data. Also depending on other constraints, solution of LO problems can have computational difficulties. To mitigate this, we can use regularization methods, such as L1 (lasso) or L2 (ridge) penalty terms in the objective:

(8.23)minimizeRx+λxxprippsubject toμTxR,1Tx=1,

where Rx is the portfolio risk, xpri is a prior portfolio, and λ is the regularization strength parameter. The penalty term will ensure that the extreme deviations from the prior are unlikely. Thus λ basically sets the investor confidence in the portfolio xpri. Using p=1,2 we arrive at LO and QO problems respectively. See details in [Lau01].

8.3 Expected utility maximization

Apart from selecting different risk measures, we can also approach portfolio optimization through the use of utility functions. We specify a concave and increasing utility function that measures the investors preference for each specific outcome. Then the objective is to maximize the expected utility under the return distribution.

Expected utility maximization can take into account any type of return distribution, while MVO works only with the first two moments, therefore it is accurate only for normally distributed return. MVO is also equivalent with expected utility maximization if the utility function is quadratic, because it models the investors indifference about higher moments of return. The only advantage of MVO in this comparison is that it works without having to discretize the return distribution and work with scenarios.

8.3.1 Optimal portfolio using gaussian mixture return

In [LB22] an expected utility maximization approach is taken, assuming that the return distribution is a Gaussian mixture (GM). The benefits of a GM distribution are that it can approximate any continuous distribution, including skewed and fat-tailed ones. Also its components can be interpreted as return distributions given a specific market regime. Moreover, the expected utility maximization using this return model can be formulated as a convex optimization problem without needing return scenarios, making this approach as efficient and scalable as MVO.

We denote security returns having Gaussian mixture (GM) distribution with K components as

(8.24)RGM({μi,Σi,πi}i=1K),

where μi is the mean, Σi is the covariance matrix, and πi is the probability of component i. As special cases, for K=1 we get the normal distribution N(μ1,Σ1), and for Σi=0, i=1,,K we get a scenario distribution with K return scenarios {μ1,,μK}.

Using definition (8.24), the distribution of portfolio return Rx will also be GM:

(8.25)RxGM({μx,i,σx,i2,πi}i=1K),

where μx,i=μiTx, and σx,i2=xTΣix.

To select the optimal portfolio we use the exponential utility function Uδ(x)=1eδx, where δ>0 is the risk aversion parameter. This choice allows us to write the expected utility of the portfolio return Rx using the moment generating function:

(8.26)E(1eδRx)=1MRx(δ).

Thus maximizing the function (8.26) is the same as minimizing the moment generating function of the portfolio return, or equivalently, we can minimize its logarithm, the cumulant generating function:

(8.27)minimizeKRx(δ)subject toxF,

If Rx is assumed to be a GM random variable, then its cumulant generating function will be the following:

(8.28)KRx(δ)=log(i=1Kπiexp(δμiTx+δ22xTΣix))

The function (8.28) is convex in x because it is a composition of the convex and increasing log-sum-exp function and a convex quadratic function. Note that for K=1, we get back the same quadratic utility objective as in version (2.3) of the MVO problem.

Assuming we have the GM distribution parameter estimates μi,Σi, i=1,,K, we can apply Sec. 13.1.1.10 (Quadratic form) and Sec. 13.1.1.13 (Log-sum-exp) to arrive at the conic model of the utility maximization problem (8.27):

(8.29)minimizezsubject toi=1Kπiui1,(ui,1,δμiTx+δ2qiz)Kexp, i=1,,K,(qi,1,GTx)QrN+2, i=1,,K,xF,

where qi is an upper bound for the quadratic term 12xTΣix, and Gi is such that Σi=GiGiT.

8.3.2 EVaR using Gaussian mixture return

We introduced Entropic Value-at-Risk (EVaR) in Sec. 8.2.3 (Entropic Value-at-Risk). EVaR can also be expressed using the cumulant generating function KL(s)=log(ML(s)) of the loss L:

(8.30)EVaRα(L)=infs>01sKL(s)1slog(1α).

After substituting the return R=L instead of the loss, we see that KR(s)=KR(s). Assuming now that R=Rx is the portfolio return, we get the following optimization problem:

(8.31)minimize1sKRx(s)1slog(1α)subject toxF,

We can find a connection between EVaR computation (8.31) and maximization of expected exponential utility (8.27). Suppose that the pair (x,s) is optimal for problem (8.31). Then x also optimal for problem (8.27), with risk aversion parameter δ=s.

By assuming a GM distribution for security return, we can optimize problem (8.31) without needing a scenario distribution. First, to formulate it as a convex optimization problem, define the new variable t=1s:

(8.32)EVaRα(L)=inft>0tKRx(1t)tlog(1α).

We can observe that the first term in formula (8.32) is the perspective of KRx(1). Therefore by substituting the cumulant generating function (8.28) of the GM portfolio return, we get a convex function in the portfolio x:

(8.33)EVaRα(L)=inft>0tlog(i=1Kπiexp(1tμiTx+12t2xTΣix))tlog(1α).

Assuming we have the GM distribution parameter estimates μi,Σi, i=1,,K, we can apply Sec. 13.1.1.10 (Quadratic form) and Sec. 13.1.1.15 (Perspective of log-sum-exp) to arrive at the conic model of the EVaR minimization problem (8.31):

(8.34)minimizeztlog(1α)subject toi=1Kπiuit,(ui,t,μiTx+qiz)Kexp, i=1,,K,(qi,1,GTx)QrN+2, i=1,,K,t0,xF,

where qi is an upper bound for the quadratic term 12xTΣix, and Gi is such that Σi=GiGiT.

The huge benefit of this EVaR formulation is that its size does not depend on the number of scenarios, because it is derived without using a scenario distribution. It depends only on the number of GM components K.

8.4 Example

This example shows how can we compute the CVaR efficient frontier using the dual form of CVaR in MOSEK Fusion.

8.4.1 Scenario generation

The input data is again obtained the same way as detailed in Sec. 3.4.2 (Data collection), but we do only the steps until Sec. 3.4.3.3 (Projection of invariants). This way we get the expected return estimate μlog and the covariance matrix estimate Σlog of yearly logarithmic returns. These returns have approximately normal distribution, so we can easily generate T number of return scenarios from them, using the numpy default random number generator. Here we choose T=99999. This number ensures to have a nonzero λα in formula (8.11), which is the most general case.

# Number of scenarios
T = 99999
# Generate logarithmic return scenarios assuming normal distribution
R_log = np.random.default_rng().multivariate_normal(m_log, S_log, T)

Next, we convert the received logarithmic return scenarios to linear return scenarios using the inverse of formula (3.2).

# Convert logarithmic return scenarios to linear return scenarios
R = np.exp(scenarios_log) - 1
R = R.T

We transpose the resulting matrix just to remain consistent with the notation in this chapter, namely that each column of R is a scenario. We also set the scenario probabilities to be 1T:

# Scenario probabilities
p = np.ones(T) / T

8.4.2 The optimization problem

The optimization problem we solve here resembles problem (2.12), but we will change the risk measure from portfolio standard deviation to portfolio CVaR:

(8.35)maximizeμTxδCVaRα(RTx)subject to1Tx=1,x0.

Applying the dual CVaR formula (8.13), we get:

(8.36)maximizeμTxδ(t+11αipimax(0,riTxt))subject to1Tx=1,x0.

We know that formula (8.13) equals CVaR only if it is minimal in t. This will be satisfied in the optimal solution of problem (8.36), because the CVaR term is implicitly forced to become smaller, and t is independent from x.

Now we model the maximum function, and arrive at the following LO model of the mean-CVaR efficient frontier:

(8.37)maximizeμTxδtδ1αipiuisubject touRTxt,u0,1Tx=1,x0.

8.4.3 The Fusion model

Here we show the Fusion model of problem (8.37).

def EfficientFrontier(N, T, m, R, p, alpha, deltas):
    with Model("CVaRFrontier") as M:
        # Variables
        # x - fraction of holdings relative to the initial capital.
        # It is constrained to take only positive values.
        x = M.variable("x", N, Domain.greaterThan(0.0))

        # Budget constraint
        M.constraint('budget', Expr.sum(x) == 1)

        # Auxiliary variables.
        t = M.variable("t", 1, Domain.unbounded())
        u = M.variable("u", T, Domain.unbounded())

        # Constraint modeling maximum
        M.constraint(u >= - R * x - Var.repeat(t, T))
        M.constraint(u >= 0)

        # Objective
        delta = M.parameter()
        cvar_term = t + u.T @ p / (1-alpha)
        M.objective('obj', ObjectiveSense.Maximize,
                           x.T @ m - delta * cvar_term)

        # Create DataFrame to store the results.
        columns = ["delta", "obj", "return", "risk"] + \
                  df_prices.columns.tolist()
        df_result = pd.DataFrame(columns=columns)
        for d in deltas:
            # Update parameter
            delta.setValue(d)

            # Solve optimization
            M.solve()

            # Save results
            portfolio_return = m @ x.level()
            portfolio_risk = t.level()[0] + \
                1/(1-alpha) * np.dot(p, u.level())
            row = pd.Series([d, M.primalObjValue(),
                             portfolio_return, portfolio_risk] + \
                            list(x.level()), index=columns)
            df_result = df_result.append(row, ignore_index=True)

        return df_result

Next, we compute the efficient frontier. We select the confidence level α=0.95. The following code produces the optimization results:

alpha = 0.95

# Compute efficient frontier with and without shrinkage
deltas = np.logspace(start=-1, stop=2, num=20)[::-1]
df_result = EfficientFrontier(N, T, m, R, p, alpha, deltas)

On Fig. 8.1 we can see the risk-return plane, and on Fig. 8.2 the portfolio composition for different levels of risk.

_images/cvar_eff_frontier.png

Fig. 8.1 The CVaR efficient frontier.

_images/cvar_portfolio_composition.png

Fig. 8.2 Portfolio composition x with varying level of CVaR risk.

Footnotes