Volatility and structural breaks
Visualizing volatility changes helps reveal possible structural break points in time series. By identifying when volatility appears to change, an informed choice of break point can be made that can, in turn, be used for further statistical analysis (such as the Chow test).
You'll examine two visualizations of volatility for the investment bank portfolio from 2008 - 2009, for two available portfolio weights: weights_with_citi and weights_without_citi. These correspond, respectively, to equal-weighted portfolios with and without Citibank, which exhibited (as you saw in Chapter 1) the highest volatility of the four assets over the period.
The portfolio prices for 2008 - 2009 with Citibank are available as prices_with_citi, and without Citibank as prices_without_citi.
Diese Übung ist Teil des Kurses
Quantitative Risk Management in Python
Anleitung zur Übung
- Find the returns series for the two portfolios using 
weights_with_citiandweights_without_citi. - Compute the 30-day rolling window standard deviations for both portfolios.
 - Combine both Pandas 
Seriesobjects into a single "vol" DataFrame object. - Plot the contents of the 
volobject to compare the two portfolio volatilities over time. 
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Find the time series of returns with and without Citibank
ret_with_citi = prices_with_citi.____.dot(weights_with_citi)
ret_without_citi = prices_without_citi.pct_change().____(____)
# Find the average 30-day rolling window volatility as the standard deviation
vol_with_citi = ret_with_citi.____.std().dropna().rename("With Citi")
vol_without_citi = ret_without_citi.rolling(30).____.dropna().rename("Without Citi")
# Combine two volatilities into one Pandas DataFrame
vol = pd.concat([____, ____], axis=1)
# Plot volatilities over time
vol.____().set_ylabel("Losses")
plt.show()