yfinance.screen#
- yfinance.screen(query: str | EquityQuery | FundQuery, offset: int = None, size: int = None, sortField: str = None, sortAsc: bool = None, userId: str = None, userIdType: str = None, session=None, proxy=None)#
Run a screen: predefined query, or custom query.
- Parameters:
Defaults only apply if query = EquityQuery or FundQuery
- querystr | Query:
The query to execute, either name of predefined or custom query. For predefined list run yf.PREDEFINED_SCREENER_QUERIES.keys()
- offsetint
The offset for the results. Default 0.
- sizeint
number of results to return. Default 100, maximum 250 (Yahoo)
- sortFieldstr
field to sort by. Default “ticker”
- sortAscbool
Sort ascending? Default False
- userIdstr
The user ID. Default empty.
- userIdTypestr
Type of user ID (e.g., “guid”). Default “guid”.
- Example: predefined query
import yfinance as yf response = yf.screen("aggressive_small_caps")
- Example: custom query
import yfinance as yf from yfinance import EquityQuery q = EquityQuery('and', [ EquityQuery('gt', ['percentchange', 3]), EquityQuery('eq', ['region', 'us']) ]) response = yf.screen(q, sortField = 'percentchange', sortAsc = True)
- To access predefineds query code
import yfinance as yf query = yf.PREDEFINED_SCREENER_QUERIES['aggressive_small_caps']
# Key
Values
aggressive_small_caps
query:EquityQuery(AND, [EquityQuery(IS-IN, [‘exchange’, ‘NMS’, ‘NYQ’]),EquityQuery(LT, [‘epsgrowth.lasttwelvemonths’, 15])])sortField: eodvolumesortType: descday_gainers
query:EquityQuery(AND, [EquityQuery(GT, [‘percentchange’, 3]),EquityQuery(EQ, [‘region’, ‘us’]),EquityQuery(GTE, [‘intradaymarketcap’, 2000000000]),EquityQuery(GTE, [‘intradayprice’, 5]),EquityQuery(GT, [‘dayvolume’, 15000])])sortField: percentchangesortType: DESCday_losers
query:EquityQuery(AND, [EquityQuery(LT, [‘percentchange’, -2.5]),EquityQuery(EQ, [‘region’, ‘us’]),EquityQuery(GTE, [‘intradaymarketcap’, 2000000000]),EquityQuery(GTE, [‘intradayprice’, 5]),EquityQuery(GT, [‘dayvolume’, 20000])])sortField: percentchangesortType: ASCgrowth_technology_stocks
query:EquityQuery(AND, [EquityQuery(GTE, [‘quarterlyrevenuegrowth.quarterly’, 25]),EquityQuery(GTE, [‘epsgrowth.lasttwelvemonths’, 25]),EquityQuery(EQ, [‘sector’, ‘Technology’]),EquityQuery(IS-IN, [‘exchange’, ‘NMS’, ‘NYQ’])])sortField: eodvolumesortType: descmost_actives
query:EquityQuery(AND, [EquityQuery(EQ, [‘region’, ‘us’]),EquityQuery(GTE, [‘intradaymarketcap’, 2000000000]),EquityQuery(GT, [‘dayvolume’, 5000000])])sortField: dayvolumesortType: DESCmost_shorted_stocks
offset: 0query:EquityQuery(AND, [EquityQuery(EQ, [‘region’, ‘us’]),EquityQuery(GT, [‘intradayprice’, 1]),EquityQuery(GT, [‘avgdailyvol3m’, 200000])])size: 25sortField: short_percentage_of_shares_outstanding.valuesortType: DESCsmall_cap_gainers
query:EquityQuery(AND, [EquityQuery(LT, [‘intradaymarketcap’, 2000000000]),EquityQuery(IS-IN, [‘exchange’, ‘NMS’, ‘NYQ’])])sortField: eodvolumesortType: descundervalued_growth_stocks
query:EquityQuery(AND, [EquityQuery(BTWN, [‘peratio.lasttwelvemonths’, 0, 20]),EquityQuery(LT, [‘pegratio_5y’, 1]),EquityQuery(GTE, [‘epsgrowth.lasttwelvemonths’, 25]),EquityQuery(IS-IN, [‘exchange’, ‘NMS’, ‘NYQ’])])sortField: eodvolumesortType: DESCundervalued_large_caps
query:EquityQuery(AND, [EquityQuery(BTWN, [‘peratio.lasttwelvemonths’, 0, 20]),EquityQuery(LT, [‘pegratio_5y’, 1]),EquityQuery(BTWN, [‘intradaymarketcap’, 10000000000, 100000000000]),EquityQuery(IS-IN, [‘exchange’, ‘NMS’, ‘NYQ’])])sortField: eodvolumesortType: descconservative_foreign_funds
query:FundQuery(AND, [FundQuery(IS-IN, [‘categoryname’, ‘Foreign Large Value’, ‘Foreign Large Blend’, ‘Foreign Large Growth’, ‘Foreign Small/Mid Growth’, ‘Foreign Small/Mid Blend’, ‘Foreign Small/Mid Value’]),FundQuery(IS-IN, [‘performanceratingoverall’, 4, 5]),FundQuery(LT, [‘initialinvestment’, 100001]),FundQuery(LT, [‘annualreturnnavy1categoryrank’, 50]),FundQuery(IS-IN, [‘riskratingoverall’, 1, 2, 3]),FundQuery(EQ, [‘exchange’, ‘NAS’])])sortField: fundnetassetssortType: DESChigh_yield_bond
query:FundQuery(AND, [FundQuery(IS-IN, [‘performanceratingoverall’, 4, 5]),FundQuery(LT, [‘initialinvestment’, 100001]),FundQuery(LT, [‘annualreturnnavy1categoryrank’, 50]),FundQuery(IS-IN, [‘riskratingoverall’, 1, 2, 3]),FundQuery(EQ, [‘categoryname’, ‘High Yield Bond’]),FundQuery(EQ, [‘exchange’, ‘NAS’])])sortField: fundnetassetssortType: DESCportfolio_anchors
query:FundQuery(AND, [FundQuery(EQ, [‘categoryname’, ‘Large Blend’]),FundQuery(IS-IN, [‘performanceratingoverall’, 4, 5]),FundQuery(LT, [‘initialinvestment’, 100001]),FundQuery(LT, [‘annualreturnnavy1categoryrank’, 50]),FundQuery(EQ, [‘exchange’, ‘NAS’])])sortField: fundnetassetssortType: DESCsolid_large_growth_funds
query: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’])])sortField: fundnetassetssortType: DESCsolid_midcap_growth_funds
query:FundQuery(AND, [FundQuery(EQ, [‘categoryname’, ‘Mid-Cap Growth’]),FundQuery(IS-IN, [‘performanceratingoverall’, 4, 5]),FundQuery(LT, [‘initialinvestment’, 100001]),FundQuery(LT, [‘annualreturnnavy1categoryrank’, 50]),FundQuery(EQ, [‘exchange’, ‘NAS’])])sortField: fundnetassetssortType: DESCtop_mutual_funds
query:FundQuery(AND, [FundQuery(GT, [‘intradayprice’, 15]),FundQuery(IS-IN, [‘performanceratingoverall’, 4, 5]),FundQuery(GT, [‘initialinvestment’, 1000]),FundQuery(EQ, [‘exchange’, ‘NAS’])])sortField: percentchangesortType: DESC