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 0x7fcbf88ba3c0 {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 ticket 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 IBM.N International Business Machines Corp IBM
1 JPM.N JPMorgan Chase & Co JPM
2 GS.N Goldman Sachs Group Inc GS
3 AAPL.OQ Apple Inc AAPL
4 NVDA.OQ NVIDIA Corp NVDA
5 TRV.N Travelers Companies Inc TRV
6 CRM.N Salesforce Inc CRM
7 PG.N Procter & Gamble Co PG
8 CSCO.OQ Cisco Systems Inc CSCO
9 MMM.N 3M Co MMM
10 BA.N Boeing Co BA
11 UNH.N UnitedHealth Group Inc UNH
12 HD.N Home Depot Inc HD
13 CVX.N Chevron Corp CVX
14 MRK.N Merck & Co Inc MRK
15 DIS.N Walt Disney Co DIS
16 V.N Visa Inc V
17 VZ.N Verizon Communications Inc VZ
18 MCD.N McDonald's Corp MCD
19 JNJ.N Johnson & Johnson JNJ
20 NKE.N Nike Inc NKE
21 SHW.N Sherwin-Williams Co SHW
22 MSFT.OQ Microsoft Corp MSFT
23 KO.N Coca-Cola Co KO
24 WMT.N Walmart Inc WMT
25 AMGN.OQ Amgen Inc AMGN
26 CAT.N Caterpillar Inc CAT
27 HON.OQ Honeywell International Inc HON
28 AMZN.OQ Amazon.com Inc AMZN
29 AXP.N American Express Co AXP

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()