Closed stakerauo closed 3 years ago
Your example works for me. Does it work for you? Maybe you only get the error if you have more tickers?
I'm going to close this since I can't replicate and this doesn't seem to be an issue with the package. That said, I'll still try to help if you're still having issues.
Hey, I was just about to reply, but looks like I was just a minute too late. The issue prevails. I've since tried updating my R console, seeing that I was using 3.6.2, and quantmod was made for 3.6.3. I'm now using 4.0.5.
I've shortened the ticker list to four tickers, and it works as it should now(it didn't at 3.6.2), but as you suggested, the full list is what's causing the issue. I'll attach the full vector below, if you want to give it a shot at replicating. I'm thinking maybe it could be the size of the data set that is too large for RStudio to handle, but I don't know how to approach the issue.
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")
Hey, I was just about to reply, but looks like I was just a minute too late.
:)
The issue prevails.
Weird, I still can't replicate. This works for me. Can you run with verbose = TRUE
in the getSymbols()
call? That may give me a better idea where the issue is. The output of traceback()
after the error would be helpful too.
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)))
})
Sure thing! Ran it with Verbose = TRUE:
downloading AEGA.OL .....
Warning: AEGA.OL download failed; trying again.
Error in getSymbols.yahoo(Symbols = "AEGA.OL", env = <environment>, verbose = TRUE, :
Unable to import “AEGA.OL”.
argument "conn" is missing, with no default`
and then from traceback()
11: stop(msg)
10: getSymbols.yahoo(Symbols = "AEGA.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))) at #2
2: FUN(X[[i]], ...)
1: lapply(sym.vd, function(sym) {
dailyReturn(na.locf(getSymbols(sym, verbose = TRUE, from = "2020-07-01",
auto.assign = FALSE)))
})
If you're still looking in the error; I've noticed at the first attempt, I'm also getting this error:
Error in curl::curl_fetch_memory(cu, handle = h) :
transfer closed with outstanding read data remaining
with the following traceback:
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)))
})
I was finally able to resolve the issue. Turns out, there was a problem with the RTools software. I reinstalled RTools, then I ran the following line of code, as recommended on the cran.rstudio.com:
writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")
Sys.which("make")
install.packages("jsonlite", type = "source")
The problem must have been somewhere along those lines. I recognize the argument con = was mentioned in the error as "missing with no default", so my guess is I was missing the .Renviron file.
Thanks a lot, Joshua. I really appreciate that you tried to help me.
Thanks a lot, Joshua. I really appreciate that you tried to help me.
You're welcome! I'm glad you were able to figure it out.
downloading AEGA.OL ..... Warning: AEGA.OL download failed; trying again. Error in getSymbols.yahoo(Symbols = "AEGA.OL", env = <environment>, verbose = TRUE, : Unable to import “AEGA.OL”. argument "conn" is missing, with no default`
Also, I fixed this in d4c6ec56054b9fec4c7bba69366a8e23fceb9ed8. Now it gives a better error message.
Description
I have created a vector with all my tickers in, and I've created a for loop that gives me the symbols that I want when I set from = "2021-01-01". However, when I set from "2020-02-01" it tells me it's unable to import. I've looked at Yahoo Finance and the price data is available.
Expected behavior
I hope for getSymbols to return stock price data from up to two years back, and probably rid of the following error.
Minimal, reproducible example
Session Info
Final note
I appreciate any comment that could lead me in the right direction. I've googled for solutions, and looked around anywhere, but I can't seem to find anything similar. Thank you!