Hello, everyone!
I've come across an issue with Quantmod in RStudio, where my consol has issues with downloading large data sets. I've created a for-loop, which helps me download closing price data for 71 companies listed on the OSEBX index. It works wonders when I set from = "2021-01-01", but when I set from = 2020-07-01" it stops working. Verbose tells me that it's able to download the data for the first four companies, so when I shorten the list to only four tickers, it works again. Then when I set from = "2020-02-01", it can't even do the first company on the list. I've checked the companies' pages on Yahoo Finance, and the data is available.
If anyone is familiar or has come across this issue, I would love to hear how you solved it. Also, any input is helpful, as I'm stuck.
I've tried asking for help over at the Quantmod forum on github, but he's not able to replicate the error, but none the less, I'll post the code and errors below.
The code, for reprex:
sym.vd = c("AEGA.OL", "AKAST.OL", "AMSC.OL", "AUSS.OL", "AGAS.OL", "AWDR.OL",
"ALNG.OL", "AXXIS.OL", "B2H.OL", "BONHR.OL", "BOR.OL", "BORR.OL", "BWLPG.OL",
"DNO.OL", "DOF.OL", "EAM.OL", "EIOF.OL", "ELE.OL", "ELK.OL", "EPIC.OL",
"EQNR.OL", "RISH.OL", "GRONG.OL", "HAVI.OL", "HBC.OL", "HSPG.OL", "IDEX.OL",
"INSR.OL", "JAREN.OL", "JIN.OL", "KOMP.OL", "KOA.OL", "NAPA.OL", "NEXT.OL",
"NANOV.OL", "NORTH.OL", "OCY.OL", "ODL.OL", "ODF.OL", "OLT.OL", "PGS.OL",
"PHLY.OL", "PLCS.OL", "PRS.OL", "QEC.OL", "REACH.OL", "RECSI.OL", "SDSD.OL",
"SADG.OL", "SBX.OL", "SHLF.OL", "SIOFF.OL", "SBVG.OL", "NONG.OL", "SNOR.OL",
"SOAG.OL", "MING.OL", "SVEG.OL", "SOR.OL", "MORG.OL", "SNI.OL", "STB.OL",
"SUBC.OL", "SUNSB.OL", "TGS.OL", "VVL.OL", "WAWI.OL", "WILS.OL", "WWI.OL",
"XXL.OL", "YAR.OL")
Stocks = lapply(sym.vd, function(sym) {
dailyReturn(na.locf(getSymbols(sym, from = "2020-02-01", auto.assign = FALSE)))
})
Error with Verbose = TRUE
downloading AEGA.OL .....
done.
downloading AKAST.OL .....
done.
downloading AMSC.OL .....
done.
downloading AUSS.OL .....
Warning: AUSS.OL download failed; trying again.
Error in getSymbols.yahoo(Symbols = "AUSS.OL", env = <environment>, verbose = TRUE, :
Unable to import “AUSS.OL”.
transfer closed with outstanding read data remaining
Traceback for last error:
11.
stop(msg)
10.
getSymbols.yahoo(Symbols = "AUSS.OL", env = <environment>, verbose = TRUE,
warnings = TRUE, auto.assign = FALSE, from = "2020-07-01",
.has1sym. = TRUE)
9.
do.call(paste("getSymbols.", symbol.source, sep = ""), list(Symbols = current.symbols,
env = env, verbose = verbose, warnings = warnings, auto.assign = auto.assign,
..., .has1sym. = .has1sym.))
8.
getSymbols(sym, verbose = TRUE, from = "2020-07-01", auto.assign = FALSE)
7.
na.locf(getSymbols(sym, verbose = TRUE, from = "2020-07-01",
auto.assign = FALSE))
6.
is.xts(x)
5.
try.xts(x)
4.
periodReturn(x, "daily", subset, type, leading, ...)
3.
dailyReturn(na.locf(getSymbols(sym, verbose = TRUE, from = "2020-07-01",
auto.assign = FALSE)))
2.
FUN(X[[i]], ...)
1.
lapply(sym.vd, function(sym) {
dailyReturn(na.locf(getSymbols(sym, verbose = TRUE, from = "2020-07-01",
auto.assign = FALSE)))
})
One time error that occurs at first attempt:
Error in curl::curl_fetch_memory(cu, handle = h) :
transfer closed with outstanding read data remaining
Traceback for last error:
13.
curl::curl_fetch_memory(cu, handle = h)
12.
new.session()
11.
.getHandle(curl.options)
10.
getSymbols.yahoo(Symbols = "AEGA.OL", env = <environment>, verbose = FALSE,
warnings = TRUE, auto.assign = FALSE, from = "2020-02-01",
.has1sym. = TRUE)
9.
do.call(paste("getSymbols.", symbol.source, sep = ""), list(Symbols = current.symbols,
env = env, verbose = verbose, warnings = warnings, auto.assign = auto.assign,
..., .has1sym. = .has1sym.))
8.
getSymbols(sym, from = "2020-02-01", auto.assign = FALSE)
7.
na.locf(getSymbols(sym, from = "2020-02-01", auto.assign = FALSE))
6.
is.xts(x)
5.
try.xts(x)
4.
periodReturn(x, "daily", subset, type, leading, ...)
3.
dailyReturn(na.locf(getSymbols(sym, from = "2020-02-01", auto.assign = FALSE)))
2.
FUN(X[[i]], ...)
1.
lapply(sym.vd, function(sym) {
dailyReturn(na.locf(getSymbols(sym, from = "2020-02-01",
auto.assign = FALSE)))
})