Search code examples
ryahoo-financequantmod

Error in new.session() : Could not establish session after 5 attempts


I've been facing in R the error message for days using getSymbols of the quantmod package:

Error in new.session() : Could not establish session after 5 attempts.
getSymbols(tick, from = date_from,  to = date_to, warnings = FALSE, auto.assign = TRUE)

The same issue applies to:

getSymbols(tick, from = date_from,  to = date_to, warnings = FALSE, auto.assign = TRUE, src="yahoo")

Solution

  • Update QuantMod and try again:

    install.packages('quantmod')
    

    This was a bug that was fixed very swiftly. Thank you Joshua Ulrich!


    History (2022-04-29):

    This was an issue on 2022-04-29 that Joshua Ulrich promptly published a fix for. You could install the patched version with:

    remotes::install_github("joshuaulrich/quantmod@358-getsymbols-new.session")
    

    But the changes are now into CRAN, so you should just be able to update QuantMod and continue with your day.

    Link to fix: GitHub: joshuaulrich/quantmod@358-getsymbols-new.session

    GitHub issue here.