Returns sector price-to-earnings (P/E) ratios. Provide exactly one of date (a snapshot across all sectors on that date) or sector (the historical time series for one sector).

Also known as: sector P/E snapshot, sector P/E history, sector valuation trend.

Sector P/E in Python

get_sector_pe is part of the Discovery module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_sector_pe as shown below.

from financetoolkit import Discovery

discovery = Discovery(api_key="FINANCIAL_MODELING_PREP_KEY")

sector_pe = discovery.get_sector_pe(date="2024-02-01")

sector_pe.head()

sector_pe_history = discovery.get_sector_pe(sector="Energy")

sector_pe_history.tail()

Which returns:

Sector Date Exchange PE Ratio
Basic Materials 2024-02-01 NASDAQ 15.6877
Communication Services 2024-02-01 NASDAQ 25.9425
Consumer Cyclical 2024-02-01 NASDAQ 55.2588
Consumer Defensive 2024-02-01 NASDAQ 31.7298
Energy 2024-02-01 NASDAQ 14.4114

Parameters

get_sector_pe accepts the following parameters:

  • date (str, optional): The date to retrieve a snapshot for, e.g. “2024-02-01”.
  • sector (str, optional): The sector to retrieve the history for, e.g. “Energy”.
Share