Observe volatility clustering
Volatility clustering is frequently observed in financial market data, and it poses a challenge for time series modeling.
In this exercise, you will get familiar with the S&P 500 daily price dataset. You will calculate daily returns as the percentage price changes, plot the results and observe its behavior over time.
Historical S&P 500 daily price data has been preloaded in sp_price for you.
Cet exercice fait partie du cours
GARCH Models in Python
Instructions
- Calculate daily returns as percentage price changes and save it to the DataFrame
sp_pricein a new column calledReturn. - View the data by printing out the last 10 rows.
- Plot the
Returncolumn and observe signs of volatility clustering.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Calculate daily returns as percentage price changes
sp_price['____'] = 100 * (sp_price['Close'].____())
# View the data
print(sp_price.____(____))
# plot the data
plt.plot(sp_price['____'], color = 'tomato', label = 'Daily Returns')
plt.legend(loc='upper right')
plt.show()