>> Help: Matlab code to fetch stock price data from yahoo finance
이전 댓글 표시
I am a student who is getting used to Matlab.
I am trying to write a Matlab code that will goto yahoo finance, get the price of a specific stock and save it into a text file.
I am using urlread / urlwrite commands, but I have not been successful. Can anyone show me a sample script file or point me to a relevant link. Thanks in advance.
댓글 수: 1
Geoff
2012년 4월 16일
What is the URL you are trying to access?
답변 (3개)
Jessica Lam
2012년 4월 17일
If you have datafeed toolbox, you may try the following code.
conn = yahoo('http://download.finance.yahoo.com');
Yahoo_HSI_Data = fetch(conn,{'^HSI'},{'Adj Close'},'2012-01-01','2012-04-01','d');
You will get Hang Seng Index daily Adjusted Close Data from 2010-01-01 to 2012-04-01 . The first col is Date. And the second col is Close Price .
you may find the following link for your ref. . * http://www.mathworks.com.au/help/toolbox/datafeed/yahoo.html * http://www.mathworks.com.au/help/toolbox/datafeed/yahoo.fetch.html
댓글 수: 2
Adam Agus Kurniawan
2020년 8월 31일
it doesn't work anymore :(
stefanos asiklaris
2020년 9월 18일
Why i am not able to load yahoo ?Did it get removed from datafeed toolbox?
Ken Atwell
2012년 4월 17일
To grab a single delayed quote (using Apple -- AAPL -- as an example here).
txt=urlread('http://download.finance.yahoo.com/d/quotes.csv', 'get', ...
{'s', 'AAPL', 'f', 'sl1d1t1c1ohgv', 'e', '.csv'} )
This return a line of text with around 10 comma-separated datum (timestamp, bid, ...). Honestly, I don't understand the magic string in the format ('f') passed to the server, but the command will fail if you omit it.
This may be enough for casual use, but serious users will want to look into MathWorks products like the Datafeed Toolbox.
댓글 수: 3
Image Analyst
2021년 6월 8일
Doesn't work anymore. No such Yahoo web page anymore. Any updated code that does work without special toolboxes?
Error using urlreadwrite (line 90)
The IP address of "download.finance.yahoo.com" could not
be determined.
Error in urlread (line 47)
[s,status] =
urlreadwrite(mfilename,catchErrors,url,varargin{:});
Error in test1 (line 1)
txt=urlread('http://download.finance.yahoo.com/d/quotes.csv',
'get', ...
Paul Safier
2021년 11월 18일
@Image Analyst : have you made any progress on this? I have used the submission getMarketDataViaYahoo.m successfully, but I'm looking for a way to get intraday data, i.e. with a frequency on the order of minutes and not 1 day...
Cengiz Esmersoy
2021년 12월 12일
Note that in "getMarketDataViaYahoo" the AdjustedClose for ETFs are incorrect. They are not adjusted.
Benjamin
2014년 3월 6일
0 개 추천
This program does can fetch stock price data from yahoo and google finance
Very simple to use.
댓글 수: 1
Michael Quinatoa
2020년 9월 21일
Does this still work ?
카테고리
도움말 센터 및 File Exchange에서 Web Services에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!