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

Exercise

Download split and dividend data

In the previous exercise, you used adjustOHLC() to adjust raw historical OHLC prices for splits and dividends, but it only works for OHLC data. It will not work if you only have close prices, and it does not return any of the split or dividend data it uses.

You need the dates and values for each split and dividend to adjust a non-OHLC price series, or if you simply want to analyze the raw split and dividend data.

You can download the split and dividend data from Yahoo Finance using the quantmod functions getSplits() and getDividends(), respectively. The historical dividend data from Yahoo Finance is adjusted for splits. If you want to download unadjusted dividend data, you need to set split.adjust = FALSE in your call to getDividends().

Instructions

100 XP
  • Use getSplits() to import AAPL split data into splits.
  • Use getDividends() to import split-adjusted AAPL dividend data into dividends.
  • Look at the first few rows of dividends. The values are small and in fractional cents because they have been split-adjusted.
  • Use getDividends() to import unadjusted AAPL dividend data into raw_dividends.
  • Look at the first few rows of raw_dividends. Note they differ from the values in dividends.