yf_screen tool runs powerful screener queries against Yahoo Finance’s database to filter stocks and funds based on fundamental metrics, technical indicators, and other criteria.
Parameters
Screener query. Can be:
- String: Predefined screener name (e.g., “aggressive_small_caps”)
- Object: Custom query builder structure with
operatorandoperands
Type of securities to screen.Options:
equity- Screen stocks/equitiesfund- Screen mutual funds and ETFs
Starting position for paginated results.Constraints: Min: 0
Number of results per page.Constraints: Min: 1, Max: 250
Total number of results to return across all pages.Constraints: Min: 1, Max: 250
Field name to sort results by (e.g., “marketcap”, “peratio”, “volumeavg”).
Sort direction.
true for ascending, false for descending.User identifier (optional, for saved screeners).
Type of user identifier (optional).
Output Options
Format of the response data.Options:
json, markdownNumber of rows to preview when using markdown format.Constraints: Min: 1, Max: 200
Save the results to a file.
Query Builder Structure
Custom queries use a recursive structure with operators and operands:Common Operators
- AND - All conditions must be true
- OR - At least one condition must be true
- GT - Greater than
- LT - Less than
- GTE - Greater than or equal
- LTE - Less than or equal
- EQ - Equal to
- BTWN - Between two values (inclusive)
Field References
Operands can reference screener fields:- Market cap:
marketcap - P/E ratio:
peratio - Volume:
volumeavg - Price:
lastprice - Sector:
sector - Industry:
industry
Examples
Predefined Screener
Use built-in screener presets:Large-Cap Tech Stocks
Find technology stocks with market cap over $10B:Value Stocks with Low P/E
Screen for stocks with P/E ratio between 5 and 15:High-Volume Stocks
Find stocks with average volume over 1 million shares:Multi-Criteria Screen
Combine multiple conditions:Fund Screening
Screen mutual funds or ETFs:Pagination
Handle large result sets with pagination:Response Structure
Screener results include:- Symbol: Ticker symbol
- Name: Company/fund name
- Field Data: All requested and available fields for each result
- Total: Total number of matches (for pagination)
Best Practices
The maximum
count and size is 250 results. For larger datasets, use pagination with offset.