Fetching all companies in an index

Hide code cell content

import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)

import lseg.data as ld

ld.open_session()
<lseg.data.session.Definition object at 0x7f10e8914050 {name='rdp'}>

You can use the LSEG Data Library for Python to retrieve metadata about all of the companies in a stock index.

To do so, pass the index’s Refinitiv Instrument Code with a 0# prefix to the fundamental_and_reference component of package’s content submodule.

The method requires that you specify at least one field to retrieve for each company, in addition to its code. Here’s how to retrieve the name and ticker symbol of each of the 30 entries in the Dow Jones Industrial Average:

ld.content.fundamental_and_reference.Definition(
    universe=["0#.DJI"],
    fields=[
        "TR.CommonName",
        "TR.TickerSymbol"
    ],
).get_data().data.df
Instrument Company Common Name Ticker Symbol
0 KO.N Coca-Cola Co KO
1 IBM.N International Business Machines Corporation IBM
2 AMGN.OQ Amgen Inc AMGN
3 CAT.N Caterpillar Inc CAT
4 AAPL.OQ Apple Inc. AAPL
5 CVX.N Chevron Corporation CVX
6 GS.N Goldman Sachs Group Inc GS
7 WMT.OQ Walmart Inc WMT
8 NVDA.OQ NVIDIA Corporation NVDA
9 UNH.N UnitedHealth Group Inc UNH
10 HD.N The Home Depot, Inc. HD
11 MSFT.OQ Microsoft Corporation MSFT
12 JNJ.N Johnson & Johnson JNJ
13 BA.N Boeing Co BA
14 GOOGL.OQ Alphabet Inc. GOOGL
15 PG.N The Procter & Gamble Company PG
16 CSCO.OQ Cisco Systems Inc CSCO
17 CRM.N Salesforce, Inc. CRM
18 MMM.N 3M Company MMM
19 TRV.N The Travelers Companies, Inc. TRV
20 JPM.N JPMorgan Chase & Co JPM
21 V.N Visa Inc. V
22 AMZN.OQ Amazon.com Inc AMZN
23 AXP.N American Express Company AXP
24 MRK.N Merck & Co Inc MRK
25 DIS.N The Walt Disney Company DIS
26 HON.OQ Honeywell International Inc HON
27 MCD.N McDonald's Corp MCD
28 NKE.N NIKE, Inc. NKE
29 SHW.N Sherwin-Williams Co SHW

Note

In LSEG terminology, the 0# prefix is known as a “chain.” It is used to identify a group of instruments that share a common characteristic, such as being part of an index.

Hide code cell content

ld.close_session()