MATLAB Answers

Datafeed returns an error using fetch function

9 ビュー (過去 30 日間)
Adriano
Adriano 2017 年 4 月 18 日
コメント済み: Denis Alaev 2017 年 6 月 18 日
Hi everybody,
I'm trying to use "fetch" function with this code:
fetch(yahoo,'SPY',today())
but I recive this error:
Error using yahoo Unable to connect or retrieve data from given URL.
I used the same code 3 days ago and it worked. What's going on? Thanks!

  0 件のコメント

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

採用された回答

MathWorks Support Team
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

  0 件のコメント

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

その他の回答 (6 件)

Shashank
Shashank 2017 年 4 月 21 日
Hi Adraino,
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
%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')

  5 件のコメント

表示 2 件の古いコメント
James Richard
James Richard 2017 年 5 月 30 日
Hi, how to find the attached files? thx
marcobar975
marcobar975 2017 年 6 月 14 日
I cannot find the attachment either...
Walter Roberson
Walter Roberson 2017 年 6 月 14 日
The attachments were withdrawn. Yahoo changed their system, disabling the interface that MATLAB used, and has not replaced it with anything useful as yet. You will not be able to get historical data from yahoo until Yahoo implements some new arrangment, and Mathworks writes a new routine to access it.

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


Philippe Loustaunau
Philippe Loustaunau 2017 年 4 月 21 日
I tried this and it is not working. First there is inconsistency in the answer: The file you provided is yahoo.m, but you suggest we delete yahoo.p. The yahoo.m file is in the datafeed directory, the yahoo.p file is in the @yahoo directory, inside the datafeed directory. Since you attached the yahoo.m file, I assume you wanted to replace the one in the datafeed directory. I followed the steps, but it is not working, same error.

  2 件のコメント

Duncan Aitken
Duncan Aitken 2017 年 4 月 25 日
It works if you follow the instructions correctly.
The '@' character in the @yahoo folder name indicates that it's a class folder. Inside that folder are the class definition file and method files.
yahoo.p is an obfuscated version the yahoo class definition.
The new yahoo.m is a new yahoo class definition to replace the old one that was causing the error.
Replacing the yahoo.m in the datafeed directory was a mistake.
Philippe Loustaunau
Philippe Loustaunau 2017 年 4 月 25 日
thank you, I got it to work.

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


Alexandre Amorim
Alexandre Amorim 2017 年 4 月 30 日
Sweet!! Simple to solve and works fine!

  0 件のコメント

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


avia gubbuy alon
avia gubbuy alon 2017 年 5 月 19 日
again not working. please help.

  1 件のコメント

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 (https://eodhistoricaldata.com/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.

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


Munir Ruffo
Munir Ruffo 2017 年 5 月 29 日
Where can i download the two mentioned files yahoo.m and fetch.m ? Can't find it anywhere!!
Thanks!

  0 件のコメント

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


Adriano
Adriano 2017 年 5 月 29 日
This is the Mathworks answer on my Technical Support on yahoo fetch function:
I sincerely apologize for the recent issues you may have encountered while connecting to the Yahoo service using the Datafeed Toolbox.
Yahoo has reportedly changed its API and site structure, which has resulted in the above error. According to Yahoo's forum, "ichart.yahoo.com" will undergo structural changes that will not cover existing functionality. Since "fetch" accesses "ichart.yahoo.com" to fetch historical and intraday data, connecting to Yahoo using the Datafeed Toolbox is no longer supported.

  0 件のコメント

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


Translated by