ETFQuery#

class yfinance.ETFQuery(operator: Literal['eq', 'is-in', 'btwn', 'gt', 'lt', 'gte', 'lte', 'and', 'or'], operand: List[QueryBase] | List[str] | List[Real])#

The ETFQuery class constructs filters for ETFs based on specific criteria such as category, fund family, exchange, and performance ratings.

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 top_etfs_us:

from yfinance import ETFQuery

ETFQuery('and', [
    ETFQuery('gt', ['intradayprice', 10]),
    ETFQuery('is-in', ['performanceratingoverall', 4, 5]),
    ETFQuery('eq', ['region', 'us'])
])

Attributes

valid_fields

Valid operands, grouped by category.

Permitted Keys/Values#

Key

Values

eq_fields

  • categoryname

  • exchange

  • fundfamilyname

  • morningstar_economic_moat

  • morningstar_moat_trend

  • morningstar_rating_change

  • morningstar_stewardship

  • morningstar_uncertainty

  • primary_sector

  • region

fundamentals

  • fundnetassets

  • ticker

feesandexpenses

  • annualreportgrossexpenseratio

  • annualreportnetexpenseratio

  • turnoverratio

historicalperformance

  • annualreturnnavy1

  • annualreturnnavy1categoryrank

  • annualreturnnavy3

  • annualreturnnavy5

keystats

  • avgdailyvol3m

  • dayvolume

  • eodvolume

  • fiftytwowkpercentchange

  • percentchange

morningstar_rating

  • morningstar_last_close_price_to_fair_value

  • morningstar_rating

  • morningstar_rating_updated_time

portfoliostatistics

  • marketcapitalvaluelong

purchasedetails

  • initialinvestment

trailingperformance

  • performanceratingoverall

  • quarterendtrailingreturnytd

  • riskratingoverall

  • trailing_3m_return

  • trailing_ytd_return

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: MAD, MCE

  • fi: HEL

  • fr: ENX, PAR

  • gb: AQS, CXE, IOB, LSE

  • gr: ATH

  • hk: HKG

  • hu: BUD

  • id: JKT

  • ie: ISE

  • il: TLV

  • in: BSE, NSI

  • is: ICE

  • it: MDD, MIL, TLO

  • jp: FKA, JPX, OSA, SAP

  • kr: KOE, KSC

  • kw: KUW

  • lk: CSE

  • lt: LIT

  • lv: RIS

  • mx: MEX

  • my: KLS

  • nl: AMS, DXE

  • 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, BTS, CXI, NAE, NCM, NGM, NMS, NYQ, OEM, OQB, OQX, PCX, PNK, YHD

  • ve: CCS

  • vn: VSE

  • za: JNB

categoryname

  • Allocation–15% to 30% Equity

  • Allocation–30% to 50% Equity

  • Allocation–50% to 70% Equity

  • Allocation–70% to 85% Equity

  • Allocation–85%+ Equity

  • Bank Loan

  • Bear Market

  • China Region

  • Commodities Agriculture

  • Commodities Broad Basket

  • Convertibles

  • Corporate Bond

  • Diversified Emerging Mkts

  • Diversified Pacific/Asia

  • Emerging Markets Bond

  • Emerging-Markets Local-Currency Bond

  • Energy Limited Partnership

  • Equity Energy

  • Equity Precious Metals

  • Europe Stock

  • Financial

  • Foreign Large Blend

  • Foreign Large Growth

  • Foreign Large Value

  • Foreign Small/Mid Blend

  • Foreign Small/Mid Growth

  • Foreign Small/Mid Value

  • Global Real Estate

  • Health

  • High Yield Bond

  • High Yield Muni

  • Inflation-Protected Bond

  • Infrastructure

  • Intermediate Government

  • Intermediate-Term Bond

  • Japan Stock

  • Large Blend

  • Large Growth

  • Large Value

  • Long Government

  • Long-Short Credit

  • Long-Short Equity

  • Long-Term Bond

  • Managed Futures

  • Market Neutral

  • Mid-Cap Blend

  • Mid-Cap Growth

  • Mid-Cap Value

  • Miscellaneous Region

  • Multialternative

  • Multicurrency

  • Multisector Bond

  • Muni California Intermediate

  • Muni California Long

  • Muni Massachusetts

  • Muni Minnesota

  • Muni National Interm

  • Muni National Long

  • Muni National Short

  • Muni New Jersey

  • Muni New York Intermediate

  • Muni New York Long

  • Muni Ohio

  • Muni Pennsylvania

  • Muni Single State Interm

  • Muni Single State Long

  • Muni Single State Short

  • Natural Resources

  • Nontraditional Bond

  • Option Writing

  • Other

  • Other Allocation

  • Pacific/Asia ex-Japan Stk

  • Preferred Stock

  • Real Estate

  • Short Government

  • Short-Term Bond

  • Small Blend

  • Small Growth

  • Small Value

  • Tactical Allocation

  • Target-Date 2000-2010

  • Target-Date 2015

  • Target-Date 2020

  • Target-Date 2025

  • Target-Date 2030

  • Target-Date 2035

  • Target-Date 2040

  • Target-Date 2045

  • Target-Date 2050

  • Target-Date 2055

  • Target-Date 2060+

  • Target-Date Retirement

  • Technology

  • Trading - Leveraged/Inverse Commodities

  • Trading - Leveraged/Inverse Equity

  • Trading–Inverse Equity

  • Trading–Leveraged Equity

  • Ultrashort Bond

  • Utilities

  • World Allocation

  • World Bond

  • World Stock

fundfamilyname

  • ALPS

  • AMG Funds

  • AQR Funds

  • Aberdeen

  • Alger

  • AllianceBernstein

  • Allianz Funds

  • American Beacon

  • American Century Investments

  • American Funds

  • Aquila

  • Artisan

  • BMO Funds

  • BNY Mellon Funds

  • Baird

  • Barclays Funds

  • Barings Funds

  • Baron Capital Group

  • BlackRock

  • Brown Advisory Funds

  • Calamos

  • Calvert Investments

  • Catalyst Mutual Funds

  • Cohen & Steers

  • Columbia

  • Commerz Funds Solutions SA

  • Commerzbank AG, Frankfurt am Main

  • Davis Funds

  • Delaware Investments

  • Deutsche Asset Management

  • Deutsche Bank AG

  • Diamond Hill Funds

  • Dimensional Fund Advisors

  • Direxion Funds

  • DoubleLine

  • Dreyfus

  • Dunham Funds

  • Eagle Funds

  • Eaton Vance

  • Federated

  • Fidelity Investments

  • First Investors

  • First Trust

  • Flexshares Trust

  • Franklin Templeton Investments

  • GMO

  • Gabelli

  • Global X Funds

  • Goldman Sachs

  • Great-West Funds

  • Guggenheim Investments

  • GuideStone Funds

  • HSBC

  • Hancock Horizon

  • Harbor

  • Hartford Mutual Funds

  • Henderson Global

  • Hennessy

  • Highland Funds

  • ICON Funds

  • Invesco

  • Ivy Funds

  • JPMorgan

  • Janus

  • John Hancock

  • Lazard

  • Legg Mason

  • Lord Abbett

  • MFS

  • Madison Funds

  • MainStay

  • Manning & Napier

  • Market Vectors

  • MassMutual

  • Matthews Asia Funds

  • Morgan Stanley

  • Nationwide

  • Natixis Funds

  • Neuberger Berman

  • Northern Funds

  • Nuveen

  • OppenheimerFunds

  • PNC Funds

  • Pacific funds series trust

  • Pax World

  • Paydenfunds

  • Pimco

  • Pioneer Investments

  • PowerShares

  • Principal Funds

  • ProFunds

  • ProShares

  • Prudential Investments

  • Putnam

  • RBC Global Asset Management.

  • RidgeWorth

  • Royce

  • Russell

  • Rydex Funds

  • SEI

  • SPDR State Street Global Advisors

  • Salient Funds

  • Saratoga

  • Schwab Funds

  • Sentinel

  • Shelton Capital Management

  • State Farm

  • State Street Global Advisors (Chicago)

  • Sterling Capital Funds

  • SunAmerica

    1. Rowe Price

  • TCW

  • TIAA-CREF Asset Management

  • Teton Westwood Funds

  • Thornburg

  • Thrivent

  • Timothy Plan

  • Touchstone

  • Transamerica

  • UBS

  • UBS Group AG

  • USAA

  • VALIC

  • Vanguard

  • Vantagepoint Funds

  • Victory

  • Virtus

  • Voya

  • Waddell & Reed

  • Wasatch

  • Wells Fargo Funds

  • William Blair

  • WisdomTree

  • iShares

morningstar_economic_moat

  • Narrow

  • None

  • Wide

morningstar_stewardship

  • Exemplary

  • Poor

  • Standard

morningstar_uncertainty

  • Extreme

  • High

  • Low

  • Medium

  • Very High

morningstar_moat_trend

  • Negative

  • Positive

  • Stable

morningstar_rating_change

  • Downgrade

  • Upgrade

Methods

__init__(operator: Literal['eq', 'is-in', 'btwn', 'gt', 'lt', 'gte', 'lte', 'and', 'or'], operand: List[QueryBase] | List[str] | List[Real])
to_dict() Dict