CVaR and loss cover selection
In previous exercises you saw that both the T and the Gaussian KDE distributions fit portfolio losses for the crisis period fairly well. Given this, which of these is best for risk management? One way to choose is to select the distribution that provides the largest loss cover, to cover the "worst worst-case scenario" of losses.
The t
and kde
distributions are available and have been fit to 2007-2008 portfolio losses
(t
fitted parameters are in p
). You'll derive the one day 99% CVaR estimate for each distribution; the largest CVaR estimate is then the 'safest' reserve amount to hold, covering expected losses that exceed the 99% VaR.
The kde
instance has been given a special .expect()
method, just for this exercise, to compute the expected value needed for the CVaR.
This exercise is part of the course
Quantitative Risk Management in Python
Exercise instructions
- Find the 99% VaR using
np.quantile()
applied to random samples from thet
andkde
distributions. - Compute the integral required for the CVaR estimates using the
.expect()
method for each distribution. - Find and display the 99% CVaR estimates for both distributions.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Find the VaR as a quantile of random samples from the distributions
VaR_99_T = np.quantile(t.rvs(size=1000, *p), ____)
VaR_99_KDE = np.quantile(kde.resample(size=1000), ____)
# Find the expected tail losses, with lower bounds given by the VaR measures
integral_T = t.____(lambda x: x, args = (p[0],), loc = p[1], scale = p[2], lb = ____)
integral_KDE = kde.____(lambda x: x, lb = ____)
# Create the 99% CVaR estimates
CVaR_99_T = (1 / (1 - ____)) * integral_T
CVaR_99_KDE = (1 / (1 - ____)) * integral_KDE
# Display the results
print("99% CVaR for T: ", CVaR_99_T, "; 99% CVaR for KDE: ", CVaR_99_KDE)