How to Store Stock Market Data Locally with Python: A Step-by-Step Guide to Saving OHLCV Data from EODHD

In a previous post, I showed how to store symbol data from EODHD. The purpose of this code is to now iterate through all those symbols and grab the Open, High, Low, Close, Adjustable Close, and Volume data from EODHD using their API.

Output

This code will contain data for each stock symbol similar to this example for TSLA below for all 48,292 stocks.

INFO:root:Processing 48930 symbols
INFO:root:                Open      High       Low     Close  Adjusted_close     Volume
Date                                                                         
2010-06-29   18.9999   24.9999   17.5401   23.8899          1.5927  281749173
2010-06-30   25.7901   30.4191   23.3001   23.8299          1.5887  257915884
2010-07-01   24.9999   25.9200   20.2701   21.9600          1.4640  123447940
2010-07-02   23.0001   23.1000   18.7101   19.2000          1.2800   77127102
2010-07-06   20.0001   20.0001   15.8301   16.1100          1.0740  103189435
...              ...       ...       ...       ...             ...        ...
2023-10-17  250.1000  257.1830  247.0800  254.8500        254.8500   93562914
2023-10-18  252.7000  254.6300  242.0800  242.6800        242.6800  125147797
2023-10-19  225.9500  230.6100  216.7800  220.1100        220.1100  170772703
2023-10-20  217.0100  218.8606  210.4200  211.9900        211.9900  138010094
2023-10-23  210.0000  216.9800  202.5100  212.0800        212.0800  150215161

Overview of the Script


The script performs the following tasks:

  • Reads a list of stock symbols from an HDF5 file that we created previously which contains all the US stock symbols.
  • Fetches the EOD stock price data for each symbol via an API call.
  • Stores the fetched data in an HDF5 file.
  • Keeps track of the last downloaded time for each symbol in a JSON log file.
  • Allows for skipping previously downloaded data.
  • Plots a simple candlestick chart of the data.

Deep Dive into the Code

Let’s dissect the code step by step, explaining each function’s purpose and the underlying logic.

  1. Initial Setup

Before diving into the functions, you’ve set up some important libraries and configurations:

  • Logging: Helps in tracking the flow and potential issues in the code.
  • Data Directory: A designated path where you store or read data.
  • API Key: Securely imported from a separate keys.py file to maintain security and modularity.
  1. Function: get_symbols

This function is designed to fetch stock symbols from an existing HDF5 file.

It first checks if the file exists. If not, it logs an informative message.
Then, it attempts to read the HDF5 file into a DataFrame.
The function ensures that the ‘Code’ column exists before extracting the list of symbols.

  1. Function: fetch_eod_price_data

This is the core function of your script. Its main responsibilities include:

  • Fetching the EOD stock price data for each symbol.
  • Skipping data that has recently been downloaded, using logs.
  • Storing the fetched data in an HDF5 file.
  • The function maintains a log of the last downloaded time for each symbol. This helps in efficiently updating your data without redundant API calls.
  1. Main Execution

After defining the utility functions, the main execution of the script begins:

  • A list of stock symbols is fetched using the get_symbols function.
  • The fetch_eod_price_data function is called to update the EOD price data.
  1. Function: plot_candlestick_with_volume

This function is designed to visually represent the stock data:

  • It fetches the data for a particular stock from the HDF5 file.
  • Filters the data based on the provided start and end dates.
  • Plots a candlestick chart representing the stock’s price movements.
  • On the same chart, it overlays a volume bar chart to indicate trading volumes on respective dates.
  1. Visualization

Finally, a candlestick chart with volume bars for the stock ‘TSLA’ is plotted for a specific date range.

Conclusion

This script provides a streamlined approach to fetch, store, and visualize EOD stock price data. The modular design makes it easy to adapt and extend the functionalities as needed. Whether you’re a seasoned trader or just someone intrigued by stock market data, this script offers a solid foundation to build upon.

In future posts, we’ll use Facebook’s Prophet to forward forecast this data into the future.

Code

import pandas as pd
import requests
from io import StringIO
from pathlib import Path
import logging
import json
from datetime import datetime, timedelta
from tqdm import tqdm
import matplotlib.pyplot as plt
from mplfinance.original_flavor import candlestick_ohlc
import matplotlib.dates as mdates




logging.basicConfig(level=logging.DEBUG)

data_dir = '/home/shared/algos/data/'
log_file_path = "symbol_price_data_time_log.json"

from keys import api_token

def get_symbols(h5_file_path, key='US'):
    """
    Open an HDF5 file and return a list of symbols from the 'Code' column.

    Parameters:
        h5_file_path (str): The path to the HDF5 file.
        key (str): The key to use when reading the HDF5 file. Default is 'exchanges'.

    Returns:
        list: A list of symbols if successful; otherwise, an empty list.
    """

    h5_file_path = Path(h5_file_path)

    # Check if the file exists
    if not h5_file_path.exists():
        logging.info(f"The file {h5_file_path} does not exist.")
        return []

    try:
        # Read the DataFrame from the HDF5 file
        df = pd.read_hdf(h5_file_path, key=key)

        # Check if 'Code' column exists
        if 'Code' not in df.columns:
            logging.info(f"The 'Code' column does not exist in the DataFrame.")
            return []

        # Get the list of symbols from the 'Code' column
        symbols = df['Code'].tolist()

        return symbols

    except Exception as e:
        logging.error(f"An error occurred: {e}")
        return []


def fetch_eod_price_data(stock_symbols, data_dir, log_file, skip_existing=True, hours_to_skip=24):
    # Load existing logs if available
    try:
        with open(log_file, 'r') as f:
            symbol_time_dict = json.load(f)
    except FileNotFoundError:
        symbol_time_dict = {}

    all_data = {}
    count = 0

    # Create the directory if it doesn't exist
    Path(data_dir).mkdir(parents=True, exist_ok=True)
    hdf5_file_path = f"{data_dir}/eod_price_data.h5"

    existing_symbols = set()

    if skip_existing:
        with pd.HDFStore(hdf5_file_path, 'r') as store:
            existing_symbols = {key[1:] for key in store.keys()}


    for symbol in tqdm(stock_symbols, desc='Fetching and storing EOD price data'):
        last_downloaded_time = symbol_time_dict.get(symbol, None)

        if skip_existing and symbol in existing_symbols:
            continue

        if last_downloaded_time:
            last_downloaded_time = datetime.fromisoformat(last_downloaded_time)
            time_since_last_download = datetime.now() - last_downloaded_time
            if time_since_last_download < timedelta(hours=hours_to_skip):
                logging.info(f"Data for symbol {symbol} was downloaded recently. Skipping...")
                continue

        logging.info(f"{symbol}: Downloading from EODHD...")
        url = f'https://eodhd.com/api/eod/{symbol}.US?api_token={api_token}&fmt=csv'
        response = requests.get(url)
        if response.status_code != 200:
            logging.error(f"Failed to fetch data for symbol {symbol}. HTTP Status Code: {response.status_code}")
            continue

        csv_data = StringIO(response.text)
        df = pd.read_csv(csv_data)


        if 'Date' not in df.columns:
            logging.error(f"No 'Date' column in the data for symbol {symbol}. Skipping...")
            logging.error(f"Data received: {response.text}")
            continue

        # Set 'Date' as DateTime index
        df['Date'] = pd.to_datetime(df['Date'])
        df.set_index('Date', inplace=True)

        # Add the DataFrame to the all_data dictionary
        all_data[symbol] = df

        # Update log
        symbol_time_dict[symbol] = datetime.now().isoformat()
        with open(log_file, 'w') as f:
            json.dump(symbol_time_dict, f)

        count += 1

        # Update the HDF5 file every 100 symbols
        if count % 100 == 0:
            with pd.HDFStore(hdf5_file_path, mode='a') as store:
                for symbol, data in all_data.items():
                    store.put(symbol, data)
            logging.info(f"Saved {list(all_data.keys())} to HDF5 file.")
            all_data = {}

    # Save remaining data to HDF5
    if all_data:
        with pd.HDFStore(hdf5_file_path, mode='a') as store:
            for symbol, data in all_data.items():
                store.put(symbol, data)
        logging.info(f"Saved remaining {list(all_data.keys())} to HDF5 file.")

    logging.info("Finished updating HDF5 file.")



symbols = get_symbols(data_dir + 'symbols.h5', key='US')
logging.info(f'Processing {len(symbols)} symbols')


fetch_eod_price_data(symbols, data_dir, log_file_path, skip_existing=True, hours_to_skip=72)


symbol = 'TSLA'
hdf5_file_path = f"{data_dir}/eod_price_data.h5"


def plot_candlestick_with_volume(symbol, hdf5_file_path, start_date, end_date):
    with pd.HDFStore(hdf5_file_path, 'r') as store:
        if f'/{symbol}' in store.keys():
            df = store.get(symbol)
            logging.info("Data fetched successfully.")

            # Filter the DataFrame based on the start and end dates
            df = df[start_date:end_date]

            # Ensure the DataFrame is sorted by date
            df = df.sort_index()

            # Convert date to a format that can be used by candlestick_ohlc
            df['Date'] = df.index.map(mdates.date2num)

            # Create subplots: one for candlestick, one for volume
            fig, ax1 = plt.subplots(figsize=(10, 6))
            ax2 = ax1.twinx()

            # Plot candlestick chart
            ohlc = df[['Date', 'Open', 'High', 'Low', 'Adjusted_close']].copy()
            candlestick_ohlc(ax1, ohlc.values, width=0.6, colorup='green', colordown='red')
            ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d'))
            ax1.set_xlabel('Date')
            ax1.set_ylabel('Price')
            ax1.set_title(f'Candlestick chart for {symbol} ({start_date} to {end_date})')
            ax1.grid(True)

            # Plot volume
            ax2.bar(df.index, df['Volume'], color='gray', alpha=0.3)
            ax2.set_ylabel('Volume')

            plt.show()

        else:
            logging.info(f"No data found for symbol: {symbol}")


symbol = 'TSLA'
hdf5_file_path = f"{data_dir}/eod_price_data.h5"
start_date = '2023-01-01'
end_date = '2023-10-23'
plot_candlestick_with_volume(symbol, hdf5_file_path, start_date, end_date)

Storing Stock Market Indices and Symbols with EODHD

If you’re looking to perform complex analyses, backtests, or even develop your own trading algorithms you’re going to need access to good data. What I’m going to show you today is how to use EODHD to get a list of all the exchanges in their database. Then we will use all of the symbols from the exchange to download information about that stock symbol. In a later post, we will then use these symbols to retrieve all the corporate fundamental data for that stock.

This code will generate a dataframe of Exchanges you can see that EODHD offers data on 77 different exchanges.

Exchanges

                             Name    Code OperatingMIC         Country Currency CountryISO2 CountryISO3
0                      USA Stocks      US   XNAS, XNYS             USA      USD          US         USA
1                 London Exchange     LSE         XLON              UK      GBP          GB         GBR
2                    NEO Exchange     NEO         NEOE          Canada      CAD          CA         CAN
3            TSX Venture Exchange       V         XTSX          Canada      CAD          CA         CAN
4                Toronto Exchange      TO         XTSE          Canada      CAD          CA         CAN
5                 Berlin Exchange      BE         XBER         Germany      EUR          DE         DEU
6                Hamburg Exchange      HM         XHAM         Germany      EUR          DE         DEU
7                  XETRA Exchange   XETRA         XETR         Germany      EUR          DE         DEU
8             Dusseldorf Exchange      DU         XDUS         Germany      EUR          DE         DEU
9                 Munich Exchange      MU         XMUN         Germany      EUR          DE         DEU
10               Hanover Exchange      HA         XHAN         Germany      EUR          DE         DEU
11             Frankfurt Exchange       F         XFRA         Germany      EUR          DE         DEU
12             Stuttgart Exchange     STU         XSTU         Germany      EUR          DE         DEU
13                Vienna Exchange      VI         XWBO         Austria      EUR          AT         AUT
14      Luxembourg Stock Exchange      LU         XLUX      Luxembourg      EUR          LU         LUX
15                 Euronext Paris      PA         XPAR          France      EUR          FR         FRA
16              Euronext Brussels      BR         XBRU         Belgium      EUR          BE         BEL
17                Madrid Exchange      MC         BMEX           Spain      EUR          ES         ESP
18             SIX Swiss Exchange      SW         XSWX     Switzerland      CHF          CH         CHE
19                Euronext Lisbon      LS         XLIS        Portugal      EUR          PT         PRT
20             Euronext Amsterdam      AS         XAMS     Netherlands      EUR          NL         NLD
21             Stockholm Exchange      ST         XSTO          Sweden      SEK          SE         SWE
22                 Irish Exchange      IR         XDUB         Ireland      EUR          IE         IRL
23            Copenhagen Exchange      CO         XCSE         Denmark      DKK          DK         DNK
24            Oslo Stock Exchange      OL         XOSL          Norway      NOK          NO         NOR
25               Iceland Exchange      IC         XICE         Iceland      ISK          IS         ISL
26              Helsinki Exchange      HE         XHEL         Finland      EUR          FI         FIN
27          Malawi Stock Exchange     MSE         XMSW          Malawi      MWK          MW         MWI
28              Egyptian Exchange     EGX         XCAI           Egypt      EGP          EG         EGY
29       Botswana Stock Exchange     XBOT         XBOT        Botswana      BWP          BW         BWA
30           Ghana Stock Exchange     GSE         XGHA           Ghana      GHS          GH         GHA
31   Regional Securities Exchange    BRVM         XBRV     Ivory Coast      XOF          CI         CIV
32         Prague Stock Exchange       PR         XPRA  Czech Republic      CZK          CZ         CZE
33    Nairobi Securities Exchange    XNAI         XNAI           Kenya      KES          KE         KEN
34      Casablanca Stock Exchange      BC         XCAS         Morocco      MAD          MA         MAR
35    Stock Exchange of Mauritius     SEM         XMAU       Mauritius      MUR          MU         MUS
36        Nigerian Stock Exchange    XNSA         XNSA         Nigeria      NGN          NG         NGA
37          Rwanda Stock Exchange     RSE         RSEX          Rwanda     RWF           RW         RWA
38   Dar es Salaam Stock Exchange     DSE         XDAR        Tanzania      TZS          TZ         TZA
39     Uganda Securities Exchange     USE         XUGA          Uganda      UGX          UG         UGA
40          Lusaka Stock Exchange    LUSE         XLUS         Zambia       ZMW          ZM         ZMB
41              Tel Aviv Exchange      TA         XTAE          Israel      ILS          IL         ISR
42        Zimbabwe Stock Exchange    XZIM         XZIM       Zimbabwe       ZWL          ZW         ZWE
43  Victoria Falls Stock Exchange    VFEX         VFEX       Zimbabwe       ZWL          ZW         ZWE
44                         KOSDAQ      KQ         XKOS           Korea      KRW          KR         KOR
45           Korea Stock Exchange      KO         XKRX           Korea      KRW          KR         KOR
46        Budapest Stock Exchange     BUD         XBUD         Hungary      HUF          HU         HUN
47          Warsaw Stock Exchange     WAR         XWAR          Poland      PLN          PL         POL
48      Philippine Stock Exchange     PSE         XPHS     Philippines      PHP          PH         PHL
49         Chilean Stock Exchange      SN         XSGO           Chile      CLP          CL         CHL
50          Johannesburg Exchange     JSE         XJSE    South Africa      ZAR          ZA         ZAF
51               Jakarta Exchange      JK         XIDX       Indonesia      IDR          ID         IDN
52              Thailand Exchange      BK         XBKK        Thailand      THB          TH         THA
53              Shanghai Exchange     SHG         XSHG           China      CNY          CN         CHN
54                    NSE (India)     NSE         XNSE           India      INR          IN         IND
55                Athens Exchange      AT         ASEX          Greece      EUR          GR         GRC
56          Saudi Arabia Exchange      SR         XSAU    Saudi Arabia      SAR          SA         SAU
57              Shenzhen Exchange     SHE         XSHE           China      CNY          CN         CHN
58         Karachi Stock Exchange     KAR         XKAR        Pakistan      PKR          PK         PAK
59             Australia Exchange      AU         XASX       Australia      AUD          AU         AUS
60         Colombo Stock Exchange      CM         XCOL       Sri Lanka      LKR          LK         LKA
61                 Vietnam Stocks      VN         HSTC         Vietnam      VND          VN         VNM
62          Kuala Lumpur Exchange    KLSE         XKLS        Malaysia      MYR          MY         MYS
63          Buenos Aires Exchange      BA         XBUE       Argentina      ARS          AR         ARG
64       Bucharest Stock Exchange      RO         XBSE         Romania      RON          RO         ROU
65             Sao Paolo Exchange      SA         BVMF          Brazil      BRL          BR         BRA
66               Mexican Exchange      MX         XMEX          Mexico      MXN          MX         MEX
67                      London IL      IL         XLON              UK      USD          GB         GBR
68          Zagreb Stock Exchange     ZSE         XZAG         Croatia      EUR          HR         HRV
69            Taiwan OTC Exchange     TWO         ROCO          Taiwan      TWD          TW         TWN
70            MICEX Moscow Russia     MCX         None          Russia      RUB          RU         RUS
71                Taiwan Exchange      TW         XTAI          Taiwan      TWD          TW         TWN
72       Bolsa de Valores de Lima     LIM         XLIM            Peru      PEN          PE         PER
73  Money Market Virtual Exchange   MONEY         None         Unknown  Unknown                        
74   Europe Fund Virtual Exchange  EUFUND         None         Unknown      EUR                        
75        Istanbul Stock Exchange      IS         XIST          Turkey      TRY          TR         TUR
76                          FOREX   FOREX         CDSL         Unknown  Unknown                        
77               Cryptocurrencies      CC         CRYP         Unknown  Unknown                        

We can now download all the symbols for the US-based stocks. Below is a sample of the S&P500 stocks but it downloads 48,292 symbols total.

Stocks

Code                                         Name Country Exchange Currency          Type          Isin
195      AAP                       Advance Auto Parts Inc     USA     NYSE      USD  Common Stock  US00751Y1064
199     AAPL                                    Apple Inc     USA   NASDAQ      USD  Common Stock  US0378331005
245     ABBV                                   AbbVie Inc     USA     NYSE      USD  Common Stock  US00287Y1091
366      ABT                          Abbott Laboratories     USA     NYSE      USD  Common Stock  US0028241000
575      ACN                                Accenture plc     USA     NYSE      USD  Common Stock  IE00B4BNMY34
697     ADBE                   Adobe Systems Incorporated     USA   NASDAQ      USD  Common Stock  US00724F1012
746      ADI                           Analog Devices Inc     USA   NASDAQ      USD  Common Stock  US0326541051
759      ADM               Archer-Daniels-Midland Company     USA     NYSE      USD  Common Stock  US0394831020
787      ADP                Automatic Data Processing Inc     USA   NASDAQ      USD  Common Stock  US0530151036
805     ADSK                                 Autodesk Inc     USA   NASDAQ      USD  Common Stock  US0527691069
880      AEE                                  Ameren Corp     USA     NYSE      USD  Common Stock  US0236081024
924      AEP          American Electric Power Company Inc     USA   NASDAQ      USD  Common Stock  US0255371017
935      AES                          The AES Corporation     USA     NYSE      USD  Common Stock  US00130H1059
1032     AFL                           Aflac Incorporated     USA     NYSE      USD  Common Stock  US0010551028
1423     AIG             American International Group Inc     USA     NYSE      USD  Common Stock  US0268747849
1539     AIZ                                 Assurant Inc     USA     NYSE      USD  Common Stock  US04621X1081
1541     AJG                      Arthur J Gallagher & Co     USA     NYSE      USD  Common Stock  US3635761097
1556    AKAM                      Akamai Technologies Inc     USA   NASDAQ      USD  Common Stock  US00971T1016
1598     ALB                               Albemarle Corp     USA     NYSE      USD  Common Stock  US0126531013
1660    ALGN                         Align Technology Inc     USA   NASDAQ      USD  Common Stock  US0162551016
1682     ALK                         Alaska Air Group Inc     USA     NYSE      USD  Common Stock  US0116591092
1689     ALL                     The Allstate Corporation     USA     NYSE      USD  Common Stock  US0200021014
1694    ALLE                                 Allegion PLC     USA     NYSE      USD  Common Stock  IE00BFRT3W74
1863     AMD                   Advanced Micro Devices Inc     USA   NASDAQ      USD  Common Stock  US0079031078
1871     AME                                   Ametek Inc     USA     NYSE      USD  Common Stock  US0311001004
1893    AMGN                                    Amgen Inc     USA   NASDAQ      USD  Common Stock  US0311621009
1959     AMP                     Ameriprise Financial Inc     USA     NYSE      USD  Common Stock  US03076C1062
1996     AMT                          American Tower Corp     USA     NYSE      USD  Common Stock  US03027X1000
2029    AMZN                               Amazon.com Inc     USA   NASDAQ      USD  Common Stock  US0231351067
2132    ANSS                                    ANSYS Inc     USA   NASDAQ      USD  Common Stock  US03662Q1058
2196     AON                                      Aon PLC     USA     NYSE      USD  Common Stock  IE00BLP1HW54
2232     APA                              APA Corporation     USA   NASDAQ      USD  Common Stock  US03743Q1085
2252     APD               Air Products and Chemicals Inc     USA     NYSE      USD  Common Stock  US0091581068
2302     APH                         Amphenol Corporation     USA     NYSE      USD  Common Stock  US0320951017
2417    APTV                                    Aptiv PLC     USA     NYSE      USD  Common Stock  JE00B783TY65
2535     ARE          Alexandria Real Estate Equities Inc     USA     NYSE      USD  Common Stock  US0152711091
3146     ATO                     Atmos Energy Corporation     USA     NYSE      USD  Common Stock  US0495601058
3191    ATVI                      Activision Blizzard Inc     USA   NASDAQ      USD  Common Stock  US00507V1098
3320     AVB                    AvalonBay Communities Inc     USA     NYSE      USD  Common Stock  US0534841012
3363    AVGO                                 Broadcom Inc     USA   NASDAQ      USD  Common Stock  US11135F1012
3480     AWK                         American Water Works     USA     NYSE      USD  Common Stock  US0304201033
3545     AXP                     American Express Company     USA     NYSE      USD  Common Stock  US0258161092
3624     AZO                                 AutoZone Inc     USA     NYSE      USD  Common Stock  US0533321024
3647      BA                           The Boeing Company     USA     NYSE      USD  Common Stock  US0970231058
3659     BAC                         Bank of America Corp     USA     NYSE      USD  Common Stock  US0605051046
3911    BBWI                       Bath & Body Works Inc.     USA     NYSE      USD  Common Stock  US0708301041
4131     BDX                 Becton Dickinson and Company     USA     NYSE      USD  Common Stock  US0758871091
4177     BEN                       Franklin Resources Inc     USA     NYSE      USD  Common Stock  US3546131018
4550    BIIB                                   Biogen Inc     USA   NASDAQ      USD  Common Stock  US09062X1037
4584     BIO                     Bio-Rad Laboratories Inc     USA     NYSE      USD  Common Stock  US0905722072
4741    BKNG                         Booking Holdings Inc     USA   NASDAQ      USD  Common Stock  US09857L1089
4749     BKR                              Baker Hughes Co     USA   NASDAQ      USD  Common Stock  US05722G1004
4843     BLK                                BlackRock Inc     USA     NYSE      USD  Common Stock  US09247X1019
5020     BMY                 Bristol-Myers Squibb Company     USA     NYSE      USD  Common Stock  US1101221083
5268      BR           Broadridge Financial Solutions Inc     USA     NYSE      USD  Common Stock  US11133T1034
5345   BRK-B                       Berkshire Hathaway Inc     USA     NYSE      USD  Common Stock  US0846707026
5622     BSX                       Boston Scientific Corp     USA     NYSE      USD  Common Stock  US1011371077
5847     BWA                               BorgWarner Inc     USA     NYSE      USD  Common Stock  US0997241064
5912     BXP                        Boston Properties Inc     USA     NYSE      USD  Common Stock  US1011211018
6095     CAG                            ConAgra Foods Inc     USA     NYSE      USD  Common Stock  US2058871029
6217    CARR                          Carrier Global Corp     USA     NYSE      USD  Common Stock  US14448C1045
6237     CAT                              Caterpillar Inc     USA     NYSE      USD  Common Stock  US1491231015
6282      CB                                    Chubb Ltd     USA     NYSE      USD  Common Stock  CH0044328745
6399    CBOE                      Cboe Global Markets Inc     USA     BATS      USD  Common Stock  US12503M1080
6411    CBRE                       CBRE Group Inc Class A     USA     NYSE      USD  Common Stock  US12504L1098
6539     CCI                                 Crown Castle     USA     NYSE      USD  Common Stock  US22822V1017
6552     CCL                         Carnival Corporation     USA     NYSE      USD  Common Stock  PA1436583006
6752     CDW                                     CDW Corp     USA   NASDAQ      USD  Common Stock  US12514G1085
6765      CE                         Celanese Corporation     USA     NYSE      USD  Common Stock  US1508701034
6929     CFG                 Citizens Financial Group Inc     USA     NYSE      USD  Common Stock  US1746101054
7343    CHRW                    CH Robinson Worldwide Inc     USA   NASDAQ      USD  Common Stock  US12541W2098
7362    CHTR                   Charter Communications Inc     USA   NASDAQ      USD  Common Stock  US16119P1084
7394      CI                                   Cigna Corp     USA     NYSE      USD  Common Stock  US1255231003
7488    CINF             Cincinnati Financial Corporation     USA   NASDAQ      USD  Common Stock  US1720621010
7607      CL                    Colgate-Palmolive Company     USA     NYSE      USD  Common Stock  US1941621039
7811     CLX                           The Clorox Company     USA     NYSE      USD  Common Stock  US1890541097
7864   CMCSA                                 Comcast Corp     USA   NASDAQ      USD  Common Stock  US20030N1019
7883     CME                                CME Group Inc     USA   NASDAQ      USD  Common Stock  US12572Q1058
7901     CMG                   Chipotle Mexican Grill Inc     USA     NYSE      USD  Common Stock  US1696561059
7921     CMI                                  Cummins Inc     USA     NYSE      USD  Common Stock  US2310211063
8002     CMS                       CMS Energy Corporation     USA     NYSE      USD  Common Stock  US1258961002
8071     CNC                                 Centene Corp     USA     NYSE      USD  Common Stock  US15135B1017
8159     CNP                       CenterPoint Energy Inc     USA     NYSE      USD  Common Stock  US15189T1079
8285     COF            Capital One Financial Corporation     USA     NYSE      USD  Common Stock  US14040H1059
8361     COO      The Cooper Companies, Inc. Common Stock     USA   NASDAQ      USD  Common Stock  US2166484020
8368     COP                               ConocoPhillips     USA     NYSE      USD  Common Stock  US20825C1045
8402    COST                        Costco Wholesale Corp     USA   NASDAQ      USD  Common Stock  US22160K1051
8411    COTY                                     Coty Inc     USA     NYSE      USD  Common Stock  US2220702037
8441     CPB                        Campbell Soup Company     USA     NYSE      USD  Common Stock  US1344291091
8527    CPRI                           Capri Holdings Ltd     USA     NYSE      USD  Common Stock  VGG1890L1076
8531    CPRT                                   Copart Inc     USA   NASDAQ      USD  Common Stock  US2172041061
8705     CRM                           Salesforce.com Inc     USA     NYSE      USD  Common Stock  US79466L3024
8831    CSCO                            Cisco Systems Inc     USA   NASDAQ      USD  Common Stock  US17275R1023
9005     CSX                              CSX Corporation     USA   NASDAQ      USD  Common Stock  US1264081035
9025    CTAS                           Cintas Corporation     USA   NASDAQ      USD  Common Stock  US1729081059
9084    CTLT                                 Catalent Inc     USA     NYSE      USD  Common Stock  US1488061029
9127    CTSH  Cognizant Technology Solutions Corp Class A     USA   NASDAQ      USD  Common Stock  US1924461023
9144    CTVA                                  Corteva Inc     USA     NYSE      USD  Common Stock  US22052L1044
9291     CVS                              CVS Health Corp     USA     NYSE      USD  Common Stock  US1266501006
9315     CVX                                 Chevron Corp     USA     NYSE      USD  Common Stock  US1667641005
9491       D                          Dominion Energy Inc     USA     NYSE      USD  Common Stock  US25746U1097
9734      DD                        Dupont De Nemours Inc     USA     NYSE      USD  Common Stock  US26614N1028
9782      DE                              Deere & Company     USA     NYSE      USD  Common Stock  US2441991054
9985     DFS                  Discover Financial Services     USA     NYSE      USD  Common Stock  US2547091080
10019     DG                   Dollar General Corporation     USA     NYSE      USD  Common Stock  US2566771059
10111    DGX               Quest Diagnostics Incorporated     USA     NYSE      USD  Common Stock  US74834L1008
10138    DHI                                DR Horton Inc     USA     NYSE      USD  Common Stock  US23331A1097
10168    DHR                          Danaher Corporation     USA     NYSE      USD  Common Stock  US2358511028
10255    DIS                          Walt Disney Company     USA     NYSE      USD  Common Stock  US2546871060
10261   DISH                     DISH Network Corporation     USA   NASDAQ      USD  Common Stock  US25470M1099
10376    DLR                     Digital Realty Trust Inc     USA     NYSE      USD  Common Stock  US2538681030
10392   DLTR                              Dollar Tree Inc     USA   NASDAQ      USD  Common Stock  US2567461080
10558   DOCU                                 DocuSign Inc     USA   NASDAQ      USD  Common Stock  US2561631068
10598    DOV                            Dover Corporation     USA     NYSE      USD  Common Stock  US2600031080
10704    DRI                       Darden Restaurants Inc     USA     NYSE      USD  Common Stock  US2371941053
10882    DTE                           DTE Energy Company     USA     NYSE      USD  Common Stock  US2333311072
10961    DUK                      Duke Energy Corporation     USA     NYSE      USD  Common Stock  US26441C2044
11108    DXC                            DXC Technology Co     USA     NYSE      USD  Common Stock  US23355L1061
11110   DXCM                                   DexCom Inc     USA   NASDAQ      USD  Common Stock  US2521311074
11154     EA                          Electronic Arts Inc     USA   NASDAQ      USD  Common Stock  US2855121099
11244   EBAY                                     eBay Inc     USA   NASDAQ      USD  Common Stock  US2786421030
11342    ECL                                   Ecolab Inc     USA     NYSE      USD  Common Stock  US2788651006
11403     ED                      Consolidated Edison Inc     USA     NYSE      USD  Common Stock  US2091151041
11552    EFX                                  Equifax Inc     USA     NYSE      USD  Common Stock  US2944291051
11734    EIX                         Edison International     USA     NYSE      USD  Common Stock  US2810201077
11791     EL                   Estee Lauder Companies Inc     USA     NYSE      USD  Common Stock  US5184391044
11981    EMN                     Eastman Chemical Company     USA     NYSE      USD  Common Stock  US2774321002
12003    EMR                     Emerson Electric Company     USA     NYSE      USD  Common Stock  US2910111044
12142    EOG                            EOG Resources Inc     USA     NYSE      USD  Common Stock  US26875P1012
12243   EQIX                                  Equinix Inc     USA   NASDAQ      USD  Common Stock  US29444U7000
12262    EQR                           Equity Residential     USA     NYSE      USD  Common Stock  US29476L1070
12340     ES                            Eversource Energy     USA     NYSE      USD  Common Stock  US30040W1080
12458    ESS                     Essex Property Trust Inc     USA     NYSE      USD  Common Stock  US2971781057
12549    ETN                        Eaton Corporation PLC     USA     NYSE      USD  Common Stock  IE00B8KQN827
12568    ETR                          Entergy Corporation     USA     NYSE      USD  Common Stock  US29364G1031
12726     EW                    Edwards Lifesciences Corp     USA     NYSE      USD  Common Stock  US28176E1082
12774    EXC                           Exelon Corporation     USA   NASDAQ      USD  Common Stock  US30161N1019
12812   EXPD   Expeditors International of Washington Inc     USA   NASDAQ      USD  Common Stock  US3021301094
12813   EXPE                           Expedia Group Inc.     USA   NASDAQ      USD  Common Stock  US30212P3038
13042   FAST                             Fastenal Company     USA   NASDAQ      USD  Common Stock  US3119001044
13456    FCX           Freeport-McMoran Copper & Gold Inc     USA     NYSE      USD  Common Stock  US35671D8570
13625     FE                      FirstEnergy Corporation     USA     NYSE      USD  Common Stock  US3379321074
14285    FHN           First Horizon National Corporation     USA     NYSE      USD  Common Stock  US3205171057
14612    FIS   Fidelity National Information Services Inc     USA     NYSE      USD  Common Stock  US31620M1062
14629   FITB                          Fifth Third Bancorp     USA   NASDAQ      USD  Common Stock  US3167731005
14944    FLR                            Fluor Corporation     USA     NYSE      USD  Common Stock  US3434121022
14972    FLS                        Flowserve Corporation     USA     NYSE      USD  Common Stock  US34354P1057
14990    FLT                    Fleetcor Technologies Inc     USA     NYSE      USD  Common Stock  US3390411052
15068    FMC                              FMC Corporation     USA     NYSE      USD  Common Stock  US3024913036
15539   FOSL                             Fossil Group Inc     USA   NASDAQ      USD  Common Stock  US34988V1061
15555    FOX                             Fox Corp Class B     USA   NASDAQ      USD  Common Stock  US35137L2043
15556   FOXA                             Fox Corp Class A     USA   NASDAQ      USD  Common Stock  US35137L1052
15886    FRT              Federal Realty Investment Trust     USA     NYSE      USD  Common Stock  US3137451015
16421    FTI                               TechnipFMC PLC     USA     NYSE      USD  Common Stock  GB00BDSFG982
16517    FTV                                 Fortive Corp     USA     NYSE      USD  Common Stock  US34959J1088
17233     GD                 General Dynamics Corporation     USA     NYSE      USD  Common Stock  US3695501086
17312     GE                     General Electric Company     USA     NYSE      USD  Common Stock  US3696043013
17731   GILD                          Gilead Sciences Inc     USA   NASDAQ      USD  Common Stock  US3755581036
17830     GL                               Globe Life Inc     USA     NYSE      USD  Common Stock  US37959E1029
17990    GLW                         Corning Incorporated     USA     NYSE      USD  Common Stock  US2193501051
18306   GOOG                         Alphabet Inc Class C     USA   NASDAQ      USD  Common Stock  US02079K1079
18307  GOOGL                         Alphabet Inc Class A     USA   NASDAQ      USD  Common Stock  US02079K3059
18352    GPC                             Genuine Parts Co     USA     NYSE      USD  Common Stock  US3724601055
18425    GPS                                      Gap Inc     USA     NYSE      USD  Common Stock  US3647601083
18545   GRMN                                   Garmin Ltd     USA     NYSE      USD  Common Stock  CH0114405324
18618     GS                      Goldman Sachs Group Inc     USA     NYSE      USD  Common Stock  US38141G1040
19147    GWW                              WW Grainger Inc     USA     NYSE      USD  Common Stock  US3848021040
19284    HAS                                   Hasbro Inc     USA   NASDAQ      USD  Common Stock  US4180561072
19315   HBAN           Huntington Bancshares Incorporated     USA   NASDAQ      USD  Common Stock  US4461501045
19333    HBI                              Hanesbrands Inc     USA     NYSE      USD  Common Stock  US4103451021
19362    HCA                             HCA Holdings Inc     USA     NYSE      USD  Common Stock  US40412C1018
19458     HD                               Home Depot Inc     USA     NYSE      USD  Common Stock  US4370761029
19602    HES                             Hess Corporation     USA     NYSE      USD  Common Stock  US42809H1077
19827    HIG            Hartford Financial Services Group     USA     NYSE      USD  Common Stock  US4165151048
19839    HII            Huntington Ingalls Industries Inc     USA     NYSE      USD  Common Stock  US4464131063
20022    HLT                Hilton Worldwide Holdings Inc     USA     NYSE      USD  Common Stock  US43300A2033
20184    HON                  Honeywell International Inc     USA   NASDAQ      USD  Common Stock  US4385161066
20275    HRB                                H&R Block Inc     USA     NYSE      USD  Common Stock  US0936711052
20304    HRL                     Hormel Foods Corporation     USA     NYSE      USD  Common Stock  US4404521001
20445    HST                    Host Hotels & Resorts Inc     USA   NASDAQ      USD  Common Stock  US44107P1049
20472    HSY                                   Hershey Co     USA     NYSE      USD  Common Stock  US4278661081
20572    HUM                                   Humana Inc     USA     NYSE      USD  Common Stock  US4448591028
20659    HWM                         Howmet Aerospace Inc     USA     NYSE      USD  Common Stock  US4432011082
20908    IBM              International Business Machines     USA     NYSE      USD  Common Stock  US4592001014
20984    ICE                Intercontinental Exchange Inc     USA     NYSE      USD  Common Stock  US45866F1049
21160   IDXX                       IDEXX Laboratories Inc     USA   NASDAQ      USD  Common Stock  US45168D1046
21225    IEX                             IDEX Corporation     USA     NYSE      USD  Common Stock  US45167R1041
21242    IFF       International Flavors & Fragrances Inc     USA     NYSE      USD  Common Stock  US4595061015
21580   ILMN                                 Illumina Inc     USA   NASDAQ      USD  Common Stock  US4523271090
21744   INCY                           Incyte Corporation     USA   NASDAQ      USD  Common Stock  US45337C1027
21861   INTC                            Intel Corporation     USA   NASDAQ      USD  Common Stock  US4581401001
21875   INTU                                   Intuit Inc     USA   NASDAQ      USD  Common Stock  US4612021034
21959     IP                          International Paper     USA     NYSE      USD  Common Stock  US4601461035
21986    IPG           Interpublic Group of Companies Inc     USA     NYSE      USD  Common Stock  US4606901001
22076    IQV                           IQVIA Holdings Inc     USA     NYSE      USD  Common Stock  US46266C1053
22077     IR                           Ingersoll Rand Inc     USA     NYSE      USD  Common Stock  US45687V1061
22145    IRM                   Iron Mountain Incorporated     USA     NYSE      USD  Common Stock  US46284V1017
22356   ISRG                       Intuitive Surgical Inc     USA   NASDAQ      USD  Common Stock  US46120E6023
22426     IT                                  Gartner Inc     USA     NYSE      USD  Common Stock  US3666511072
22525    ITW                      Illinois Tool Works Inc     USA     NYSE      USD  Common Stock  US4523081093
22670    IVZ                                  Invesco Plc     USA     NYSE      USD  Common Stock  BMG491BT1088
22785      J                        Jacobs Solutions Inc.     USA     NYSE      USD  Common Stock  US46982L1089
23656   JKHY                  Jack Henry & Associates Inc     USA   NASDAQ      USD  Common Stock  US4262811015
23861    JNJ                            Johnson & Johnson     USA     NYSE      USD  Common Stock  US4781601046
23870   JNPR                         Juniper Networks Inc     USA     NYSE      USD  Common Stock  US48203R1041
23985    JPM                          JPMorgan Chase & Co     USA     NYSE      USD  Common Stock  US46625H1005
24450    JWN                                Nordstrom Inc     USA     NYSE      USD  Common Stock  US6556641008
24482      K                                    Kellanova     USA     NYSE      USD  Common Stock  US4878361082
24640   KEYS                    Keysight Technologies Inc     USA     NYSE      USD  Common Stock  US49338L1035
24689    KHC                               Kraft Heinz Co     USA   NASDAQ      USD  Common Stock  US5007541064
24716    KIM                     Kimco Realty Corporation     USA     NYSE      USD  Common Stock  US49446R1095
24748   KLAC                       KLA-Tencor Corporation     USA   NASDAQ      USD  Common Stock  US4824801009
24790    KMB                   Kimberly-Clark Corporation     USA     NYSE      USD  Common Stock  US4943681035
24805    KMI                            Kinder Morgan Inc     USA     NYSE      USD  Common Stock  US49456B1017
24876     KO                        The Coca-Cola Company     USA     NYSE      USD  Common Stock  US1912161007
24999    KSS                                   Kohls Corp     USA     NYSE      USD  Common Stock  US5002551043
25507    LEG                 Leggett & Platt Incorporated     USA     NYSE      USD  Common Stock  US5246601075
25543    LEN                           Lennar Corporation     USA     NYSE      USD  Common Stock  US5260571048
25780     LH   Laboratory Corporation of America Holdings     USA     NYSE      USD  Common Stock  US50540R4092
25800    LHX                    L3Harris Technologies Inc     USA     NYSE      USD  Common Stock  US5024311095
25904    LIN                                    Linde PLC     USA     NYSE      USD  Common Stock  IE000S9YS762
26011    LKQ                              LKQ Corporation     USA   NASDAQ      USD  Common Stock  US5018892084
26044    LLY                        Eli Lilly and Company     USA     NYSE      USD  Common Stock  US5324571083
26152    LMT                  Lockheed Martin Corporation     USA     NYSE      USD  Common Stock  US5398301094
26200    LNT                          Alliant Energy Corp     USA   NASDAQ      USD  Common Stock  US0188021085
26280    LOW                         Lowe's Companies Inc     USA     NYSE      USD  Common Stock  US5486611073
26399   LRCX                            Lam Research Corp     USA   NASDAQ      USD  Common Stock  US5128071082
26714   LUMN                       Lumen Technologies Inc     USA     NYSE      USD  Common Stock  US5502411037
26780    LVS                         Las Vegas Sands Corp     USA     NYSE      USD  Common Stock  US5178341070
26789     LW                     Lamb Weston Holdings Inc     USA     NYSE      USD  Common Stock  US5132721045
26823    LYB                 LyondellBasell Industries NV     USA     NYSE      USD  Common Stock  NL0009434992
26877      M                                   Macy’s Inc     USA     NYSE      USD  Common Stock  US55616P1049
26878     MA                               Mastercard Inc     USA     NYSE      USD  Common Stock  US57636Q1040
27044    MAR                   Marriott International Inc     USA   NASDAQ      USD  Common Stock  US5719032022
27064    MAS                            Masco Corporation     USA     NYSE      USD  Common Stock  US5745991068
27272    MCD                       McDonald’s Corporation     USA     NYSE      USD  Common Stock  US5801351017
27314   MCHP                     Microchip Technology Inc     USA   NASDAQ      USD  Common Stock  US5950171042
27356    MCO                           Moodys Corporation     USA     NYSE      USD  Common Stock  US6153691059
27515   MDLZ                   Mondelez International Inc     USA   NASDAQ      USD  Common Stock  US6092071058
27565    MDT                                Medtronic PLC     USA     NYSE      USD  Common Stock  IE00BTN1Y115
27722    MET                                  MetLife Inc     USA     NYSE      USD  Common Stock  US59156R1086
28102    MHK                        Mohawk Industries Inc     USA     NYSE      USD  Common Stock  US6081901042
28365    MKC             McCormick & Company Incorporated     USA     NYSE      USD  Common Stock  US5797802064
28409   MKTX                     MarketAxess Holdings Inc     USA   NASDAQ      USD  Common Stock  US57060D1081
28476    MLM                Martin Marietta Materials Inc     USA     NYSE      USD  Common Stock  US5732841060
28594    MMC               Marsh & McLennan Companies Inc     USA     NYSE      USD  Common Stock  US5717481023
28693    MMM                                   3M Company     USA     NYSE      USD  Common Stock  US88579Y1010
28937   MNST                        Monster Beverage Corp     USA   NASDAQ      USD  Common Stock  US61174X1090
28971     MO                                 Altria Group     USA     NYSE      USD  Common Stock  US02209S1033
29057    MOS                           The Mosaic Company     USA     NYSE      USD  Common Stock  US61945C1036
29323    MRK                          Merck & Company Inc     USA     NYSE      USD  Common Stock  US58933Y1055
29416     MS                               Morgan Stanley     USA     NYSE      USD  Common Stock  US6174464486
29467   MSCI                                     MSCI Inc     USA     NYSE      USD  Common Stock  US55354G1004
29525   MSFT                        Microsoft Corporation     USA   NASDAQ      USD  Common Stock  US5949181045
29710    MTB                                M&T Bank Corp     USA     NYSE      USD  Common Stock  US55261F1049
29729    MTD             Mettler-Toledo International Inc     USA     NYSE      USD  Common Stock  US5926881054
29835     MU                        Micron Technology Inc     USA   NASDAQ      USD  Common Stock  US5951121038
30457   NCLH           Norwegian Cruise Line Holdings Ltd     USA     NYSE      USD  Common Stock  BMG667211046
30501   NDAQ                                   Nasdaq Inc     USA   NASDAQ      USD  Common Stock  US6311031081
30563    NEE                           Nextera Energy Inc     USA     NYSE      USD  Common Stock  US65339F1012
30694   NFLX                                  Netflix Inc     USA   NASDAQ      USD  Common Stock  US64110L1061
30793     NI                                 NiSource Inc     USA     NYSE      USD  Common Stock  US65473P1057
31121    NOV                                     NOV Inc.     USA     NYSE      USD  Common Stock  US62955J1034
31132    NOW                               ServiceNow Inc     USA     NYSE      USD  Common Stock  US81762P1021
31307    NSC                 Norfolk Southern Corporation     USA     NYSE      USD  Common Stock  US6558441084
31466   NTRS                   Northern Trust Corporation     USA   NASDAQ      USD  Common Stock  US6658591044
31491    NUE                                   Nucor Corp     USA     NYSE      USD  Common Stock  US6703461052
31564   NVDA                           NVIDIA Corporation     USA   NASDAQ      USD  Common Stock  US67066G1040
31600    NVR                                      NVR Inc     USA     NYSE      USD  Common Stock  US62944T1051
31725    NWL                            Newell Brands Inc     USA   NASDAQ      USD  Common Stock  US6512291062
31758    NWS                                  News Corp B     USA   NASDAQ      USD  Common Stock  US65249B2088
31759   NWSA                                  News Corp A     USA   NASDAQ      USD  Common Stock  US65249B1098
32070   ODFL                Old Dominion Freight Line Inc     USA   NASDAQ      USD  Common Stock  US6795801009
32082    ODP                                     ODP Corp     USA   NASDAQ      USD  Common Stock  US88337F1057
32309    OMC                            Omnicom Group Inc     USA     NYSE      USD  Common Stock  US6819191064
32517    ORI              Old Republic International Corp     USA     NYSE      USD  Common Stock  US6802231042
32527   ORLY                      O’Reilly Automotive Inc     USA   NASDAQ      USD  Common Stock  US67103H1077
32746    OXY             Occidental Petroleum Corporation     USA     NYSE      USD  Common Stock  US6745991058
32981   PANW                       Palo Alto Networks Inc     USA   NASDAQ      USD  Common Stock  US6974351057
33075   PAYX                                  Paychex Inc     USA   NASDAQ      USD  Common Stock  US7043261079
33206   PCAR                                   PACCAR Inc     USA   NASDAQ      USD  Common Stock  US6937181088
33588   PEAK                    Healthpeak Properties Inc     USA     NYSE      USD  Common Stock  US42250P1030
33682    PEP                                  PepsiCo Inc     USA   NASDAQ      USD  Common Stock  US7134481081
33750    PFE                                   Pfizer Inc     USA     NYSE      USD  Common Stock  US7170811035
33767    PFG                Principal Financial Group Inc     USA   NASDAQ      USD  Common Stock  US74251V1026
33876     PG                     Procter & Gamble Company     USA     NYSE      USD  Common Stock  US7427181091
34000    PGR                             Progressive Corp     USA     NYSE      USD  Common Stock  US7433151039
34060     PH                  Parker-Hannifin Corporation     USA     NYSE      USD  Common Stock  US7010941042
34126    PHM                               PulteGroup Inc     USA     NYSE      USD  Common Stock  US7458671010
34476    PLD                                 Prologis Inc     USA     NYSE      USD  Common Stock  US74340W1036
34639     PM              Philip Morris International Inc     USA     NYSE      USD  Common Stock  US7181721090
34814    PNC             PNC Financial Services Group Inc     USA     NYSE      USD  Common Stock  US6934751057
34879    PNW                   Pinnacle West Capital Corp     USA     NYSE      USD  Common Stock  US7234841010
34951   POOL                             Pool Corporation     USA   NASDAQ      USD  Common Stock  US73278L1052
35015    PPG                           PPG Industries Inc     USA     NYSE      USD  Common Stock  US6935061076
35033    PPL                              PPL Corporation     USA     NYSE      USD  Common Stock  US69351T1060
35232   PRGO                          Perrigo Company PLC     USA     NYSE      USD  Common Stock  IE00BGH1M568
35479    PSA                               Public Storage     USA     NYSE      USD  Common Stock  US74460D1090
35992    PVH                                     PVH Corp     USA     NYSE      USD  Common Stock  US6936561009
36056    PWR                          Quanta Services Inc     USA     NYSE      USD  Common Stock  US74762E1029
36190   PYPL                          PayPal Holdings Inc     USA   NASDAQ      USD  Common Stock  US70450Y1038
36295   QCOM                        Qualcomm Incorporated     USA   NASDAQ      USD  Common Stock  US7475251036
36528   QRVO                                    Qorvo Inc     USA   NASDAQ      USD  Common Stock  US74736K1016
36919    RCL                  Royal Caribbean Cruises Ltd     USA     NYSE      USD  Common Stock  LR0008862868
37109   REGN                Regeneron Pharmaceuticals Inc     USA   NASDAQ      USD  Common Stock  US75886F1075
37621    RJF                 Raymond James Financial Inc.     USA     NYSE      USD  Common Stock  US7547301090
37649     RL                    Ralph Lauren Corp Class A     USA     NYSE      USD  Common Stock  US7512121010
37740    RMD                                   ResMed Inc     USA     NYSE      USD  Common Stock  US7611521078
37937    ROK                      Rockwell Automation Inc     USA     NYSE      USD  Common Stock  US7739031091
37941    ROL                                  Rollins Inc     USA     NYSE      USD  Common Stock  US7757111049
37949    ROP         Roper Technologies Inc. Common Stock     USA   NASDAQ      USD  Common Stock  US7766961061
37961   ROST                              Ross Stores Inc     USA   NASDAQ      USD  Common Stock  US7782961038
38180    RSG                        Republic Services Inc     USA     NYSE      USD  Common Stock  US7607591002
38335    RTX                   Raytheon Technologies Corp     USA     NYSE      USD  Common Stock  US75513E1010
39030   SBUX                        Starbucks Corporation     USA   NASDAQ      USD  Common Stock  US8552441094
39132   SCHW                          Charles Schwab Corp     USA     NYSE      USD  Common Stock  US8085131055
39422    SEE                       Sealed Air Corporation     USA     NYSE      USD  Common Stock  US81211K1007
39940    SHW                          Sherwin-Williams Co     USA     NYSE      USD  Common Stock  US8243481061
40128    SJM                           JM Smucker Company     USA     NYSE      USD  Common Stock  US8326964058
40243    SLG                         SL Green Realty Corp     USA     NYSE      USD  Common Stock  US78440X8873
40572    SNA                                  Snap-On Inc     USA     NYSE      USD  Common Stock  US8330341012
40668   SNPS                                 Synopsys Inc     USA   NASDAQ      USD  Common Stock  US8716071076
40732     SO                             Southern Company     USA     NYSE      USD  Common Stock  US8425871071
40898    SPG                     Simon Property Group Inc     USA     NYSE      USD  Common Stock  US8288061091
40902   SPGI                               S&P Global Inc     USA     NYSE      USD  Common Stock  US78409V1044
41139    SRE                                Sempra Energy     USA     NYSE      USD  Common Stock  US8168511090
41518    STE                                   STERIS plc     USA     NYSE      USD  Common Stock  IE00BFY8C754
41964    SWK                   Stanley Black & Decker Inc     USA     NYSE      USD  Common Stock  US8545021011
41968   SWKS                       Skyworks Solutions Inc     USA   NASDAQ      USD  Common Stock  US83088M1027
42066    SYF                          Synchrony Financial     USA     NYSE      USD  Common Stock  US87165B1035
42077    SYK                          Stryker Corporation     USA     NYSE      USD  Common Stock  US8636671013
42139      T                                     AT&T Inc     USA     NYSE      USD  Common Stock  US00206R1023
42239    TAP              Molson Coors Brewing Co Class B     USA     NYSE      USD  Common Stock  US60871R2094
42577    TDG                 Transdigm Group Incorporated     USA     NYSE      USD  Common Stock  US8936411003
42725    TER                                 Teradyne Inc     USA   NASDAQ      USD  Common Stock  US8807701029
42771    TFC                        Truist Financial Corp     USA     NYSE      USD  Common Stock  US89832Q1094
42836    TFX                        Teleflex Incorporated     USA     NYSE      USD  Common Stock  US8793691069
42943    TGT                           Target Corporation     USA     NYSE      USD  Common Stock  US87612E1064
43273    TJX                        The TJX Companies Inc     USA     NYSE      USD  Common Stock  US8725401090
43530    TMO                 Thermo Fisher Scientific Inc     USA     NYSE      USD  Common Stock  US8835561023
43557   TMUS                              T-Mobile US Inc     USA   NASDAQ      USD  Common Stock  US8725901040
44030   TROW                      T. Rowe Price Group Inc     USA   NASDAQ      USD  Common Stock  US74144T1088
44139    TRV                  The Travelers Companies Inc     USA     NYSE      USD  Common Stock  US89417E1091
44302   TSLA                                    Tesla Inc     USA   NASDAQ      USD  Common Stock  US88160R1014
44409     TT                       Trane Technologies plc     USA     NYSE      USD  Common Stock  IE00BK9ZQ967
44490   TTWO            Take-Two Interactive Software Inc     USA   NASDAQ      USD  Common Stock  US8740541094
44674    TXN               Texas Instruments Incorporated     USA   NASDAQ      USD  Common Stock  US8825081040
44683    TXT                                  Textron Inc     USA     NYSE      USD  Common Stock  US8832031012
44725     UA                           Under Armour Inc C     USA     NYSE      USD  Common Stock  US9043112062
44726    UAA                           Under Armour Inc A     USA     NYSE      USD  Common Stock  US9043111072
44731    UAL                 United Airlines Holdings Inc     USA   NASDAQ      USD  Common Stock  US9100471096
45004    UNH              UnitedHealth Group Incorporated     USA     NYSE      USD  Common Stock  US91324P1021
45016    UNM                                   Unum Group     USA     NYSE      USD  Common Stock  US91529Y1064
45076    UPS                    United Parcel Service Inc     USA     NYSE      USD  Common Stock  US9113121068
45105    URI                           United Rentals Inc     USA     NYSE      USD  Common Stock  US9113631090
45143    USB                                 U.S. Bancorp     USA     NYSE      USD  Common Stock  US9029733048
45374      V                            Visa Inc. Class A     USA     NYSE      USD  Common Stock  US92826C8394
45603   VEEV                    Veeva Systems Inc Class A     USA     NYSE      USD  Common Stock  US9224751084
45683    VFC                               VF Corporation     USA     NYSE      USD  Common Stock  US9182041080
46017    VLO                    Valero Energy Corporation     USA     NYSE      USD  Common Stock  US91913Y1001
46145    VNO                         Vornado Realty Trust     USA     NYSE      USD  Common Stock  US9290421091
46163    VNT                                 Vontier Corp     USA     NYSE      USD  Common Stock  US9288811014
46320   VRSK                         Verisk Analytics Inc     USA   NASDAQ      USD  Common Stock  US92345Y1064
46321   VRSN                                 VeriSign Inc     USA   NASDAQ      USD  Common Stock  US92343E1029
46337   VRTX                   Vertex Pharmaceuticals Inc     USA   NASDAQ      USD  Common Stock  US92532F1003
46539    VTR                                   Ventas Inc     USA     NYSE      USD  Common Stock  US92276F1003
46819     VZ                   Verizon Communications Inc     USA     NYSE      USD  Common Stock  US92343V1044
46830    WAB     Westinghouse Air Brake Technologies Corp     USA     NYSE      USD  Common Stock  US9297401088
46910    WAT                           Waters Corporation     USA     NYSE      USD  Common Stock  US9418481035
47118    WEC                         WEC Energy Group Inc     USA     NYSE      USD  Common Stock  US92939U1060
47154   WELL                                Welltower Inc     USA     NYSE      USD  Common Stock  US95040Q1040
47351    WHR                        Whirlpool Corporation     USA     NYSE      USD  Common Stock  US9633201069
47500     WM                         Waste Management Inc     USA     NYSE      USD  Common Stock  US94106L1098
47501    WMB                       Williams Companies Inc     USA     NYSE      USD  Common Stock  US9694571004
47553    WMT                                  Walmart Inc     USA     NYSE      USD  Common Stock  US9311421039
47670    WRK                                  WestRock Co     USA     NYSE      USD  Common Stock  US96145D1054
47742    WST             West Pharmaceutical Services Inc     USA     NYSE      USD  Common Stock  US9553061055
47838     WU                             Western Union Co     USA     NYSE      USD  Common Stock  US9598021098
47907     WY                         Weyerhaeuser Company     USA     NYSE      USD  Common Stock  US9621661043
48077    XEL                              Xcel Energy Inc     USA   NASDAQ      USD  Common Stock  US98389B1008
48387    XOM                             Exxon Mobil Corp     USA     NYSE      USD  Common Stock  US30231G1022
48486    XRX                                   Xerox Corp     USA   NASDAQ      USD  Common Stock  US98421M1062
48583    XYL                                    Xylem Inc     USA     NYSE      USD  Common Stock  US98419M1009
48717    YUM                              Yum! Brands Inc     USA     NYSE      USD  Common Stock  US9884981013
48743    ZBH                   Zimmer Biomet Holdings Inc     USA     NYSE      USD  Common Stock  US98956P1021
48897    ZTS                                   Zoetis Inc     USA     NYSE      USD  Common Stock  US98978V1035

Here’s how the code works

Prerequisites

Before we dive in, make sure you have the following installed:

  • Python 3.x
  • Pandas
  • Requests

You’ll also need an API token from EODHD, which you can get by signing up on their website.

Importing Necessary Modules

Let’s start by importing the necessary modules. We’ll need logging for logging, pandas for data manipulation, requests for making HTTP requests, io for handling CSV data streams, and pathlib for file path manipulation.

import logging
import pandas as pd
import requests
import io
from pathlib import Path

Setting Up Logging and Pandas Configuration

We’ll set up logging to the INFO level and configure Pandas to display all columns for our dataframes.

logging.basicConfig(level=logging.INFO)
pd.set_option('display.max_columns', None)
pd.set_option('display.expand_frame_repr', False)

Fetch and Save Exchanges

The first function fetch_and_save_exchanges fetches the list of all stock market exchanges and saves them to an HDF5 file. You can also opt to read this data from a local file if it exists.

def fetch_and_save_exchanges(api_token, data_dir, local_only=False):
    # ... (code)

This function takes an API token and a directory path as its arguments and also has an optional argument local_only to specify whether to use local data if available.

Here’s how to call it:

df = fetch_and_save_exchanges(api_token, data_dir)
logging.info(df.head())
logging.info(df.tail())

Fetch and Save Symbols

The second function fetch_and_save_symbols fetches stock symbols for each exchange and saves them to an HDF5 file.

def fetch_and_save_symbols(api_token, data_dir, exchange_codes):
    # ... (code)

This function iterates over each exchange code and fetches its symbols. Here’s how to call it:

# Uncomment the following line when you want to fetch and save symbols
# fetch_and_save_symbols(api_token, data_dir, exchange_codes)

Inspecting Your Local Database

The final function, print_h5_file_info, allows you to inspect what’s inside your HDF5 file. It lists all the market codes (keys) and can export a specific one to a CSV file.

def print_h5_file_info(h5_file_path, market_code=None, csv_export=False):
    # ... (code)

To check the content of your HDF5 file, simply call:

print_h5_file_info(data_dir + 'symbols.h5', 'US')

The entire code is below

You will need to create a python file key.py to store your api_token variable.

from keys import api_token

data_dir = '/home/shared/algos/data/'

import logging
import pandas as pd
import requests
import io
from pathlib import Path

logging.basicConfig(level=logging.INFO)
# Configure Pandas to display all columns
pd.set_option('display.max_columns', None)
pd.set_option('display.expand_frame_repr', False)

def fetch_and_save_exchanges(api_token, data_dir, local_only=False):
    h5_file_path = Path(data_dir, "exchanges.h5")

    if local_only:
        if h5_file_path.exists():
            df = pd.read_hdf(h5_file_path, key="exchanges")
            print(f"Loaded data from {h5_file_path}")
        else:
            print("Local file does not exist. You might want to fetch it first.")
            return None
    else:
        url = "https://eodhd.com/api/exchanges-list/?api_token=" + api_token
        response = requests.get(url)
        if response.status_code == 200:
            json_data = response.json()
            df = pd.DataFrame(json_data)
            df.to_hdf(h5_file_path, key="exchanges", mode="w")
            print(f"Saved data to {h5_file_path}")
        else:
            print(f"Failed to fetch data. HTTP Status Code: {response.status_code}")
            return None

    return df


df = fetch_and_save_exchanges(api_token, data_dir)
logging.info(df.head())
logging.info(df.tail())

exchange_codes = df['Code'].tolist()


def fetch_and_save_symbols(api_token, data_dir, exchange_codes):
    h5_file_path = Path(data_dir, "symbols.h5")

    for exchange_code in exchange_codes:
        url = f"https://eodhistoricaldata.com/api/exchanges/{exchange_code}?api_token={api_token}"
        response = requests.get(url)

        if response.status_code == 200:
            csv_data = response.text
            csv_stream = io.StringIO(csv_data)

            # Create DataFrame from CSV stream
            df = pd.read_csv(csv_stream)

            # Append DataFrame to H5 file under the key `exchange_code`
            df.to_hdf(h5_file_path, key=f"{exchange_code}", mode='a')
            print(f"Saved data for {exchange_code} to {h5_file_path}")
        else:
            print(f"Failed to fetch data for {exchange_code}. HTTP Status Code: {response.status_code}")


# fetch_and_save_symbols(api_token, data_dir, exchange_codes)


def print_h5_file_info(h5_file_path, market_code=None, csv_export=False):

    h5_file_path = Path(h5_file_path)

    # Check if the file exists
    if not h5_file_path.exists():
        logging.info(f"The file {h5_file_path} does not exist.")
        return

    with pd.HDFStore(h5_file_path, 'r') as store:
        # Log available keys (symbols)
        logging.info("Available market codes in the HDF5 file:")
        for key in store.keys():
            logging.info(key.lstrip('/'))  # Remove the leading '/' from the key name

        # If a market_code is specified, try to read its data
        if market_code:
            if f'/{market_code}' in store.keys():
                # Read the DataFrame for the specific market code
                df = pd.read_hdf(h5_file_path, key=market_code)

                # Log the DataFrame
                logging.info(f"\nData for market code {market_code}:")
                logging.info(df)

                # If csv_export is True, save the DataFrame to a CSV file
                if csv_export:
                    csv_file_path = h5_file_path.parent / f"{market_code}.csv"
                    df.to_csv(csv_file_path, index=False)
                    logging.info(f"DataFrame has been saved to {csv_file_path}")

            else:
                logging.info(f"\nThe market code {market_code} does not exist in the HDF5 file.")

print_h5_file_info(data_dir + 'symbols.h5', 'US')