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.
Permitted Keys/Values# 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.
Permitted Keys/Values# Key
Values
exchange
ae: DFM
ar: BUE
at: VIE
au: ASX, CXA
be: BRU
br: SAO
ca: CNQ, NEO, TOR, VAN
ch: EBS
cl: SGO
cn: SHH, SHZ
co: BVC
cz: PRA
de: BER, DUS, EUX, FRA, GER, HAM, HAN, MUN, STU
dk: CPH
ee: TAL
eg: CAI
es: BAR, MAD, MCE
fi: HEL
fr: ENX, PAR
gb: CXE, IOB, LSE
gr: ATH
hk: HKG
hu: BUD
id: JKT
ie: ISE
il: TLV
in: BSE, NSI
is: ICE
it: MIL
jp: FKA, JPX, OSA, SAP
kr: KOE, KSC
kw: KUW
lk: CSE
lt: LIT
lv: RIS
mx: MEX
my: KLS
nl: AMS
no: OSL
nz: NZE
pe:
ph: PHP, PHS
pk: KAR
pl: WSE
pt: LIS
qa: DOH
ro: BVB
ru: MCX
sa: SAU
se: STO
sg: SES
sr:
th: SET
tr: IST
tw: TAI, TWO
us: ASE, NAS, NCM, NGM, NMS, NYQ, OEM, OGM, OQB, PNK, WCB
ve: CCS
vn: VSE
za: JNB
Methods
- __init__(operator: str, operand: List[QueryBase] | Tuple[str, Tuple[str | Real, ...]])
- to_dict() Dict