Build a fundamental stock screener that filters by P/E ratio, free cash flow, and revenue growth — using clean, structured data sourced directly from SEC EDGAR.
Most stock screeners rely on third-party data that may be delayed, aggregated, or derived from unknown sources. By going straight to SEC EDGAR — the official source of public company filings — you get:
Financial statements from official SEC filings, not estimates
Screen using long-term trends, not just the latest quarter
Revenue, net income, free cash flow — directly from 10-K/10-Q
pip install factstream
This script screens a list of tickers by P/E ratio and free cash flow yield, using data sourced from SEC EDGAR via FactStream:
import factstream
client = factstream.Client(api_key="your_api_key")
# Define your universe — could be S&P 500, a sector, or custom list
tickers = [
"AAPL", "MSFT", "GOOGL", "AMZN", "META",
"JNJ", "JPM", "V", "PG", "UNH",
"HD", "MA", "NVDA", "PFE", "KO"
]
# Screening criteria
MAX_PE = 25 # Maximum P/E ratio
MIN_FCF_YIELD = 0.03 # Minimum 3% free cash flow yield
print("Stock Screener: P/E < 25 & FCF Yield > 3%")
print("=" * 55)
results = []
for ticker in tickers:
try:
# Get valuation metrics
metrics = client.metrics.get(ticker=ticker)
pe = metrics.pe_ratio
fcf_yield = metrics.free_cash_flow_yield
# Skip if data is missing
if pe is None or fcf_yield is None:
continue
# Apply filters
if pe < MAX_PE and pe > 0 and fcf_yield > MIN_FCF_YIELD:
# Get latest income statement for context
income = client.financials.income_statement(
ticker=ticker,
period="annual",
limit=2
)
revenue = income[0].revenue
prev_revenue = income[1].revenue if len(income) > 1 else None
rev_growth = ((revenue - prev_revenue) / prev_revenue * 100
if prev_revenue else None)
results.append({
"ticker": ticker,
"pe": pe,
"fcf_yield": fcf_yield,
"revenue": revenue,
"rev_growth": rev_growth,
})
except Exception as e:
print(f" Skipping {ticker}: {e}")
# Sort by FCF yield (highest first)
results.sort(key=lambda x: x["fcf_yield"], reverse=True)
# Display results
for r in results:
growth_str = f"{r['rev_growth']:+.1f}%" if r["rev_growth"] else "N/A"
print(f"{r['ticker']:>6} P/E: {r['pe']:5.1f} "
f"FCF Yield: {r['fcf_yield']:5.1%} "
f"Revenue Growth: {growth_str}")The screener filters for stocks with:
Because FactStream sources from SEC EDGAR, these numbers come from audited financial statements — not third-party estimates.
With FactStream's API, you can add more sophisticated criteria:
Use balance sheet data to screen for low-leverage companies.
Check 10 years of net income to find companies that never had a loss.
Compare dividends paid vs free cash flow to find sustainable payers.
Cross-reference with Form 4 filings to see if insiders are buying.