MATLAB Answers

fetching data from yahoo

84 ビュー (過去 30 日間)
Mervan Aksu
Mervan Aksu 2017 年 4 月 18 日
編集済み: Artem Lenskiy 2018 年 8 月 29 日
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 件のコメント
hsch1234
hsch1234 2017 年 4 月 22 日
Hi Richard, Forget about the c=yahoo; Just do directly a urlread as Octavio mentions

サインインしてコメントする。

採用された回答

MathWorks Support Team
MathWorks Support Team 2017 年 5 月 2 日
編集済み: MathWorks Support Team 2017 年 5 月 2 日
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

その他の回答 (8 件)

David Holland
David Holland 2017 年 4 月 20 日
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 件のコメント
duvnoo222
duvnoo222 2017 年 5 月 20 日
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.

サインインしてコメントする。


tom3w
tom3w 2017 年 5 月 17 日
Is there a similar issue today this 5/17/2017? Impossible to load any data from my side. Thanks
  6 件のコメント
Denis Alaev
Denis Alaev 2017 年 6 月 18 日
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.

サインインしてコメントする。


Christopher Reeves
Christopher Reeves 2017 年 5 月 24 日
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 件のコメント
dpb
dpb 2017 年 7 月 12 日
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...

サインインしてコメントする。


Amit K
Amit K 2017 年 5 月 4 日
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 件のコメント
Steven Lord
Steven Lord 2017 年 5 月 5 日
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.

サインインしてコメントする。


Mervan Aksu
Mervan Aksu 2017 年 5 月 11 日
編集済み: Mervan Aksu 2017 年 5 月 20 日
ı 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 2017 年 5 月 21 日
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 2017 年 5 月 28 日
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?
  1 件のコメント
Steven Lord
Steven Lord 2017 年 5 月 28 日
See this Answer for more information.

サインインしてコメントする。


Artem Lenskiy
Artem Lenskiy 2018 年 8 月 29 日
編集済み: Artem Lenskiy 2018 年 8 月 29 日
Please check the following code yahoo finance downloader it should be able to download historical data.

Community Treasure Hunt

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

Start Hunting!

Translated by