1. Learn
  2. /
  3. Courses
  4. /
  5. Quantitative Risk Management in Python

Connected

Exercise

Comparing CVaR and VaR

The conditional value at risk (CVaR), or expected shortfall (ES), asks what the average loss will be, conditional upon losses exceeding some threshold at a certain confidence level. It uses VaR as a point of departure, but contains more information because it takes into consideration the tail of the loss distribution.

You'll first compute the 95% VaR for a Normal distribution of portfolio losses, with the same mean and standard deviation as the 2005-2010 investment bank portfolio_losses. You'll then use the VaR to compute the 95% CVaR, and plot both against the Normal distribution.

The portfolio_losses are available in your workspace, as well as the norm Normal distribution from scipy.stats.

Instructions

100 XP
  • Compute the mean and standard deviation of portfolio_losses and assign them to pm and ps, respectively.
  • Find the 95% VaR using norm's .ppf() method--this takes arguments loc for the mean and scale for the standard deviation.
  • Use the 95% VaR and norm's .expect() method to find the tail_loss, and use it to compute the CVaR at the same level of confidence.
  • Add vertical lines showing the VaR (in red) and the CVaR (in green) to a histogram plot of the Normal distribution.