Adjusting for corporate actions

1. Adjusting for corporate actions

In the last video, you learned how splits and dividends can affect stock prices, and that they can affect total return calculations. In this video, you will learn how to adjust data for splits and dividends.

2. Adjust for stock splits and dividends (1)

The adjustOHLC() function in the quantmod package can adjust OHLC data by downloading split and dividend data from Yahoo Finance. It uses those data and the unadjusted series to calculate adjustment ratios. Then it uses those ratios to back-adjust the OHLC data, so all the price changes account for splits and dividends. You only need to pass the object containing the OHLC data, if the object name is the same as the ticker symbol. If the object has a different name, you can use the symbol-dot-name argument to tell adjustOHLC() the ticker symbol to use when downloading split and dividend data. It's important to remember that you need to update all your historical data whenever a split or dividend occurs.

3. Adjust for stock splits and dividends (2)

Let's return to the Microsoft example from the previous video. The three dollar per share dividend caused the price to drop, but with no impact to the investor's return. The black line is the unadjusted price, and you can see that the adjusted price is about three dollars lower than the unadjusted price before the dividend. Without going into details, it's not exactly three dollars because the adjustment process ensures returns are corrected.

4. Download split and dividend data

You can only use the adjustOHLC() function if you have OHLC data. If you have a univariate series, close prices for example, then you need to calculate the adjustment yourself. To do that, you need split and dividend data. The getSplits() and getDividends() functions in quantmod provide access to both. Both functions have similar arguments as getSymbols(), and import the split and dividend data from Yahoo Finance. Most of the time, you just need to specify the ticker symbol.

5. Download unadjusted dividends

Keep in mind that the dividend data are adjusted for splits by default. If you need the raw dividend amounts, you can set the split-dot-adjust argument to FALSE, and getDividends() will return the unadjusted dividend prices.

6. adjRatios()

Once you have split and dividend data, you can use the adjRatios() function to back-adjust any series for splits, dividends, or both. The adjRatios() function takes three arguments: 'splits', 'dividends', and 'close'. adjRatios() returns an xts object with two columns: Split and Div, which contain the adjustment ratios for splits and dividends, respectively.

7. Adjust univariate series for splits and dividends

Let's look at an example of manually calculating the adjusted close price for General Electric. First you import split and dividend data using getSplits() and getDividends(). Now you can use adjRatios() to calculate the split and dividend adjustment ratios.

8. Adjust univariate series for splits and dividends

Then you just need to multiply your price by both ratios to complete the adjustment.

9. Let's practice!

Now that you've seen a few examples of how to adjust for splits and dividends, it's time to practice with some exercises!