Ralph,
This will parse that yahoo link you provided. I'll add it (along with
a wrapper) to the qmao package tonight.
.getSplitsCalendar <- function(YM=format(Sys.Date(), "%Y%m")) {
stopifnot(length(YM) == 1)
if (is.timeBased(YM) || nchar(YM) == 10) {
YM <- format(as.Date(YM), "%Y%m")
} else if (nchar(YM) == 5) {
YM <- paste0(substr(YM, 1, 4), 0, substr(YM, 5, 5))
} else if (nchar(YM) == 7 && length(grep("-", YM) == 1)) {
YM <- sub("-", "", YM)
}
if (nchar(YM) != 6) stop("'YM' should be 6 digits or a Date")
Y <- substr(YM, 3, 4)
M <- as.numeric(substr(YM, 5, 6))
# there is a different URL for the current month than for other months
URL <- if (identical(format(Sys.Date(), "%Y%m"), YM)) {
"http://biz.yahoo.com/c/s.html"
} else paste0("http://biz.yahoo.com/c/", Y, "/s", M, ".html")
rt <- try(readHTMLTable(URL, stringsAsFactors=FALSE), silent=TRUE)
if (inherits(rt, 'try-error')) return(NULL)
dat <- rt[[which.max(sapply(rt, nrow))]]
colnames(dat) <- make.names(dat[1, ])
dat <- dat[-c(1,2), -NCOL(dat)]
#read.zoo(dat, index.column=1:2
dat[[1]] <- as.Date(paste(substr(YM, 1, 4), dat[[1]]), "%Y %b %d")
dat[[2]] <- as.Date(paste(substr(YM, 1, 4), dat[[2]]), "%Y %b %d")
dat[, NCOL(dat)] <- as.Date(paste(substr(YM, 1, 4), dat[, NCOL(dat)]),
"%Y %b %d")
dat
}
R> .getSplitsCalendar()
Payable Ex.Date Company Symbol Optionable. Ratio Announced
3 2012-09-07 2012-09-10 Old Dominion ODFL Y 3-2 2012-08-13
4 2012-09-18 2012-09-19 LKQ LKQ Y 2-1 2012-08-17
5 2012-09-21 2012-09-24 Medivation MDVN Y 2-1 2012-08-28
R> .getSplitsCalendar('201208')
Payable Ex.Date Company Symbol Optionable. Ratio Announced
3 2012-08-10 2012-08-13 Brown-Forman BF.B Y 3-2 2012-06-14
4 <NA> 2012-08-13 Coca-Cola KO Y 2-1 2012-04-25
5 2012-08-14 2012-08-15 Oi SA OIBR Y 3-1 2012-08-10
6 2012-08-21 2012-08-22 Schweitzer-Mauduit SWM Y 2-1 2012-08-01
getDividendsCalendar gets it's data from earnings.com which is Reuters
data. So, it should be good (except that it's way too much data if
you only want to know the dividend date of a particular ticker)
Regards,
Garrett
On Thu, Sep 6, 2012 at 12:56 PM, Ralph Vince <[email protected]> wrote:
> THis looks pretty good, and could be parsed -- I just wish they had it
> for cash dividends as well;
> http://biz.yahoo.com/c/s.html
> Ralph Vince
>
> On Thu, Sep 6, 2012 at 1:44 PM, Ralph Vince <[email protected]> wrote:
>> Hi Jeff,
>>
>> Yes, but they only offer dividends not splits. I;ve been working off
>> of sites like this and looking to automate it somehow, hopefully
>> through R.
>>
>>
>> On Thu, Sep 6, 2012 at 12:15 PM, Jeff Ryan <[email protected]> wrote:
>>> You might be able to use this:
>>>
>>> http://www.dividend.com/ex-dividend-dates.php
>>>
>>> Jeff
>>>
>>> On Thu, Sep 6, 2012 at 11:13 AM, Ralph Vince <[email protected]> wrote:
>>>> Yes, I'm willing to pay for it, but I would like to get it
>>>> automatically into a format I can parse and use, not even sure where
>>>> that exists at the moment. (Doesn't Yahoo Finance get their data from
>>>> CSI?) Ralph Vince
>>>>
>>>> On Thu, Sep 6, 2012 at 12:04 PM, G See <[email protected]> wrote:
>>>>> On Thu, Sep 6, 2012 at 10:54 AM, Brian G. Peterson <[email protected]>
>>>>> wrote:
>>>>>> The only way I know of to get out of maintaining it by hand is to pay for
>>>>>> data.
>>>>>>
>>>>>> On the GUI side, Bloomberg, Factset, and Reuters have all been mentioned
>>>>>> already I think. Rbbg of course talks to Bloomberg.
>>>>>>
>>>>>> On the other vendor side, I think Interactive Brokers has this data, and
>>>>>> it
>>>>>> may be available via the IBrokers package if it is available via the IB
>>>>>> API.
>>>>>> Additional vendors, such as CSIdata, tickdata.com, Reuters, CRSP,
>>>>>> Telekurs,
>>>>>> etc all sell this data, at varying prices and quality.
>>>>>
>>>>> Interactive Brokers does provide an "Upcoming Dividend Schedule" for
>>>>> stocks, but it is a rough estimate that is often wrong. Also, I don't
>>>>> think you can get it from their API (although if someone knows how,
>>>>> please speak up). I think you have to go into the GUI, right-click a
>>>>> stock and select Dividend Schedule.
>>>>>
>>>>> -Garrett
>>>>>
>>>>> _______________________________________________
>>>>> [email protected] mailing list
>>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>>>>> -- Subscriber-posting only. If you want to post, subscribe first.
>>>>> -- Also note that this is not the r-help list where general R questions
>>>>> should go.
>>>>
>>>> _______________________________________________
>>>> [email protected] mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>>>> -- Subscriber-posting only. If you want to post, subscribe first.
>>>> -- Also note that this is not the r-help list where general R questions
>>>> should go.
>>>
>>>
>>>
>>> --
>>> Jeffrey Ryan
>>> [email protected]
>>>
>>> www.lemnica.com
_______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should
go.