Learn R Programming

PMwR (version 0.11-0)

Adjust-Series: Adjust Time Series for Dividends and Splits

Description

Adjust a time series for dividends and splits.

Usage

div_adjust(x, t, div, backward = TRUE, additive = FALSE)

split_adjust(x, t, ratio, backward = TRUE)

Arguments

x

a numeric vector

t

an integer vector, specifying the positions in x at which dividends were paid (‘ex-days’) or at which a split occurred

div

a numeric vector, specifying the dividends. If necessary, recycled to the length of t.

ratio

a numeric vector, specifying the split ratios. The ratio must be ‘American Style’: a 2-for-1 stock split, for example, corresponds to a ratio of 2. (In other countries, for instance Germany, a 2-for-1 stock split would be called a 1-for-1 split: you keep your shares and receive one new share per share that you own.)

backward

logical

additive

logical

Value

a numeric vector of length equal to length(x)

Details

With backward set to TRUE, which is the default, the final prices in the unadjusted series matches the final prices in the adjusted series.

Examples

Run this code
# NOT RUN {
x <- c(9.777, 10.04, 9.207, 9.406)
div <- 0.7
t <- 3

div_adjust(x, t, div)
div_adjust(x, t, div, FALSE)
# }

Run the code above in your browser using DataLab