Sector and Industry#
Sector class#
The Sector and Industry modules provide access to the Sector and Industry information.
|
Represents a financial market sector and allows retrieval of sector-related data such as top ETFs, top mutual funds, and industry data. |
|
Represents an industry within a sector. |
See also
Sector.industriesMap of sector and industry
Sample Code#
To initialize, use the relevant sector or industry key as below.
import yfinance as yf
tech = yf.Sector('technology')
software = yf.Industry('software-infrastructure')
# Common information
tech.key
tech.name
tech.symbol
tech.ticker
tech.overview
tech.top_companies
tech.research_reports
# Sector information
tech.top_etfs
tech.top_mutual_funds
tech.industries
# Industry information
software.sector_key
software.sector_name
software.top_performing_companies
software.top_growth_companies
The modules can be chained with Ticker as below.
import yfinance as yf
# Ticker to Sector and Industry
msft = yf.Ticker('MSFT')
tech = yf.Sector(msft.info.get('sectorKey'))
software = yf.Industry(msft.info.get('industryKey'))
# Sector and Industry to Ticker
tech_ticker = tech.ticker
tech_ticker.info
software_ticker = software.ticker
software_ticker.history()
Region scoping#
By default Sector and Industry return U.S. data. Pass a Yahoo region
(ISO 3166-1 alpha-2 country code, case-insensitive) to scope top_companies,
top_etfs, top_mutual_funds and the industry top performing/growth lists:
yf.Sector("technology", region="GB").top_companies # UK
yf.Sector("technology", region="DE").top_companies # Germany
yf.Industry("software-infrastructure", region="JP") # Japan