File Exchange

image thumbnail

Historical Stock Data Download (alternate Method)

version 3.0 (2.66 KB) by

Retrieves historical stock data from Yahoo Finance by parsing html pages instead of .csv download.



View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

This is an updated function to retrieve historical data from Yahoo Finance.
Apparently they changed things around May 2017 and previous versions of these types of functions stopped working. This is a completely new version that should now work (as of November 2017).

Comments and Ratings (10)

Odemir Bruno

Peter Gruber

Hi, congrats! It seems there are two small errors

line 47 should be
if nargin <2

line 48 should be
d1 = datenum(d2)-100;

New version. Should work now.


Unforunatly, this doesn't work anymore. I got this error.

>> get_yahoo_stockdata2('IBM','01-Mar-2008')
Downloaded IBM stock date for 01-Mar-2008 to 23-Apr-2017
Downloading data from page 1
Warning: stock data download failed: IBM
> In get_yahoo_stockdata2 at 180


Josiah Renfree

Josiah Renfree (view profile)

Thanks for the info regarding the Dow Jones data. That's very odd and annoying, but it is what it is.


I use 7.6.0 version ( R2008a) and i have a problem with this function:

??? Input argument "ticker" is undefined.

Error in ==> get_yahoo_stockdata2 at 98

Do you have an idea to resolve this bug?
Thank you!

yan Chen



Jia (view profile)

I'll try on R2012b then,see if it works.


I'm tried this in R2012b and did not get any errors.


Jia (view profile)

Hi there, I'm absolutely new to Matlab, when I run this function, it tell me

>> get_yahoo_stockdata2
Error: File: get_yahoo_stockdata2.m Line: 1 Column: 39
Unexpected MATLAB expression.

I'm running the R0212a version, is it the problem?



Updated to handle new format of data from yahoo.

MATLAB Release
MATLAB 9.0 (R2016a)

Inspired by: hist_stock_data(start_date, end_date, varargin)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today