Get startedGet started for free

Compute GARCH covariance

Covariance describes the relationship of movement between two price return series. Recall dynamic covariance can be computed by ρ * σ1 * σ2, where σ1, σ2 are volatility estimates from GARCH models, and ρ is the simple correlation between GARCH standardized residuals.

In this exercise, you will practice computing dynamic covariance with GARCH models. Specifically you will use two foreign exchange time series data: EUR/USD and USD/CAD (shown in the plot). Their price returns have been fitted by two GARCH models, and the volatility estimates are saved in vol_eur and vol_cad. In addition, their standardized residuals are saved in resid_eur and resid_cad respectively. In addition, the numpy package has been imported as np.

This exercise is part of the course

GARCH Models in Python

View Course

Exercise instructions

  • Calculate correlation between GARCH standardized residuals resid_eur and resid_cad.
  • Calculate covariance with GARCH volatility vol_eur, vol_cad and the correlation computed in the previous step.
  • Plot the calculated covariance.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Calculate correlation
corr = np.____(____, ____)[0,1]
print('Correlation: ', corr)

# Calculate GARCH covariance
covariance =  ____ * ____ * ____

# Plot the data
plt.plot(____, color = 'gold')
plt.title('GARCH Covariance')
plt.show()
Edit and Run Code