1. Learn
  2. /
  3. Courses
  4. /
  5. Importing and Managing Financial Data in R

Exercise

Use Quandl to download quarterly returns data

Sometimes you need to aggregate and/or transform raw data before you can continue your analysis. The Quandl() function allows you to specify common aggregations and transformations via the collapse and/or transform arguments. The Quandl API takes care of the details for you.

You will use the same CL and BZ data from the CME as last exercise, but this time you will apply some aggregations and transformations on the raw data. The quandl codes for CL and BZ are provided in the object quandl_codes.

Instructions

100 XP
  • Use the collapse and type arguments with Quandl() to download quarterly data as an xts object named qtr_price.
  • Use a quantmod extractor function to view the high prices for both instruments.
  • Modify the command to the first instruction to create a qtr_return object that contains the % change of the raw data. See the Quandl API documentation for how to specify row-on-row % change.
  • Use getPrice() to view the Settle returns.