>> Help: Matlab code to fetch stock price data from yahoo finance

60 vues (au cours des 30 derniers jours)
Tapan Samaddar
Tapan Samaddar le 16 Avr 2012
Commenté : Cengiz Esmersoy le 12 Déc 2021
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 commentaire
Geoff
Geoff le 16 Avr 2012
What is the URL you are trying to access?

Connectez-vous pour commenter.

Réponses (3)

Jessica Lam
Jessica Lam le 17 Avr 2012
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 .
  2 commentaires
Adam Agus Kurniawan
Adam Agus Kurniawan le 31 Août 2020
it doesn't work anymore :(
stefanos asiklaris
stefanos asiklaris le 18 Sep 2020
Why i am not able to load yahoo ?Did it get removed from datafeed toolbox?

Connectez-vous pour commenter.


Ken Atwell
Ken Atwell le 17 Avr 2012
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 commentaires
Paul Safier
Paul Safier le 18 Nov 2021
@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
Cengiz Esmersoy le 12 Déc 2021
Note that in "getMarketDataViaYahoo" the AdjustedClose for ETFs are incorrect. They are not adjusted.

Connectez-vous pour commenter.


Benjamin
Benjamin le 6 Mar 2014
This program does can fetch stock price data from yahoo and google finance
Very simple to use.

Community Treasure Hunt

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

Start Hunting!

Translated by