Yahoo Finance and Quandl data downloader

YahooFinance/Quandl data downloader
7.3K Downloads
Updated 7 Mar 2021
The toolbox contains two functions:
(a) getMarketDataViaYahoo()
% INPUT:
% symbol - is a ticker symbol i.e. 'AMD', 'BTC-USD'
% startdate - the market data will be requested from this data
% enddate - the market data will be requested till this date
% interval - the market data will be returned in this intervals
% supported intervals are '1d', '5d', '1wk', '1mo', '3mo'
%
% OUTPUT:
% data - is a retrieved dataset returned as a table
data = getMarketDataViaYahoo('AMD', '1-Jan-2018', datetime('today'), '5d'); % Downloads AMD share historic price
(b) getMarketDataViaQuandl()
% INPUT:
% set_name - is a dataset name e.g. 'WIKI/AAPL'
% startdate - the market data will be requested from this data
% enddate - the market data will be requested till this date
% collapse - the market data will be returned in this intervals
% supported intervals are 'daily', 'weekly', 'monthly', 'quarterly', 'annual'
% key - user's api key
%
% OUTPUT:
% data - is a retrieved dataset returned as a table
opec_orb_raw = getMarketDataViaQuandl('OPEC/ORB', '1-Jan-2018', date(), 'weekly'); % Downloads historic OPEC basket price from Quandl
For a complete list of free datasets provided by Quandl check https://www.quandl.com/search?filters=%5B%22Free%22%5D
Examples:
(a) Yahoo Finance
disp('Request historical YTD Bitcoin price and plot Close, High and Low');
initDate = '1-Jan-2018';
symbol = 'BTC-USD';
btcusd = getMarketDataViaYahoo(symbol, initDate);
btcusdts = timeseries([btcusd.Close, btcusd.High, btcusd.Low], datestr(btcusd(:,1).Date));
btcusdts.DataInfo.Units = 'USD';
btcusdts.Name = symbol;
btcusdts.TimeInfo.Format = "dd-mm-yyyy";
plot(btcusdts);
legend({'Close', 'High', 'Low'});
(b) Quandl
dataset = 'LBMA/GOLD';
initDate = '1-Jan-2018';
lbma_gold_raw = getMarketDataViaQuandl(dataset, initDate, date(), 'daily');
lbma_gold_ts = timeseries(lbma_gold_raw.("EURO(AM)"), datestr(lbma_gold_raw.Date));
lbma_gold_ts.DataInfo.Units = 'USD';
lbma_gold_ts.Name = dataset;
lbma_gold_ts.TimeInfo.Format = "dd-mm-yyyy";
figure, plot(lbma_gold_ts);

Cite As

Artem Lensky (2024). Yahoo Finance and Quandl data downloader (https://github.com/Lenskiy/Yahoo-Quandl-Market-Data-Donwloader/releases/tag/v1.131), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2018a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired: Yahoo! Finance Data Loader

Community Treasure Hunt

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

Start Hunting!

Versions that use the GitHub default branch cannot be downloaded

Version Published Release Notes
1.131

See release notes for this release on GitHub: https://github.com/Lenskiy/Yahoo-Quandl-Market-Data-Donwloader/releases/tag/v1.131

1.130

.

1.13

Added Big Mac example

1.12

* removes rows with missing values

1.11

The function has been updated according to the new Yahoo interface.

1.03

Data older than 1970 can now be downloaded.

1.02

Seems crumb value is not required anymore, hence now the function continues even if crumb is not found.

1.01

Thanks to Christian, Xiang Chen Fixed, Ryan Hendry for pointing out the bug. The most recent sample was not loaded. The problem was in two slightly different formats data is returned by Quandl and Yahoo. The bug is fixed.

0.934

Fixed a bug

0.933

.

0.932

Fixed a bug in getMarketDataViaQuandl()

0.931

.

0.93

fixed bug in getMarketDataViaQuandl()

0.92

Added Quandl data downloader

0.91

404 error has been dealt with

0.9

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.