AddCumDiv: Add dividends back to price series

Description Usage Arguments Details Value Author(s) Examples

View source: R/AddCumDiv.R

Description

At every timestamp, add to the prices the cumulative amount of dividends receieved since the beginning of the dataset.

Usage

1

Arguments

x

xts or character name of xts object

name

name of stock to use when getting dividends

env

environment in which to find x

Details

After a series has been adjusted, an "adj" attr of TRUE is added to the object. If the object already has an "adj" attr, the original object x will be returned and no adjustment will be made.

cumulative dividends will only be added to columns with names that include one of the following terms: Open, High, Low, Close, Bid.Price, Ask.Price, Trade.Price, Mid.Price.

TODO: make a function that does the opposite of this one.

Value

xts object with same dims as x that is the original x with cumulative dividends added. An attr called “cumdiv” that contains an xts of the cumulative dividends will be added to the returned object

Author(s)

Garrett See

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
## You must setDefaults on getSymbols.FI (at least for the "dir" argument)
## for this to work
getSymbols("SPY", src='FI', from='2011-09-01', to='2011-12-31')
SPY.tp <- AddCumDiv(SPY)
tail(attr(SPY.tp, "cumdiv"))
cbind(tail(estAd(SPY)), estAd(tail(SPY.tp)))

## End(Not run)

qmao documentation built on May 2, 2019, 4:54 p.m.