EquityQuery#

class yfinance.EquityQuery(operator: str, operand: Real | str | List[EquityQuery])#

The EquityQuery class constructs filters for stocks based on specific criteria such as region, sector, exchange, and peer group.

The queries support operators: GT (greater than), LT (less than), BTWN (between), EQ (equals), and logical operators AND and OR for combining multiple conditions.

Example

Screen for stocks where the end-of-day price is greater than 3.

gt = yf.EquityQuery('gt', ['eodprice', 3])

Screen for stocks where the average daily volume over the last 3 months is less than a very large number.

lt = yf.EquityQuery('lt', ['avgdailyvol3m', 99999999999])

Screen for stocks where the intraday market cap is between 0 and 100 million.

btwn = yf.EquityQuery('btwn', ['intradaymarketcap', 0, 100000000])

Screen for stocks in the Technology sector.

eq = yf.EquityQuery('eq', ['sector', 'Technology'])

Combine queries using AND/OR.

qt = yf.EquityQuery('and', [gt, lt])
qf = yf.EquityQuery('or', [qt, btwn, eq])

See also

EquityQuery.valid_operand_fields

supported operand values for query

EquityQuery.valid_eq_operand_map

supported EQ query operand parameters

Attributes

valid_eq_operand_map

Valid Operand Map for Operator “EQ”

Permitted Keys/Values#

Key

Values

region

  • ar

  • at

  • au

  • be

  • br

  • ca

  • ch

  • cl

  • cn

  • cz

  • de

  • dk

  • ee

  • eg

  • es

  • fi

  • fr

  • gb

  • gr

  • hk

  • hu

  • id

  • ie

  • il

  • in

  • is

  • it

  • jp

  • kr

  • kw

  • lk

  • lt

  • lv

  • mx

  • my

  • nl

  • no

  • nz

  • pe

  • ph

  • pk

  • pl

  • pt

  • qa

  • ro

  • ru

  • sa

  • se

  • sg

  • sr

  • th

  • tr

  • tw

  • us

  • ve

  • vn

  • za

sector

  • Basic Materials

  • Communication Services

  • Consumer Cyclical

  • Consumer Defensive

  • Energy

  • Financial Services

  • Healthcare

  • Industrials

  • Real Estate

  • Technology

  • Utilities

exchanges

  • BSE

  • NAS

  • NCM

  • NGM

  • NMS

  • NYQ

  • YHD

peer_group

  • Aerospace & Defense

  • Auto Components

  • Automobiles

  • Banks

  • Building Products

  • Chemicals

  • China Fund Aggressive Allocation Fund

  • China Fund Equity Funds

  • China Fund QDII Greater China Equity

  • China Fund QDII Sector Equity

  • China Fund Sector Equity Financial and Real Estate

  • Commercial Services

  • Construction & Engineering

  • Construction Materials

  • Consumer Durables

  • Consumer Services

  • Containers & Packaging

  • Diversified Financials

  • Diversified Metals

  • EAA CE Global Large-Cap Blend Equity

  • EAA CE Other

  • EAA CE Sector Equity Biotechnology

  • EAA CE UK Large-Cap Equity

  • EAA CE UK Small-Cap Equity

  • EAA Fund Asia ex-Japan Equity

  • EAA Fund China Equity

  • EAA Fund China Equity - A Shares

  • EAA Fund Denmark Equity

  • EAA Fund EUR Aggressive Allocation - Global

  • EAA Fund EUR Corporate Bond

  • EAA Fund EUR Moderate Allocation - Global

  • EAA Fund Emerging Europe ex-Russia Equity

  • EAA Fund Europe Large-Cap Blend Equity

  • EAA Fund Eurozone Large-Cap Equity

  • EAA Fund Germany Equity

  • EAA Fund Global Emerging Markets Equity

  • EAA Fund Global Equity Income

  • EAA Fund Global Flex-Cap Equity

  • EAA Fund Global Large-Cap Blend Equity

  • EAA Fund Global Large-Cap Growth Equity

  • EAA Fund Hong Kong Equity

  • EAA Fund Japan Large-Cap Equity

  • EAA Fund Other Bond

  • EAA Fund Other Equity

  • EAA Fund RMB Bond - Onshore

  • EAA Fund Sector Equity Consumer Goods & Services

  • EAA Fund Sector Equity Financial Services

  • EAA Fund Sector Equity Industrial Materials

  • EAA Fund Sector Equity Technology

  • EAA Fund South Africa & Namibia Equity

  • EAA Fund Switzerland Equity

  • EAA Fund US Large-Cap Blend Equity

  • EAA Fund USD Corporate Bond

  • Electrical Equipment

  • Energy Services

  • Food Products

  • Food Retailers

  • Healthcare

  • Homebuilders

  • Household Products

  • India CE Multi-Cap

  • India Fund Large-Cap

  • India Fund Sector - Financial Services

  • Industrial Conglomerates

  • Insurance

  • Machinery

  • Media

  • Mexico Fund Mexico Equity

  • Oil & Gas Producers

  • Paper & Forestry

  • Pharmaceuticals

  • Precious Metals

  • Real Estate

  • Refiners & Pipelines

  • Retailing

  • Semiconductors

  • Software & Services

  • Steel

  • Technology Hardware

  • Telecommunication Services

  • Textiles & Apparel

  • Traders & Distributors

  • Transportation

  • Transportation Infrastructure

  • US CE Convertibles

  • US CE Options-based

  • US CE Preferred Stock

  • US Fund China Region

  • US Fund Consumer Cyclical

  • US Fund Diversified Emerging Mkts

  • US Fund Equity Energy

  • US Fund Equity Precious Metals

  • US Fund Financial

  • US Fund Foreign Large Blend

  • US Fund Health

  • US Fund Large Blend

  • US Fund Large Growth

  • US Fund Large Value

  • US Fund Miscellaneous Region

  • US Fund Natural Resources

  • US Fund Technology

  • US Fund Trading–Leveraged Equity

  • Utilities

valid_operand_fields

Valid Operand Fields

Permitted Keys/Values#

Key

Values

eq_fields

  • exchanges

  • peer_group

  • region

  • sector

price

  • eodprice

  • fiftytwowkpercentchange

  • intradaymarketcap

  • intradayprice

  • intradaypricechange

  • lastclose52weekhigh.lasttwelvemonths

  • lastclose52weeklow.lasttwelvemonths

  • lastclosemarketcap.lasttwelvemonths

  • percentchange

trading

  • avgdailyvol3m

  • beta

  • dayvolume

  • eodvolume

  • pctheldinsider

  • pctheldinst

short_interest

  • days_to_cover_short.value

  • short_interest.value

  • short_interest_percentage_change.value

  • short_percentage_of_float.value

  • short_percentage_of_shares_outstanding.value

valuation

  • bookvalueshare.lasttwelvemonths

  • lastclosemarketcaptotalrevenue.lasttwelvemonths

  • lastclosepriceearnings.lasttwelvemonths

  • lastclosepricetangiblebookvalue.lasttwelvemonths

  • lastclosetevtotalrevenue.lasttwelvemonths

  • pegratio_5y

  • peratio.lasttwelvemonths

  • pricebookratio.quarterly

profitability

  • consecutive_years_of_dividend_growth_count

  • forward_dividend_per_share

  • forward_dividend_yield

  • returnonassets.lasttwelvemonths

  • returnonequity.lasttwelvemonths

  • returnontotalcapital.lasttwelvemonths

leverage

  • ebitdainterestexpense.lasttwelvemonths

  • ebitinterestexpense.lasttwelvemonths

  • lastclosetevebit.lasttwelvemonths

  • lastclosetevebitda.lasttwelvemonths

  • ltdebtequity.lasttwelvemonths

  • netdebtebitda.lasttwelvemonths

  • totaldebtebitda.lasttwelvemonths

  • totaldebtequity.lasttwelvemonths

liquidity

  • altmanzscoreusingtheaveragestockinformationforaperiod.lasttwelvemonths

  • currentratio.lasttwelvemonths

  • operatingcashflowtocurrentliabilities.lasttwelvemonths

  • quickratio.lasttwelvemonths

income_statement

  • basicepscontinuingoperations.lasttwelvemonths

  • dilutedeps1yrgrowth.lasttwelvemonths

  • dilutedepscontinuingoperations.lasttwelvemonths

  • ebit.lasttwelvemonths

  • ebitda.lasttwelvemonths

  • ebitda1yrgrowth.lasttwelvemonths

  • ebitdamargin.lasttwelvemonths

  • epsgrowth.lasttwelvemonths

  • grossprofit.lasttwelvemonths

  • grossprofitmargin.lasttwelvemonths

  • netepsbasic.lasttwelvemonthsnetepsdiluted.lasttwelvemonths

  • netincome1yrgrowth.lasttwelvemonths

  • netincomeis.lasttwelvemonths

  • netincomemargin.lasttwelvemonths

  • operatingincome.lasttwelvemonths

  • quarterlyrevenuegrowth.quarterly

  • totalrevenues.lasttwelvemonths

  • totalrevenues1yrgrowth.lasttwelvemonths

balance_sheet

  • totalassets.lasttwelvemonths

  • totalcashandshortterminvestments.lasttwelvemonths

  • totalcommonequity.lasttwelvemonths

  • totalcommonsharesoutstanding.lasttwelvemonths

  • totalcurrentassets.lasttwelvemonths

  • totalcurrentliabilities.lasttwelvemonths

  • totaldebt.lasttwelvemonths

  • totalequity.lasttwelvemonths

  • totalsharesoutstanding

cash_flow

  • capitalexpenditure.lasttwelvemonths

  • cashfromoperations.lasttwelvemonths

  • cashfromoperations1yrgrowth.lasttwelvemonths

  • forward_dividend_yield

  • leveredfreecashflow.lasttwelvemonths

  • leveredfreecashflow1yrgrowth.lasttwelvemonths

  • unleveredfreecashflow.lasttwelvemonths

esg

  • environmental_score

  • esg_score

  • governance_score

  • highest_controversy

  • social_score

Methods

__init__(operator: str, operand: Real | str | List[EquityQuery])

See also

EquityQuery.valid_operand_fields

supported operand values for query

EquityQuery.valid_eq_operand_map

supported EQ query operand parameters

to_dict() Dict