Compute parametric VaR
In this exercise, you will practice estimating dynamic 5% daily VaRs with a parametric approach.
Recall there are three steps to perform a forward VaR estimation. Step 1 is to use a GARCH model to make variance forecasts. Step 2 is to obtain the GARCH forward-looking mean and volatility. And Step 3 is to compute the quantile according to a given confidence level. The parametric approach estimates quantiles from an assumed distribution assumption.
A GARCH model has been fitted with historical Bitcoin return data up to 1/1/2019, then it has generated mean and variance forecasts, saved in mean_forecast
and variance_forecast
respectively. The GARCH model assumes a Student's t-distribution, and its \(\nu\) (degree of freedom) is saved in nu
.
This exercise is part of the course
GARCH Models in Python
Exercise instructions
- Compute 0.05 quantile from the assumed Student's t-distribution.
- Calculate VaR using
mean_forecast
,variance_forecast
from the GARCH model and the quantile from the previous step.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Obtain the parametric quantile
q_parametric = basic_gm.____.____(____, nu)
print('5% parametric quantile: ', q_parametric)
# Calculate the VaR
VaR_parametric = ____.values + np.sqrt(____).values * ____
# Save VaR in a DataFrame
VaR_parametric = pd.DataFrame(VaR_parametric, columns = ['5%'], index = variance_forecast.index)
# Plot the VaR
plt.plot(VaR_parametric, color = 'red', label = '5% Parametric VaR')
plt.scatter(variance_forecast.index,bitcoin_data.Return['2019-1-1':], color = 'orange', label = 'Bitcoin Daily Returns' )
plt.legend(loc = 'upper right')
plt.show()