For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
7 1 1 1

Sector average data for a specific stock

How to get sector average data for specific stock, e.g., find average P/E ratio for the sector that AAPL.O is in? Is there an example?

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythonapi
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvotes
Accepted
4.6k 26 7 22

Yes, with the use of screening functions (for sector) or peer service (for peers). The following code gives you an average historic p/e for all companies in Apple Inc. sector, headquartered in US with market cap > $1B:

import eikon as tr

tr.set_app_id('your_app_id')
expression = 'SCREEN(U(IN(Equity(active,public,primary))), \
                IN(TR.GICSSectorCode,45), IN(TR.HQCountryCode,US), \
                TR.CompanyMarketCap>=1000000000, CURN=USD)'

df, e = tr.get_data([exp], ['TR.CompanyName','TR.HistPE'])
df.dropna()
df['Historic P/E'].mean()


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea