The algorithm
How it works, end to end
Six steps, every month. Click any step below to expand its details, or dive into a dedicated explainer.
Monthly pipeline
From raw filings to live signals
Click any step to see the details. Hover the connectors to follow the flow.
1 📥 Pull data EDGAR + Yahoo Finance Click to expand ↓ Collapse ↑
Pull fundamentals + prices
- Each month, fetch the latest 10-K filings from SEC EDGAR companyfacts API for every ticker in our investable universe — a Russell 3000 approximation (~3,000 largest US firms by market cap, NASDAQ + NYSE).
- Daily adjusted closes for the past 800 days from Yahoo Finance, for momentum and beta calculations.
- Cached locally for 30 days to avoid hitting rate limits — only the deltas are re-pulled monthly.
2 ⚖️ Score quality 13 ratios → z-score Click to expand ↓ Collapse ↑
Compute composite quality score
- Profitability (6 ratios): gross profit / assets, ROE, ROA, operating cash flow / assets, gross margin, accruals.
- Growth: 5-year change in each profitability ratio.
- Safety: Altman Z-score components + Piotroski-like liquidity ratios + inverted leverage.
- Cross-sectional rank z-score at each level, then composite = z(mean of three pillars).
3 🚀 Filter momentum 12-1 month, > median Click to expand ↓ Collapse ↑
Apply academic momentum filter
- Cumulative return over [t-252, t-21] days — 12 months excluding the last month (avoids short-term reversal noise).
- Keep only stocks with momentum > 0 AND > cross-sectional median.
- Typically eliminates 40-60% of the top quality decile.
4 🛡️ Check regime Trailing 3M ret > 0? Click to expand ↓ Collapse ↑
Test the regime indicator
- If the strategy's own trailing 3-month return is positive → FULL exposure (100% invested).
- If negative → HALF exposure (50% in cash, 50% in top picks).
- Endogenous, non-discretionary — a built-in circuit breaker.
5 📊 Build weights Top decile, max 40 Click to expand ↓ Collapse ↑
Construct the portfolio
- Drop firms flagged insolvent by Altman Z-score (Z < 1.81).
- Take the top decile by composite quality.
- Cap at 40 positions max for diversification.
- Weights proportional to quality score, normalized to 100%.
6 📧 Send briefing Email + site update Click to expand ↓ Collapse ↑
Notify subscribers and refresh the site
- Commit fresh live.json + history.json to GitHub repo (auto-deploys to Vercel within 60s).
- Trigger a broadcast email via Resend to all newsletter subscribers — branded from noreply@leversenstrading.com.
- Each user gets the full picture: regime, holdings, buys/sells, performance.