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