adjustOHLC(x,
adjust = c("split","dividend"),
use.Adjusted = FALSE,
ratio = NULL)
use.Adjusted = TRUE
will be less precise
than the method that employs actual split
and dividend information. This is due to
loss of precision from Yahoo! using
Adjusted columns of only two decimal places.
The advantage is that this can be run offline,
and for short series or those with few adjustments
the loss of precision will be small.The resulting precision loss will be from row observation to row observation, as the calculation will be exact for intraday values.
There are three methods available to calculate the new OHLC object prices.
By default, getSplits and getDividends are
called to retrieve the respective information. These
may dispatch to custom methods following the getSymbols
for information related to extending quantmod.
This information is passed to
adjSplitDiv
from the
The second method works only on standard Yahoo! data containing an explicit Adjusted column.
A final method allows for one to pass
a ratio
into the function directly.
All methods proceed as follows:
New columns are derived by taking the
ratio of adjusted value to original Close, and multiplying
by the difference of the respective column and the
original Close. This is then added to the modified Close
column to arrive at the remaining
If no adjustment is needed, the function returns the original data unaltered.
getSymbols.yahoo
getSplits
getDividends
adjSplitDiv
getSymbols("AAPL", from="1990-01-01", src="yahoo")
head(AAPL)
head(AAPL.a <- adjustOHLC(AAPL))
head(AAPL.uA <- adjustOHLC(AAPL, use.Adjusted=TRUE))
# intrada adjustments are precise across all methods
# an example with Open to Close (OpCl)
head(cbind(OpCl(AAPL),OpCl(AAPL.a),OpCl(AAPL.uA)))
# Close to Close changes ma lose precision
head(cbind(ClCl(AAPL),ClCl(AAPL.a),ClCl(AAPL.uA)))
Run the code above in your browser using DataLab