Get startedGet started for free

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().

This exercise is part of the course

Importing and Managing Financial Data in R

View Course

Exercise instructions

  • 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.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Download AAPL split data


# Download AAPL dividend data


# Look at the first few rows of dividends


# Download AAPL dividend data that is not split-adjusted


# Look at the first few rows of raw_dividends
Edit and Run Code