Yahoo Finance stock screener with complete feature parity
Project description
yfinance-screener
A Python package providing programmatic access to Yahoo Finance's stock screener with complete feature parity to the web interface.
Features
- Complete Filter Support: Access all Yahoo Finance screener filters including price, market cap, P/E ratio, volume, dividends, sectors, regions, and more
- US Stocks by Default: Automatically filters to US stocks unless you specify different regions
- YFinance Compatible: Returns data in formats compatible with the yfinance library
- Flexible Query Building: Simple parameter-based screening or advanced fluent query builder interface
- Smart Caching: Configurable result caching to minimize API calls
- Robust Error Handling: Clear error messages and automatic retry logic
- Type Hints: Full type hint support for better IDE integration
Installation
pip install yfinance-screener
After installation, you need to install the Playwright browser:
playwright install chromium
Quick Start
Simple Screening
from yfinance_screener import Screener
# Create a screener instance
screener = Screener()
# Screen for US stocks with basic filters (US is the default region)
symbols = screener.screen(
min_price=10,
max_price=100,
min_market_cap=10_000_000_000,
max_results=50
)
print(f"Found {len(symbols)} stocks: {symbols[:5]}")
Get Detailed Data as DataFrame
import pandas as pd
from yfinance_screener import Screener
screener = Screener()
# Get detailed data as pandas DataFrame
df = screener.screen(
min_price=10,
max_price=100,
sectors=["Technology", "Healthcare"],
min_pe_ratio=10,
max_pe_ratio=30,
as_dataframe=True
)
print(df.head())
Advanced Query Building
from yfinance_screener import Screener
screener = Screener()
# Build complex queries with fluent interface
results = screener.query() \
.price(min=50, max=200) \
.market_cap(min=1_000_000_000) \
.pe_ratio(min=10, max=25) \
.dividend_yield(min=2.0) \
.sector("Technology", "Healthcare") \
.region("us") \
.sort_by("marketCap", order="desc") \
.limit(100) \
.execute(as_dataframe=True)
print(results)
Available Filters
The package supports all Yahoo Finance screener filters:
- Price:
min_price,max_price - Market Cap:
min_market_cap,max_market_cap - Volume:
min_volume,max_volume - Valuation Ratios:
min_pe_ratio,max_pe_ratio,min_pb_ratio,max_pb_ratio,min_peg_ratio,max_peg_ratio - Dividends:
min_dividend_yield,max_dividend_yield - Growth Metrics:
min_revenue_growth,max_revenue_growth,min_earnings_growth,max_earnings_growth - Profitability:
min_profit_margin,max_profit_margin,min_roe,max_roe,min_roa,max_roa - Categorical:
sectors,industries,regions,exchanges
Region Filtering
By default, the screener returns only US stocks. To search other regions:
# Search European stocks
symbols = screener.screen(
min_price=10,
regions=["eu"]
)
# Search multiple regions
symbols = screener.screen(
min_price=10,
regions=["us", "ca", "gb"] # US, Canada, UK
)
# Search ALL regions (pass empty list)
symbols = screener.screen(
min_price=10,
regions=[]
)
Available regions: us, eu, asia, au, ca, gb
Configuration
from yfinance_screener import Screener
# Configure caching and browser behavior
screener = Screener(
cache_enabled=True, # Enable result caching
cache_ttl=3600, # Cache TTL in seconds (1 hour)
headless=True # Run browser in headless mode
)
Integration with yfinance
import yfinance as yf
from yfinance_screener import Screener
# Screen for stocks
screener = Screener()
symbols = screener.screen(
min_market_cap=50_000_000_000,
sectors=["Technology"],
max_results=10
)
# Use with yfinance to get detailed data
for symbol in symbols:
ticker = yf.Ticker(symbol)
info = ticker.info
print(f"{symbol}: {info.get('longName')} - ${info.get('currentPrice')}")
Backward Compatibility
For users of the original yfinance_screener_fetcher module:
from yfinance_screener import YFinanceScreenerFetcher
# Legacy interface still works
fetcher = YFinanceScreenerFetcher()
stocks = fetcher.fetch_stocks(
min_price=10.0,
max_price=100.0,
min_market_cap=10_000_000_000
)
Requirements
- Python 3.8+
- playwright >= 1.40.0
- playwright-stealth >= 1.0.0
- pandas >= 1.5.0
- aiohttp >= 3.8.0
Documentation
For detailed documentation, see:
License
MIT License - see LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
For issues and questions:
- GitHub Issues: https://github.com/yourusername/yfinance-screener/issues
- Documentation: https://yfinance-screener.readthedocs.io
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yfinance_screener-1.0.0.tar.gz.
File metadata
- Download URL: yfinance_screener-1.0.0.tar.gz
- Upload date:
- Size: 49.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8423d42e1bfe59c84a2abca7a596479e1ab2581e15ac26b1fecaf81558262ba
|
|
| MD5 |
357fe4d2ffb49600c90e0dc41d1c6103
|
|
| BLAKE2b-256 |
0a93cc886224d24a37f3ca33cebf1e961c44dc79aa7c95e4197c68382c328811
|
File details
Details for the file yfinance_screener-1.0.0-py3-none-any.whl.
File metadata
- Download URL: yfinance_screener-1.0.0-py3-none-any.whl
- Upload date:
- Size: 29.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4a727cf1678c76ca92a35e19f99f36f155669d72640b724ddfe8727a18d9b02
|
|
| MD5 |
4a5f1af1c916874ab56c0c6cd49a45ec
|
|
| BLAKE2b-256 |
2d5d6b732a22a9b8965d3afd73dab5f75f0ea986e81f0e68836f08e306f1e7a5
|