Sector Performance
Returns sector performance - the average price change per sector. 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 performance snapshot, sector performance history, sector trend.
Sector Performance in Python
get_sector_performance is part of the Discovery module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_sector_performance as shown below.
from financetoolkit import Discovery
discovery = Discovery(api_key="FINANCIAL_MODELING_PREP_KEY")
sector_snapshot = discovery.get_sector_performance(date="2024-02-01")
sector_snapshot.head()
sector_history = discovery.get_sector_performance(sector="Energy")
sector_history.tail()
Which returns:
| Sector | Date | Exchange | Average Change |
|---|---|---|---|
| Basic Materials | 2024-02-01 | NASDAQ | -0.31481 |
| Communication Services | 2024-02-01 | NASDAQ | 0.85070 |
| Consumer Cyclical | 2024-02-01 | NASDAQ | 1.81130 |
| Consumer Defensive | 2024-02-01 | NASDAQ | 1.74347 |
| Energy | 2024-02-01 | NASDAQ | 0.63975 |
Parameters
get_sector_performance 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”.