Get startedGet started for free

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.

This exercise is part of the course

GARCH Models in Python

View Course

Exercise instructions

  • Calculate daily returns as percentage price changes and save it to the DataFrame sp_price in a new column called Return.
  • View the data by printing out the last 10 rows.
  • Plot the Return column and observe signs of volatility clustering.

Hands-on interactive exercise

Have a go at this exercise by completing this sample 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()
Edit and Run Code