yfinance.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"

valid_operand_fields

Valid Operand Fields

Methods

__init__(operator, operand)

to_dict()