diff --git a/R/getSymbols.R b/R/getSymbols.R index 0491f1d2..cf75a19e 100644 --- a/R/getSymbols.R +++ b/R/getSymbols.R @@ -725,7 +725,7 @@ function(Symbols,env,return.class='xts', # getSymbols.FRED {{{ `getSymbols.FRED` <- function(Symbols,env, - return.class="xts", ...) { + return.class="xts", timeout=10, ...) { importDefaults("getSymbols.FRED") this.env <- environment() for(var in names(list(...))) { @@ -742,12 +742,13 @@ function(Symbols,env,return.class='xts', returnSym <- Symbols noDataSym <- NULL + ch <- curl::new_handle(timeout=timeout) for(i in seq_along(Symbols)) { if(verbose) cat("downloading ",Symbols[[i]],".....\n\n") test <- try({ URL <- paste0(FRED.URL, Symbols[[i]]) - fr <- read.csv(curl::curl(URL),na.strings=".") + fr <- read.csv(curl::curl(URL, handle=ch),na.strings=".") if(verbose) cat("done.\n") fr <- xts(as.matrix(fr[,-1]), diff --git a/man/getSymbols.FRED.Rd b/man/getSymbols.FRED.Rd index 2ce130cb..43c63b4d 100644 --- a/man/getSymbols.FRED.Rd +++ b/man/getSymbols.FRED.Rd @@ -19,6 +19,7 @@ additional getSymbols \sQuote{methods}. getSymbols.FRED(Symbols, env, return.class = "xts", + timeout=10, ...) } %- maybe also 'usage' for other objects documented here. @@ -27,6 +28,7 @@ getSymbols.FRED(Symbols, the names of each symbol to be loaded} \item{env}{ where to create objects. (.GlobalEnv) } \item{return.class}{ class of returned object } + \item{timeout}{ timeout for the call in seconds } \item{\dots}{ additional parameters } } \details{