Recently, Yahoo Finance – a popular source of free end-of-day price data – made some changes to their server which wreaked a little havoc on anyone relying on it for their algos or simulations. Specifically, Yahoo Finance switched from HTTP to HTTPS and changed the data download URLs. No doubt this is a huge source of frustration, as many backtesting and trading scripts that relied on such data will no longer work.

Users of the excellent R package quantmod  however are in luck! The package’s author, Joshua Ulrich, has already addressed the change in a development version of quantmod. You can update your quantmod  package to the development version that addresses this issue using this command in R:

devtools::install_github("joshuaulrich/quantmod", ref="157_yahoo_502")

Of course, you need the devtools  package installed, so do install.packages("devtools")  first if you don’t already have it installed.

Once the package updates,  quantmod::getSymbols(src = "yahoo")  should work just as it did prior to the updates on the Yahoo Finance server. I can verify that this worked for me.

Of course, if you don’t want to update quantmod to a version that lives on a Git branch, you can wait until the changes are merged into master and do

devtools::install_github("joshuaulrich/quantmod")

I don’t know when that will happen, but I have been using the branch version for a few days now, and all appears to be working as expected.

Update: A user suggested making use of the quantmod::adjustOHLC() function as the adjusted close of Yahoo data is currently incomplete, and doesn’t account for dividends. Example usage:

First time here? Check out our posts on machine learning in finance and our recent review of dual momentum as an investment strategy. Enjoy!

Hey Kris, thanks very much for this! Been struggling massively with this for a while now.

My pleasure, Jeff. I’m only the messenger here though, all credit to Josh Ulrich, the quantmod package developer.

Hi Kris,
when running the install_github function I got the following error:
> install_github(“joshuaulrich/quantmod”, ref=”157_yahoo_502″)
Installation failed: Couldn’t connect to server

Any advice? was the Git branch deactivated?
Thanks!
Tom

Hey Tom, I just had a look at the Github repo. It looks like the updates have been merged into the master branch. You can install the master branch direct from the repo by doing devtools::install_github("joshuaulrich/quantmod")

Obviously make sure you do install.packages('devtools') first if you don’t already have it installed.

Some users have reported having to restart R Studio if using that platform as your IDE.

Hope that helps!

Thanks for the method – it works.

Unfortunately, old good Yahoo is not that good anymore – dividend adjustments absent for some tickers, so backtests of all my systems got worse due to that. Need to find new better data source… =(

Hi Kris,

Thank you for posting this.  My R code that used quantmod and getSymbols no longer worked, so a solution would be welcome.

I use RStudio.  I updated devtools, and then executed the R command you suggested:

devtools::install_github(“joshuaulrich/quantmod”, ref=“157_yahoo_502”), which ran without error.

However here is the result:
library(quantmod)
getSymbols(‘F’)
HTTP error 401.
I am an R novice, so surely I did something wrong.  Any clues?

Thank you.

I couldn’t reproduce this error. quantmod::getSymbols('F') worked fine for me.

Try restarting R Studio after updating quantmod.

Thank you Kris! It worked after restarting R studio.

But it reflects only splits, not dividend as Google..

Indeed for me too I can confirm that for some assets we have splits but no dividends.

One user suggested using quantmod::adjustOHCL() to get adjustments for dividends and splits, which seems now to be missing for yahoo data. Example usage as follows;
ratio = NULL,
symbol.name=deparse(substitute(x)))
I haven’t tested this.

Hi Kris,

thank you for your help, I am still struggling with this issue. I am getting this error. Can you help please ?

options(“getSymbols.yahoo.warning”=FALSE).