I am having trouble downloading getSymbols("SPY") in rstudio

quantmod function not working in rStudio IDE syntax correct library installed and loaded.

Hi @variable,
Welcome to the RStudio Community Forum.

To get help you will need to post the code you are using that produces the error (and some sample data). In short, we need a Minimal Reproducible Example (MRE) and, maybe, the output from

sessionInfo()

HTH

Thanks yes I only want one years data at this point I have got from 2000 before, so that could be handy, yes google disconnected there API, it no longer works, yahoo stopped working, however the quantmod team did a great work around, and it was still running; even though you can only get 2 years data from the yahoo website, from quantmod you could go back as far as 1991 for some things. But yahoo, were stating they were not storing data anymore it was costing them too much. Might try it without startDate and endDate, it is possible they are now incompatible. They are not necessary generally. Thank you very much for your kind assistance.

1 Like

Yes It works without start and end dates functions. thank you very much, but the yahoo API is still very unstable. I am not sure how I close this question

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

library(quantmod)


startDate <- as.Date(2019-04-01)
endDate <- as.Date(2020-04-24)

getSymbols("SPY",  from = startDate , to = endDate)

SPY

#> getSymbols("SPY", from = startDate , to = endDate)
‘getSymbols’ currently uses auto.assign=TRUE by default, but will
use auto.assign=FALSE in 0.5-0. You will still be able to use
‘loadSymbols’ to automatically load data. getOption("getSymbols.env")
and getOption("getSymbols.auto.assign") will still be checked for
alternate defaults.

This message is shown once per session and may be disabled by setting
options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.

Warning: SPY download failed; trying again.
Error in getSymbols.yahoo(Symbols = "SPY", env = , verbose = FALSE, :
Unable to import “SPY”.
SPY download failed after two attempts. Error message:
HTTP error 400.

Hi @variable,
I couldn't get any downloads to work with startDate and endDate included in the arguments.
It worked fine without any date limits - you can easily fix your date selection later in R.
I also noted that some of the src= options don't work either.

library(quantmod)

startDate <- as.Date(2019-04-01)
endDate <- as.Date(2020-04-24)

getSymbols("SPY",  from = startDate , to = endDate)
getSymbols("SPY",  from = startDate , to = endDate, src = "yahoo")
getSymbols("SPY",  from = startDate , to = endDate, src = "google")
getSymbols("SPY",  from = startDate , to = endDate, src = "oanda")
getSymbols("SPY",  from = startDate , to = endDate, src = "FRED")

getSymbols("SPY", src = "yahoo")
getSymbols("SPY")

dim(SPY)
head(SPY)
tail(SPY)

HTH

1 Like

I have checked windows defender to see it is not being blocked by the firewall, it is an exception and is allowed across the firewall, I have deleted the R idle and downloaded version 4 and updated R studio, still no luck. It is baffling? I have no idea why I can install packages across the server, but quantmod can not download across the server?