Install quantmod v. 0.4.17.2 onwards; CRAN doesn't have this version yet, so install from github directly devtools::install_github("joshuaulrich/quantmod")
Because the new version can handle multiple connections & handles (Check this), and you would need this to push multiple requests to yahoo.
The following function uses multiple cores. So you can replace %dopar% with %do% if you want it otherwise.
RawData.Splits <- function(stocks, from)
{
x <- foreach(ticker = stocks, .combine = bind_rows
, .errorhandling = "remove", .inorder = F, .multicombine = T
) %dopar%
{
x <- tryCatch({suppressWarnings(
quantmod::getSplits(ticker, from, envir = .GlobalEnv)
)},
error = function(e) {data.frame()})
if(xts::is.xts(x))
{
names(x) <- c("split.ratio")
x <- as.data.frame(x) %>% mutate(split.ds = rownames(.), ticker) %>%
select(ticker, split.ds, split.ratio)
cat(paste0(ticker, "; "))
}
else {x <- data.frame()}
rm(ticker)
return(x)
}
if(nrow(x) > 0)
{ x <- x %>% mutate(split.ds = as.Date(split.ds), updated.on = Sys.Date()) }
rm(stocks, from)
return(x)
}