Expected shortfall

Chamberlain Mbah
4 min readJan 23, 2023

--

Expected shortfall (ES) is a risk management measure that quantifies the potential loss of a portfolio in the event of a specific level of tail risk, such as a market downturn. It is a more conservative measure of risk than Value-at-Risk (VaR) because it takes into account the potential loss beyond a certain level of VaR. It is also known as “conditional value-at-risk” (CVaR) or “tail value-at-risk” (TVaR).

A financial risk manager at work.
A financial risk manager

Understanding VaR and ES

To understand why ES is a more conservative measure of risk than VaR, let’s review VaR first. VaR is a statistical measure of the risk of a portfolio, which represents the maximum loss that can be expected at a given confidence level. For example, if the VaR of a portfolio is $1 million at a confidence level of 99%, it means that there is only a 1% chance that the portfolio will lose more than $1 million. However, VaR does not take into account the potential loss beyond that level.

ES, on the other hand, is a measure of the expected loss beyond the VaR level. It is calculated as the average loss in the worst x% of scenarios, where x is the confidence level. For example, if the VaR of a portfolio is $1 million at a confidence level of 99%, and the ES is $1.5 million, it means that in 1% of the worst scenarios, the portfolio is expected to lose an average of $1.5 million.

Take home message: ES is a more conservative measure of risk than VaR because it takes into account the potential loss beyond VaR level.

Calculating ES using portfolio optimization

One way to calculate ES is through the use of a portfolio optimization model. The model optimizes the portfolio weights to minimize the risk subject to an expected shortfall constraint. Here is an example of how to calculate the ES of a portfolio of assets using the cvxpy library in Python:

import cvxpy as cp
import numpy as np

# Define portfolio returns and covariance matrix
returns = np.array([0.1, 0.2, 0.15])
cov_matrix = np.array([[0.04, 0.005, 0.02],
[0.005, 0.03, 0.01],
[0.02, 0.01, 0.05]])

# Define portfolio weights
weights = cp.Variable(3)

# Define risk budget
alpha = 0.05

# Define expected shortfall constraint
portfolio_return = cp.sum(cp.multiply(returns, weights))
portfolio_risk = cp.quad_form(weights, cov_matrix)
ES = portfolio_return - (1/alpha)*portfolio_risk
constraints = [ES <= 0, cp.sum(weights) == 1]

# Define optimization objective
objective = cp.Minimize(portfolio_risk)

# Solve problem
prob = cp.Problem(objective, constraints)
prob.solve()

# Print result
print("Expected Shortfall:", prob.value)
print("Optimal weights:", weights.value)

In this code, a portfolio of three assets is defined with given returns and covariance matrix. The portfolio weights are optimized to minimize the risk subject to an expected shortfall constraint. The variable alpha is the risk budget, and the expected shortfall is defined as the difference between the expected portfolio return and the expected shortfall risk.

Take home message: Portfolio optimization is one way to calculate the expected shortfall, by optimizing the portfolio weights to minimize the risk subject to an expected shortfall constraint.

Using ES in practice

In practice, ES is commonly used by financial institutions and investors to manage the risk of their portfolios. It can also be used to set risk budgets for different departments or business units, and to assess the performance of portfolio managers.

One important use of ES is in stress testing, which is a method of evaluating the potential impact of extreme market events on a portfolio. Stress testing using ES can help identify potential vulnerabilities in a portfolio and inform the development of risk management strategies.

Take home message: ES is a useful tool for managing risk in practice, it can be used to set risk budgets and evaluate the performance of portfolio managers and assess the impact of extreme market events on a portfolio.

It’s important to note that this is just an example and you may want to adjust the inputs to match your specific use case and portfolio. Additionally, this example uses the optimization package cvxpy which is one of the many available in python, others include cvxopt and scipy. It's also worth mentioning that the accuracy of the results depends on the quality and completeness of the input data, and the assumptions made in the model.

In conclusion, expected shortfall (ES) is a risk management measure that quantifies the potential loss of a portfolio in the event of a specific level of tail risk, it is a more conservative measure than VaR as it takes into account the potential loss beyond a certain level of VaR. One way to calculate ES is through the use of a portfolio optimization model, and it can be used in practice to manage risk, set risk budgets, assess the performance of portfolio managers and stress testing.

--

--

Chamberlain Mbah

Dr. Chamberlain Mbah is a lead data scientist known for his expertise in big data, machine learning algorithms, and creating advanced AI applications.