This is in relation to stock data obtained from Yahoo Finance.
I'm looking for a method for determining dates when a stock was split (or bonus shares were issued, the distinction is immaterial to current task).
I could not find any specific answer to this problem. Here's the best I could think of:
AAPL<- getSymbols("AAPL", from="1987-01-01",to="2016-08-01", auto.assign = F)
# assuming a minimum split of 10:11
probableSplits<- which( Delt(Cl(AAPL)/Ad(AAPL)) <= -0.1)
x<- AAPL[c(probableSplits, ((probableSplits)-1))]
#Added Following 1 line for very old stocks with adjusted price in low decimals
chartSeries(AAPL["2014-06"],theme = chartTheme('white'))
You could use the split/dividend data that Yahoo Finance provides.
require(quantmod) getSplits("RELIANCE.NS") # RELIANCE.NS.spl # 1997-10-27 0.5 # 2009-11-26 0.5
You could also use
adjustOHLC to do the adjustment for you.
getSymbols("RELIANCE.NS") RELIANCE.NS.ADJ <- adjustOHLC(RELIANCE.NS)