Update: April 29, 2022
As per this discussion in Github, Joshua Ulrich had uploaded a patch into Github which resolves the issue.
The issue was with Yahoo website having stopped to provide the crumb(s) that were expected by the new.session()
but not essential for getting getSymbols()
to work.
To install the patch, exit all R and RStudio sessions. Start a new R or RStudio session. Execute the commands
remotes::install_github("joshuaulrich/quantmod@358-getsymbols-new.session")
library("quantmod")
quantmod::getSymbols("TSLA")
Original question
Today (April 28, 2022) I got an unusual situation with quantmod::getSymbols()
.
The following code works if executed in an RStudio session that was started yesterday (R version 4.2.0, Windows 10):
if (!require("quantmod")) install.packages("quantmod")
library("quantmod")
quantmod::getSymbols("TSLA")
However, the same code produces a timeout error in a new RStudio session on the same machine:
Error in new.session() : Could not establish session after 5 attempts.
What was tried:
- Same code in Jupyter notebook on a remote server produces the same timeout.
- Same code in a new RStudio (or R) session on a different Windows 10 computer produces the same timeout.
- Same code in an RStudio (or R) session works if the session was started yesterday on either Windows 10 computer.
- Same code on previous versions of R or RStudio works if the session was started yesterday on either Windows 10 computer.
Perhaps the quantmod
package and getSymbols()
have cached the SSL certificates?