Exercise

Computing returns

For managing financial risk, we need to first measure the risk by analyzing the return series. Here, you are given the S&P 500 price series and you need to plot the daily returns. You will see that large (positive or negative) returns tend to be followed by large returns of either sign, and small returns tend to be followed by small returns. The periods of sustained low volatility and high volatility are called volatility clusters.

At any point in this course:

  • feel free to explore the datasets in the Console
  • don't hesitate to refer to the slides in the tab on the right of the console if you need to check the functions and processes explained in the videos

This course assumes knowledge of xts. To refresh your memory, try the xts in R Cheat Sheet.

Instructions

100 XP
  • Plot the daily stock prices available in the xts object sp500prices.
  • Use the function CalculateReturns from, the package PerformanceAnalytics to calculate the corresponding returns and save them in the object sp500ret.
  • Verify that sp500ret is of the class xts.
  • Plot the daily S&P 500 returns and note the changes in return variability over time.