Skip to content

Commit

Permalink
Catch and warn on getSymbols.yahooj() errors
Browse files Browse the repository at this point in the history
Use the same logic as getSymbols.yahoo().

See #135.
  • Loading branch information
joshuaulrich committed Apr 11, 2018
1 parent 5802644 commit 5b1aa7d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions R/getSymbols.R
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,11 @@ function(Symbols,env,return.class='xts',index.class="Date",
stop("package:",dQuote("XML"),"cannot be loaded.")

yahoo.URL <- "https://info.finance.yahoo.co.jp/history/"
for(i in 1:length(Symbols)) {

returnSym <- Symbols
noDataSym <- NULL
for(i in seq_along(Symbols)) {
test <- try({
# The name of the symbol, which will actually be used as the
# variable name. It needs to start with YJ, and it will be appended
# if it does not.
Expand Down Expand Up @@ -565,9 +569,16 @@ function(Symbols,env,return.class='xts',index.class="Date",
Sys.sleep(1)
}

}, silent = TRUE)
if (inherits(test, "try-error")) {
msg <- attr(test, "condition")$message
warning("Unable to import ", dQuote(returnSym[[i]]), ".\n",
msg, call. = FALSE, immediate. = TRUE)
noDataSym <- c(noDataSym, returnSym[[i]])
}
}
if(auto.assign)
return(Symbols)
return(setdiff(returnSym, noDataSym))
return(fr)
}
# }}}
Expand Down

0 comments on commit 5b1aa7d

Please sign in to comment.