Register & Get Data

Simple Example

It’s easy to use our API with MatLab without API connector also; below you can find a straightforward example with explanations for MatLab users.

url = 'http://nonsecure.eodhd.com/api/table.csv?s=AAPL.US&api_token=YOUR_API_KEY&a=0&b=1&c=2000&d=5&e=16&f=2017&g=d';

options = weboptions('ContentType','text');
s=webread(url,options);

C = textscan(s, '%s%f%f%f%f%f%f', 'HeaderLines', 1, 'delimiter', ',', 'CollectOutput', 0);

disp(C)

For testing purposes, you can use this API Key: api_token=demo. It works with AAPL.US only.

As you see, it’s easy to use. Usually, if you used before Yahoo Finance, then URL variable should look like this:

http://ichart.finance.yahoo.com/table.csv.....

and basically, all you need is to change the beginning of the URL to

 http://nonsecure.eodhd.com/api/table.csv

and then add your API Key as an additional parameter.

Please note, that it’s better to use HTTP instead of HTTPS for MatLab projects. And since we do automatic redirects, you should use special sub-domain without redirects: nonsecure.eodhd.com

Matlab Stock API Connector

MATLAB Stock API Example

Simply download and extract the EODML.zip file from the Undocumented Matlab website in a folder on your Matlab path, then run the EODML command with self-explanatory parameters.

The usage is very user-friendly, as explained on UndocumentedMatlab.com (for example, case-insensitive parameter names with default values, different ways to specify start/end dates, etc.) Some usage examples are below.

Usage Example I. Get Live/Delayed Prices

>> data =
EODML('prices', 'symbol','AAPL', 'datatype','live')
data = 
  struct with fields:
           symbol: 'AAPL.US'
        timestamp: 1577480400
        gmtoffset: 0
             open: 291.12
             high: 293.97
              low: 288.12
            close: 289.8
           volume: 36566500
    previousClose: 289.91
           change: -0.11
         change_p: -0.038
      datestr_GMT: '27-Dec-2019 21:00:00'
      datenum_GMT: 737786.875

Usage Example II. Get Historic Prices for Multiple Stocks

>> data =
EODML('prices', 'symbols','IBM,AAPL,GOOG', 'FromDate',20191203, 'ToDate','2019/12/13', 'DataType','day')
data = 
  9×3 struct array with fields:
    symbol
    date
    datenum
    open
    high
    low
    close
    adjusted_close
    volume
>> data(1,2)
ans = 
  struct with fields:
            symbol: 'AAPL.US'
              date: '2019-12-03'
           datenum: 737762
              open: 258.31
              high: 259.53
               low: 256.29
             close: 259.45
    adjusted_close: 259.45
            volume: 29377268

Usage Example III. Get Fundamental Data

 >> data = EODML('fundamental', 'symbol','AAPL')
 data = 
   struct with fields:
                symbol: 'AAPL.US'
               General: [1×1 struct]
            Highlights: [1×1 struct]
             Valuation: [1×1 struct]
           SharesStats: [1×1 struct]
            Technicals: [1×1 struct]
       SplitsDividends: [1×1 struct]
             ESGScores: [1×1 struct]
     outstandingShares: [1×1 struct]
              Earnings: [1×1 struct]
            Financials: [1×1 struct]

Usage Example IV. Get Historic Earning Reports

>> data =
EODML('earnings', 'symbol','AAPL', 'fromdate','2019-01-01')
data = 
  4×1 struct array with fields:
    symbol
    report_date
    date
    datenum
    actual
    estimate
    difference
    percent
>> struct2table(data)
ans =
  4×8 table
     symbol   report_date  date         datenum  actual  estimate    
difference percent
    'AAPL.US' '2019-01-29' '2018-12-31'  737425  4.18    4.17  
0.01       0.24
    'AAPL.US' '2019-04-30' '2019-03-31'  737515  2.46    2.36  
0.10       4.24
    'AAPL.US' '2019-07-30' '2019-06-30'  737606  2.18    2.10  
0.08       3.81
    'AAPL.US' '2019-10-30' '2019-09-30'  737698  3.03    2.84  
0.19       6.69

…and so on for the entire EODHD offering. You can read more about the EODML connector on https://UndocumentedMatlab.com/EODML

About the Author

Yair Altman is a recognized Matlab expert with 30 years of experience. Yair published two textbooks on Matlab and is a member of the MathWorks advisory board. He is widely known in the Matlab user community from his UndocumentedMatlab website and contributions to public forums. Yair posted numerous free Matlab code and developed multiple commercial Matlab connectors and programs for the finance sector. Read more on http://UndocumentedMatlab.com

Register & Get Data