Adjust Time Series for Dividends and Splits
Adjust a time series for dividends and splits.
div_adjust(x, t, div, backward = TRUE, additive = FALSE) split_adjust(x, t, ratio, backward = TRUE)
x |
a numeric vector: the series to be adjusted |
t |
An integer vector, specifying the positions in
|
div |
A numeric vector, specifying the dividends (or
payments, cashflows). If necessary, recycled to
the length of |
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 |
With backward
set to TRUE
, which is the
default, the final prices in the unadjusted series
matches the final prices in the adjusted series.
a numeric vector of length equal to length(x)
Enrico Schumann
Schumann, E. (2021) Portfolio Management with R. http://enricoschumann.net/PMwR/
Using div_adjust
for handling generic external cashflows:
http://enricoschumann.net/R/packages/PMwR/manual/PMwR.html#returns-with-external-cashflows
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) ## assume there were three splits: adjust shares outstanding shares <- c(100, 100, 200, 200, 1000, 1500) t <- c(3, 5, 6) ratio <- c(2, 5, 1.5) ### => invert ratio split_adjust(shares, t, 1/ratio) ## [1] 1500 1500 1500 1500 1500 1500 split_adjust(shares, t, 1/ratio, backward = FALSE) ## [1] 100 100 100 100 100 100
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.