MATLAB Answers

can't connect to yahoo

19 views (last 30 days)
c = yahoo; error using yahoo (line 63) Unable to connect or retrieve data from given URL.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 2 May 2017
The MathWorks Support Team recently posted an update on this issue. Here is the answer to save you the click:
“In April 2017, Yahoo introduced some changes in the protocol of their API. These changes prevented the Datafeed Toolbox from connecting to the service. The following webpage contains the workaround for this issue and instructions on how to apply the fix.
Denis Alaev
Denis Alaev on 18 Jun 2017
It seems that after several changes Yahoo Finance closed their API forever. The API was closed on May 15, one month ago already.
I've tested several alternatives and found that the best one for those who used Yahoo Finance. They provide raw data, adjusted closes and splits/dividends.
They also have CSV output, with very similar format for Yahoo Finance users.
Also there is a data provider, looks good, but they much more expensive, have no data for Mutual Funds and API is very different in compare to Yahoo Finance. Then you need to significantly change your code.

Sign in to comment.

More Answers (5)

Artur Sepp
Artur Sepp on 19 Apr 2017
Edited: Artur Sepp on 20 Apr 2017
It appears that Yahoo have changed the http to the encrypted https. You should now create the queries using '' + requests instead of '' + requests. This solution is a bit messy than using the conventional yahoo handle in the matlab datafeed packadge. It took me a few hours to re-write my data fetching analytics...
Matlab function c=yahoo is a build-in one and cannot be overwritten with something like c=yahoo(''). So we can only wait for Matlab to update the datafeed toolbox to pick up this change from Yahoo. I hope that someone from Matlab support team would read this post and take the needed action.
  1 Comment
Denis Alaev
Denis Alaev on 18 Jun 2017
No, it appears that Yahoo closed the API forever...

Sign in to comment.

Adriano on 20 Apr 2017
Edited: Adriano on 20 Apr 2017
Hello! I contact Matlab support and they give me a new code for datafeed toolbox. Now it works! You should do the same if you want fix the problem quickly.
  1 Comment
Adhish Aggarwal
Adhish Aggarwal on 20 Apr 2017
Hi Adriano, Can you post the code that Matlab support gave you?

Sign in to comment.

Alexandre Amorim
Alexandre Amorim on 30 Apr 2017
MATLAB uses Yahoo's API under the hood. Around April 18 Yahoo introduced some changes in the protocol of their API. These changes prevented the Datafeed Toolbox from connecting to the service.
The development team implemented a fix that takes into account those changes, but the fix needs to be applied manually. To apply the fix, follow these steps:
1) Download the attached files: 'yahoo.m' and 'fetch.m'
2) Remove the following file
where %MATLAB_ROOT% can be found with the following MATLAB command:
>> matlabroot
3) Place the downloaded files in the following locations:
4) Run the following MATLAB command
>> rehash toolboxcache
>> clear classes
Now you should be able to retrieve historic and current data as usual:
>> % Current data
>> fetch(yahoo,'IBM')
Thanks to Shashank
Steven Lord
Steven Lord on 6 Jun 2017
The bug report has been updated since that answer was posted.

Sign in to comment.

Jeremy Shaw
Jeremy Shaw on 18 Apr 2017
i have this problem also, worked fine last week, now fails; the API/Yahoo has a problem???
Adhish Aggarwal
Adhish Aggarwal on 19 Apr 2017
It is still not working.

Sign in to comment.

Calder on 19 Apr 2017
Help us matlab!!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!