3

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:

require(quantmod)
AAPL<- getSymbols("AAPL", from="1987-01-01",to="2016-08-01", auto.assign = F)
# head(AAPL)
# tail(AAPL)    
# assuming a minimum split of 10:11 
probableSplits<- which( Delt(Cl(AAPL)/Ad(AAPL)) <= -0.1)    
probableSplitDates<- index(AAPL)[probableSplits] 
x<- AAPL[c(probableSplits, ((probableSplits)-1))]
x$tmpratio<- Cl(x)/Ad(x)    
x$splitRatio<- round(1/(1+Delt(x$tmpratio)))   
#Added Following 1 line for very old stocks with adjusted price in low   decimals
probableSplitDates<- index(x[x$splitRatio>1,])  

x$splitRatio[probableSplitDates]

chartSeries(AAPL["2014-06"],theme = chartTheme('white'))

I would like to know what issues this solution might run into.

Even though I'm using Apple here, I am looking for data from Indian exchanges (for example, RELIANCE.NS) so some of the US specific sources for cross-referencing will not work for me.

EDIT: Added one line to code for old adjusted price in very low decimal values

R.S.
  • 2,093
  • 14
  • 29
  • The derived number of splits need to be verified from an external reliable source constrained by feasibility. For example the above AAPL example can be verified from [here](https://www.stocksplithistory.com/apple/). As for NSE/BSE listed stocks you could try [here](http://economictimes.indiatimes.com/reliance-industries-ltd/infocompanybonus/companyid-13215.cmshere). For a large number of tickers an http search function could be used to verify presence/absence of external stock split history – Silence Dogood Aug 29 '16 at 14:42
  • @Osssan : Thanks for looking into it. I used AAPL data because it was verifiable on a site like stocksplithistory. An http based search from news media sites would probably be very messy , especially with a large dump of thousands of symbols. But if nothing else works , something like that would need be resorted to. But I'd lke to avoid it if I can. I wanted to know if people have tried this approach above and can give some idea about what quantum of error it might induce. – R.S. Aug 29 '16 at 15:02

1 Answers1

2

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)
Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418
  • Many Thanks @Joshua. Wonder how I missed getSplis() ! Though I guess getSplits values would be related to Adjusted and the two will mirror the same data error in case there are any . Let me please check the results against some known data and some relatively obscure companies and then come back. – R.S. Aug 29 '16 at 15:41
  • Sorry Joshua,I was sent on a wild goose chase digging old data for this. getSplits() is the best option for me. Much appreciated your help. Thanks again. Marked answer. some data issues still. For instance, split in INFY.NS on "1999-02-08" shows on "1999-02-10" . makes external verification difficult, but well. weirder rants though: yahoo data for INFY.NS["2009-02",] does not show this change in close price, only in adjusted price, which is weird. Weirder, data from Indian stock xchange itself gives absurdly wrong prices for 1999, and yahoo prices are more in line with INFY's annual repo. – R.S. Aug 30 '16 at 00:34