Dividend Ex-Date returns Dividend Pay Date · Issue #287 · joshuaulrich/quantmod (original) (raw)

Description

I'm trying to get the dividends dates (I see "Dividend Pay Date" is commented out in getQuote() source code). So I should probably not get the "Dividend Pay Date" but I should be getting the "Ex-Dividend Date".

library(quantmod)
library(dplyr)

what_metrics <- yahooQF(
  c("Dividend Yield", "Dividend/Share",
    "Ex-Dividend Date",
    "dividendDate",
    "Dividend Pay Date",
    "Earnings Timestamp")
)

df <- getQuote("MSFT", what=what_metrics) %>% as.data.frame()
yahoo_time <- function(x){
  as.POSIXct(x,
             origin = "1970-01-01 00:00:00.000 UTC")
}
df %>%
  mutate(`Ex-Dividend Date` = yahoo_time(`Ex-Dividend Date`),
         `Earnings Timestamp` = yahoo_time(`Earnings Timestamp`))

Produces

           Trade Time Dividend Yield Dividend/Share    Ex-Dividend Date  Earnings Timestamp
1 2019-11-08 16:00:01     0.01310135           1.89 2019-12-11 19:00:00 2019-10-23 12:08:39

Expected behavior

https://finance.yahoo.com/quote/MSFT?p=MSFT
https://www.nasdaq.com/market-activity/stocks/msft


Somewhat separate issue, the Earnings timestamp shows the past timestamp (not sure if this is correct behavior, given yahoo shows an estimate future earnings report)