Quantifying the Downside: An Investor’s Guide to Value at Risk (VaR) and Expected Shortfall

No of Post Views:

47 hits

In our journey through financial data analysis, we’ve learned to calculate returns, measure volatility with standard deviation, and use the power of diversification. However, standard deviation has a limitation: it treats all volatility, both upside gains and downside losses, as equal. For most investors, the real concern isn’t the risk of making too much money; it’s the risk of losing it.

This brings us to the crucial topic of downside risk. How can we specifically measure and manage our potential for losses? In this article, we will explore two of the most widely used metrics in risk management: Value at Risk (VaR) and Conditional Value at Risk (CVaR), also known as Expected Shortfall.

1. Value at Risk (VaR): Answering the Fundamental Question

Value at Risk, or VaR, is a statistical measure that seeks to answer a simple yet profound question: “In a worst-case scenario, how much money can I lose on an investment?”

It quantifies the potential loss in value of an asset or portfolio over a defined period for a given confidence interval. To understand VaR, you must always consider its three key components:

  1. Time Period: The duration over which the loss could occur (e.g., one day, one week).
  2. Confidence Level: The probability that the actual loss will not exceed the VaR amount (e.g., 95%, 99%).
  3. Potential Loss Amount: The maximum estimated loss in currency or percentage terms.

For example, a portfolio with a one-day, 95% VaR of $1 million means there is a 95% chance that the portfolio will not lose more than $1 million in a single day. Conversely, it also means there is a 5% chance that the loss could be greater than $1 million.

2. Beyond VaR: Conditional Value at Risk (CVaR)

VaR answers the question of how much we stand to lose, but it doesn’t tell us anything about the days when losses exceed the VaR threshold. If we hit that unlucky 5% of days, what is our expected loss?

This is where Conditional Value at Risk (CVaR), or Expected Shortfall, comes in. CVaR calculates the average loss on the days that fall beyond the VaR point. The calculation is simple: we just take the average of all returns that were worse than our calculated VaR.

3. How to Calculate VAR and CVAR

These metrics are ubiquitous in the financial industry, used by banks and investment firms to set risk limits and monitor market exposure. There are three primary methods for calculating VaR, each with its own strengths and weaknesses.

Method 1: The Historical Method

The historical method is the most intuitive way to calculate VaR. It makes a simple assumption: the future will behave similarly to the past. It uses actual historical returns to empirically determine the worst-case loss.

Let’s illustrate this by calculating the daily VaR for Bitcoin with a 95% confidence level. First, we’ll download five years of historical data and visualize the distribution of daily returns.

import datetime
import numpy as np
import pandas as pd
import seaborn as sns
import yfinance as yfin
import matplotlib.pyplot as plt

# Define the time period
start = datetime.date(2016, 1, 1)
end = datetime.date(2021, 11, 28)

# Download historical data for Bitcoin
prices = pd.DataFrame(yfin.download(["BTC-USD"], start, end)["Close"])
returns = prices.pct_change().dropna()
returns = returns.rename(columns={"Adj Close": "Bitcoin"})

# Plot the distribution of daily returns
sns.histplot(data=returns)
plt.title("Distribution of Bitcoin Daily Returns (2016-2021)")
plt.xlabel("Daily Return")
plt.show()
Histogram showing the distribution of Bitcoin daily returns from 2016 to 2021, illustrating the frequency of different return values.

The histogram shows the frequency of different daily returns. The “left tail” of the distribution represents the negative returns, or losses. To find the historical VaR, we simply need to find the point on this distribution that separates the worst 5% of days from the best 95%. This is the 5th percentile of the historical returns.

We can create a reusable Python function to calculate this easily.

def getHistoricalVaR(returns, confidenceLevel):
    """
    Calculates the historical Value at Risk (VaR) at a given confidence level.
    """
    # We use 100 - confidenceLevel to get the correct percentile for the loss tail
    var = np.percentile(returns, 100 - confidenceLevel)
    print(
        f"With {confidenceLevel:.2f}% confidence, the maximum daily loss is {var*100:.3f}% (Historical VaR)."
    )
    return var

# Calculate VaR at different confidence levels
var_95 = getHistoricalVaR(returns['BTC-USD'], 95)
var_99 = getHistoricalVaR(returns['BTC-USD'], 99)
With 95.00% confidence, the maximum daily loss is -6.020% (Historical VaR). 
With 99.00% confidence, the maximum daily loss is -10.555% (Historical VaR).

The results tell us that, based on the last five years of data, we can be 95% confident that our Bitcoin holdings won’t lose more than 6.02% on any given day. If we want to be more certain, we can increase the confidence level to 99%, which corresponds to a higher potential loss of 10.56%.

Let’s create another function to calculate CVaR.

from scipy import stats

def getHistoricalCVaR(returns, confidenceLevel):
    """
    Calculates the historical Conditional Value at Risk (CVaR) or Expected Shortfall.
    """
    var = np.percentile(returns, 100 - confidenceLevel)
    # Filter for returns that are less than or equal to the VaR
    cvar = returns[returns <= var].mean()
    print(
        f"In the worst {100-confidenceLevel:.0f}% of days, the average loss is {cvar*100:.2f}% (Historical CVaR)."
    )

# Calculate CVaR for Bitcoin at the 95% confidence level
getHistoricalCVaR(returns['BTC-USD'], 95)
In the worst 5% of days, the average loss is -9.08% (Historical CVaR).

This tells us that on the 5% of days when Bitcoin’s losses exceeded our 6.02% VaR, the average loss was about -9.08%. CVaR provides a more complete picture of the tail risk, giving us a sense of the magnitude of extreme losses.

To see how these metrics differ for less volatile assets, let’s compare Bitcoin to a bond ETF (BLV).

# Get data for the bond ETF
bond_prices = pd.DataFrame(yfin.download(["BLV"], start, end)["Close"])
bond_returns = bond_prices.pct_change().dropna()

print("Bond ETF (BLV) Risk Metrics:")
getHistoricalVaR(bond_returns.BLV, 95)
getHistoricalCVaR(bond_returns.BLV, 95)
With 95.00% confidence, the maximum daily loss is -0.927% (Historical VaR). 
In the worst 5% of days, the average loss is -1.49% (Historical CVaR).

As you can see, the downside risk for the bond ETF is dramatically lower than for Bitcoin, which is exactly what we would expect.

Method 2: The Parametric Approach

The historical method is simple, but it assumes the past is a perfect predictor of the future. The parametric method takes a more statistical approach by assuming that returns follow a specific probability distribution, most commonly the normal distribution.

Instead of sorting historical data, this method uses the mean and standard deviation of returns to calculate VaR based on the properties of the assumed distribution.

Let’s calculate the 95% parametric VaR for Apple (AAPL) stock.

# Define a longer time period for more robust statistics
start_aapl = datetime.date(2010, 1, 1)
end_aapl = datetime.date(2021, 11, 28)

# Download Apple data
aapl_prices = pd.DataFrame(yfin.download(["AAPL"], start_aapl, end_aapl)["Close"])
aapl_returns = aapl_prices.pct_change().dropna()

# Calculate mean and standard deviation of daily returns
mean = aapl_returns.AAPL.mean()
std_dev = aapl_returns.AAPL.std()

# Calculate parametric VaR using the normal distribution's Percent Point Function (ppf)
confidence_level = 0.05 # For the 5% left tail
parametric_var_95 = stats.norm.ppf(confidence_level, mean, std_dev)

print(f"The 95% parametric VaR for AAPL is {parametric_var_95*100:.3f}%")
The 95% parametric VaR for AAPL is -2.783%

The primary weakness of this method is its reliance on the normal distribution assumption. Financial returns are known to have “fat tails,” meaning extreme events occur more frequently than a normal distribution would predict. This can lead to an underestimation of the true VaR. To combat this, analysts sometimes use other distributions, like the t-distribution, which has fatter tails.

Method 3: Monte Carlo Simulation

The most flexible and powerful method for calculating VaR is the Monte Carlo simulation. This approach involves running thousands of computer simulations to generate random potential outcomes for a portfolio’s returns.

Instead of relying on historical data or a single distribution, it can model a wide range of future possibilities. For each simulation, a random return path is generated. After running thousands of simulations, the results are collected and sorted, and the VaR is determined by looking at the percentile of the simulated outcomes, much like the historical method.

  • Advantages: Extremely flexible; can model complex instruments like options and incorporate multiple probability distributions.
  • Disadvantages: Computationally intensive; the results are only as good as the assumptions used to build the simulation.

Conclusion: A More Complete View of Risk

Throughout this series, we’ve built a comprehensive toolkit for financial analysis. We started with basic returns, moved to measuring volatility, understood the benefits of diversification and ETFs, and have now equipped ourselves with sophisticated tools to measure downside risk.

Value at Risk and Expected Shortfall are not crystal balls, but they provide a structured and quantitative way to think about potential losses. By understanding these metrics, you can better align your portfolio with your personal risk tolerance, set appropriate limits, and navigate the unpredictable world of financial markets with greater confidence. This knowledge empowers you to move from being a passive investor to an informed and strategic risk manager of your own capital.


Leave a Reply

Discover more from SimplifiedZone

Subscribe now to keep reading and get access to the full archive.

Continue reading

Discover more from SimplifiedZone

Subscribe now to keep reading and get access to the full archive.

Continue reading