Dear all;
When ı try to retrieve historical stock prices data ı receive the following error
Error using yahoo (line 63) Unable to connect or retrieve data from given URL
PS: ı used following to commands to retrieve the data >>conn=yahoo('http://download.finance.yahoo.com'); >>d=fetch(conn,'IBM'); and
>> conn2 = yahoo; >>d=fetch(conn2,'IBM');
Thanks in advence
Kind Regards
Mervan

12 commentaires

Leonardo Falconi
Leonardo Falconi le 18 Avr 2017
Hi, I have problems downloading the stock price with the Yahoo fetch function. The code worked until Yesterday night, but today it is not. Do you know how can I fix it?
Running the code I get: "Error using yahoo Unable to connect or retrieve data from given URL."
Thanks Leonardo
Adriano
Adriano le 18 Avr 2017
I have the same problem. Yahoo worked very well 3 days ago but not today. I need fix the problem urgently!
Geoff Hayes
Geoff Hayes le 18 Avr 2017
Mervan - even if you copy and paste http://download.finance.yahoo.com into a browser, you should observe a Sorry, the page you requested was not found. What happens if you try http://finance.yahoo.com instead?
Adriano
Adriano le 18 Avr 2017
http://finance.yahoo.com works perfectly intead of http://download.finance.yahoo.com that returns 'Sorry, the page you requested was not found'.
I have the same problem, even if I use
stock = 'JPM'; from = '01/14/2000'; to = '01/13/2005'; kind = 'Close';
conn = yahoo('http://finance.yahoo.com');
data = fetch(conn,stock,kind,from,to);
The error is the following
Error using yahoo
Unable to connect or retrieve data from given URL.
Error in untitled13bis (line 4)
conn = yahoo('http://finance.yahoo.com');
Victor Hatman
Victor Hatman le 18 Avr 2017
Modifié(e) : Victor Hatman le 18 Avr 2017
I have the same problem when I try to get a connection to Yahoo. If I simply use:
>> c = yahoo
I am getting this error:
Error using yahoo Unable to connect or retrieve data from given URL.
Listing the contents of the yahoo command gives the default URL Matlab is using to connect:
>> type yahoo
function c = yahoo(url,ip,port)
%YAHOO Yahoo! datafeed object constructor.
% C = YAHOO verifies that the URL download.finance.yahoo.com is accessible and creates
% a connection handle.
%
% C = YAHOO(URL) creates the connection handle using the given URL. For example,
% 'http://download.finance.yahoo.com:80'. The difference in this URL from the default is
% the addition of the port number.
%
% See also CLOSE, FETCH, GET, ISCONNECTION.
% Copyright 1999-2008 The MathWorks, Inc.
If I cut and paste the default URL from the yahoo command in a web browser, I get an error message to the effect URL not found. However, if I click my way to Yahoo Finance, and pull some quote, the URL showing up in the address bar is https://finance.yahoo.com, which is different from the default URL. So, I tried running the yahoo command with this new URL, but I got the same error.
>> c=yahoo('https://finance.yahoo.com')
Error using yahoo Unable to connect or retrieve data from given URL.
I also tried with http instead of https. Same result... Any help will be greatly appreciated.
yes, exactly the same issue here:
>> c=yahoo
Error using yahoo
Unable to connect or retrieve data from given URL.
Lukas Mich
Lukas Mich le 19 Avr 2017
Seems like Yahoo made some changes to this API.... a few days ago I got an error while downloading historical data via the fetch command. It turned out, that the link that is built inside the fetch function
u = ['http://ichart.yahoo.com/table.csv?',...
failed because of the "http", as the URL has changed to "https". I manually amended the fetch function this way, and it worked fine until today...
Did somebody experienced the same issue?
Octavio Garcia
Octavio Garcia le 19 Avr 2017
The same happen to me with urlread and urlread2 and to several pople. Yahoo maybe broken something becasue is not only not works with me, with different methods to download the historical data doesnt work as well.
https://es.mathworks.com/matlabcentral/answers/335991-url-read-returns-status-of-1-but-no-data
Octavio Garcia
Octavio Garcia le 19 Avr 2017
....but I just changed after, read your post, http by https in the URL, and now WORKS!! using urlread
[temp, status] = urlread(strcat('https://ichart.finance.yahoo.com/table.csv?s='... ,tickers{i},'&a=',bm,'&b=',bd,'&c=',by,'&d=',em,'&e=',ed,'&f=',... ey,'&g=',freq,'&ignore=.csv'));% urlread2.urlread2( ... do the same
Richard Giroux
Richard Giroux le 20 Avr 2017
Modifié(e) : Walter Roberson le 21 Avr 2017
Hi all, I tried to connect to yahoo data using any of these today and don't work. Any idea if someone is dealing with this, or how to solve the issue?
Thanks, Richard
>> conn=yahoo('https://download.finance.yahoo.com'); Error using yahoo Unable to connect or retrieve data from given URL.
>> conn=yahoo('http://download.finance.yahoo.com'); Error using yahoo Unable to connect or retrieve data from given URL.
>> conn=yahoo('https://finance.yahoo.com'); Error using yahoo Unable to connect or retrieve data from given URL.
>> conn=yahoo('http://finance.yahoo.com'); Error using yahoo Unable to connect or retrieve data from given URL.
>> conn=yahoo('http://ichart.yahoo.com');Error using yahoo Unable to connect or retrieve data from given URL.
>> conn=yahoo('https://ichart.yahoo.com'); Error using yahoo Unable to connect or retrieve data from given URL.
hsch1234
hsch1234 le 22 Avr 2017
Hi Richard, Forget about the c=yahoo; Just do directly a urlread as Octavio mentions

Connectez-vous pour commenter.

 Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 2 Mai 2017
Modifié(e) : MathWorks Support Team le 2 Mai 2017

1 vote

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. https://www.mathworks.com/support/bugreports/1571158

Plus de réponses (8)

David Holland
David Holland le 20 Avr 2017

4 votes

Hello David,
My name is Will and I am writing in reference to your Technical Support Case #02539213 regarding 'c=yahoo'.
MATLAB uses Yahoo's API under the hood. Around April 18th 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 %MATLAB_ROOT%\toolbox\datafeed\datafeed\@yahoo\yahoo.p %MATLAB_ROOT%\toolbox\datafeed\datafeed\@yahoo\fetch.m
where %MATLAB_ROOT% can be found with the following MATLAB command: >> matlabroot
3) Place the downloaded files in the following locations: %MATLAB_ROOT%\toolbox\datafeed\datafeed\@yahoo\yahoo.m %MATLAB_ROOT%\toolbox\datafeed\datafeed\@yahoo\fetch.m
4) Run the following MATLAB command >> rehash toolboxcache >> clear classes Now you should be able to retrieve historic and current data as usual: >> % Historic data >> d = fetch(yahoo,'IBM','Close','01/01/2012','06/30/2012'); >> d(1:3,:) >> >> % Current data >> fetch(yahoo,'IBM')

10 commentaires

alex sant
alex sant le 20 Avr 2017
Hi, I'm also having the same problem. Could you please tell me were are the attached files? Thank you
Marie Noëlle
Marie Noëlle le 20 Avr 2017
Same question, where can we get the two files?
Victor Hatman
Victor Hatman le 21 Avr 2017
The location of the two files would be very helpful, indeed. Or a description of the changes that need to be made to the existing files...
Also, on my machine (Win 8.1, running R2017a), the yahoo.m file is in the datafeed directory, not in the @yahoo directory...
David Holland
David Holland le 21 Avr 2017
I want to share them
David Holland
David Holland le 21 Avr 2017
However, I am running into a different problem now, maybe because I am new to Matlab. If anybody is successful, do me a favor and post the codes.
sergei tyr
sergei tyr le 23 Avr 2017
Modifié(e) : sergei tyr le 23 Avr 2017
connection works, but fetch gives an error: Undefined function 'isstring' for input arguments of type 'cell'. Error in fetch (line 40) if ischar(s) isstring(s)
my line of code call fetch is: Price.(names{i})=fetch(c,ticker(i),'Adj Close',startDate,endDate,'m');
Andy
Andy le 30 Avr 2017
it worked for me on R2016b:
if true
>>
>> y = yahoo;
>> d = fetch(y,'IBM','Close','01/01/2012','06/30/2012');
>>
end
Amit K
Amit K le 2 Mai 2017
I've the same problem as Sergei tyr. got the same error message (see below) after replacing the yahoo.m and fetch.m files in the datafeed tool. Please help. I've a deadline in few days :-(
"Undefined function 'isstring' for input arguments of type 'cell'. Error in fetch (line 40) if ischar(s) isstring(s)"
Amit K
Amit K le 4 Mai 2017
"isstring" function is not available in Pre-R2017a. The above solution works only for the latest version.
duvnoo222
duvnoo222 le 20 Mai 2017
If you download the attachment in the link - https://www.mathworks.com/support/bugreports/1571158 - the files are fetch.m and yahoo.p, not yahoo.m. Is that correct?
Also, I put them into @yahoo and it still doesn't work. The error is (still) "Error using yahoo/fetch (line 387) Unable to return historical data for given security."
Any advice would be helpful.

Connectez-vous pour commenter.

tom3w
tom3w le 17 Mai 2017

1 vote

Is there a similar issue today this 5/17/2017? Impossible to load any data from my side. Thanks

6 commentaires

Xander Mann
Xander Mann le 17 Mai 2017
I'm experiencing something similar, it's really frustrating. Everything was working fine last night. Have you reported the bug?
Xander Mann
Xander Mann le 17 Mai 2017
but my error says:
Error using yahoo/fetch (line 387)
Unable to return historical data for given security.
Alex Layten
Alex Layten le 17 Mai 2017
Modifié(e) : Alex Layten le 17 Mai 2017
I'm having this exact problem. (line 387) It was actually working earlier today so I really have no idea what's going on.
Paul Shoemaker
Paul Shoemaker le 18 Mai 2017
I'm having the same problem. I've found that I'm able to get data for the current day with "fetch(yahoo,'SYMBOL')". In other words, just get the latest bar of data by leaving off all other parameters in the fetch command except the symbol.
This worked yesterday and then today as well. So if you have a database of historical data that's up to date then you can retrieve the current trading day data and append. That's what I did yesterday and again today. This is not a long-term solution so hopefully Yahoo fixes the issue shortly.
Octavio Garcia
Octavio Garcia le 18 Mai 2017

These are the 2 link about the Yahoo API related to this problem. I hope they will be wrong and exist someone in YAHOO that put this service back.....but looks like no more intelligent life in Yahoo.

https://yahoo.uservoice.com/forums/382977-finance/suggestions/19310356-https-ichart-finance-yahoo-com-table-csv-s-spy-a

https://yahoo.uservoice.com/forums/382977-finance/suggestions/19307365-ichart-is-off-line

Denis Alaev
Denis Alaev le 18 Juin 2017
It seems that after several changes Yahoo Finance closed their API forever, I think that's just Verizon costs cutting strategy and I'm pretty sure this API will not be working again. The API was closed on May 15, one month ago already.
I've tested several alternatives and found that https://eodhistoricaldata.com 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, API Documentation and even VBA Examples, you can find them in Knowledgebase.
Also there is a https://intrinio.com/ 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.

Connectez-vous pour commenter.

Christopher Reeves
Christopher Reeves le 24 Mai 2017

1 vote

It seems that yahoo finance has changed its API. I could not figure out how to fetch from their new API, so I made a script for google instead.
Here is the new function
Cheers
-Chris Reeves (Bayes Quant)

1 commentaire

dpb
dpb le 12 Juil 2017
Modifié(e) : dpb le 12 Juil 2017
What's the symbol formatting to return mutual fund data? Hand trying at the google site retrieved UNCMX but neither the symbol alone nor 'MUTF:UNCMX' succeed with the function -- "...did not find a resource to match this request."
It does work with the stock symbol so it's not something I fouled up in copying the function over; it is about how to look up mutual fund data instead of stocks...
ADDENDUM
Guess I found an answer -- there appears a difference at the google site when one clicks on historical data for mutual funds a .csv page is brought up but the Export link is not made active as is with stocks--so while the data are available, they're not in the same format as with the ticker data apparently; at least not yet.
I was able to solve the immediate need by a manual download from the Yahoo site...

Connectez-vous pour commenter.

Amit K
Amit K le 4 Mai 2017

0 votes

Where are the attached files. The solution provided by Mathworks is useless. Unable to replace the yahoo.p file. Just bought the new license and still datafeed/yahoo/fetch does not work.
Amit

1 commentaire

Steven Lord
Steven Lord le 5 Mai 2017
If following the instructions in the Bug Report linked in the Support team's answer did not work for you, please contact the Support staff using the Contact Us link in the upper-right corner of this page and ask them for further assistance. Let them know that you have tried those instructions and describe what happened (error messages, warning messages, etc.) when you tried.

Connectez-vous pour commenter.

Mervan Aksu
Mervan Aksu le 11 Mai 2017
Modifié(e) : Mervan Aksu le 20 Mai 2017

0 votes

ı apply the changes to R2014A and it worked. Thanks everyone who were kind enough to respond.
Mervan
Update it again start to give following error Error using yahoo/fetch (line 387) Unable to return historical data for given security.
Luis Sanchez
Luis Sanchez le 21 Mai 2017

0 votes

I appreacite the effort put to solve the bug from a couple months ago.
But this weekend i found another bug.... " Error using yahoo/fetch (line 387) Unable to return historical data for given security "
Any thoughts or solutions?
free5721
free5721 le 28 Mai 2017

0 votes

I first encountered this problem back in April 2017. I used the Matlab fix mentioned above and it resolved the problem. However, now at the end of May 2017 the same (or at least similar) problem has reappeared when fetch is used. Is Matlab support working on a solution to this apparently new problem?
Artem Lensky
Artem Lensky le 29 Août 2018
Modifié(e) : Artem Lensky le 29 Août 2018

0 votes

Please check the following code yahoo finance downloader it should be able to download historical data.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by