FundQuery#
- class yfinance.FundQuery(operator: str, operand: List[QueryBase] | Tuple[str, Tuple[str | Real, ...]])#
The FundQuery class constructs filters for mutual funds based on specific criteria such as region, sector, exchange, and peer group.
Start with value operations: EQ (equals), IS-IN (is in), BTWN (between), GT (greater than), LT (less than), GTE (greater or equal), LTE (less or equal).
Combine them with logical operations: AND, OR.
Example
Predefined Yahoo query solid_large_growth_funds:
from yfinance import FundQuery FundQuery('and', [ FundQuery('eq', ['categoryname', 'Large Growth']), FundQuery('is-in', ['performanceratingoverall', 4, 5]), FundQuery('lt', ['initialinvestment', 100001]), FundQuery('lt', ['annualreturnnavy1categoryrank', 50]), FundQuery('eq', ['exchange', 'NAS']) ])
Attributes
- valid_fields
Valid operands, grouped by category.
# Key
Values
eq_fields
annualreturnnavy1categoryrank
categoryname
exchange
initialinvestment
performanceratingoverall
riskratingoverall
price
eodprice
intradayprice
intradaypricechange
- valid_values
Most operands take number values, but some have a restricted set of valid values.
# Key
Values
exchange
us: NAS
Methods
- __init__(operator: str, operand: List[QueryBase] | Tuple[str, Tuple[str | Real, ...]])
- to_dict() Dict