Step 01: Data
SEC EDGAR + yfinance Ingestion
Annual income statements, balance sheets, and cash flow statements fetched via
yfinance (primary) with automatic fallback to the
SEC EDGAR XBRL API when yfinance returns empty data.
Market data (beta, P/E, EV/EBITDA, sector) sourced from yfinance info.
80 companies ingested; each returning 4–6 years of annual data.
Step 02: Features
22-Feature Financial Engineering
Features span revenue momentum (YoY growth, 1-year lag, 3-year CAGR),
profitability levels and trends (gross, EBITDA, net margins + trend
direction), cash generation (FCF margin + lag),
returns (ROE, ROA, ROIC), balance sheet
(D/E, current ratio), investment intensity (CapEx, R&D), valuation multiples,
and sector encoding. Lag and trend features capture momentum,
the single largest driver of model improvement.
Step 03: Models
XGBoost + LightGBM Ensemble
Two regression targets: forward 1-year revenue growth and
forward 1-year FCF margin. Both XGBoost (depth-3, high regularization)
and LightGBM (15 leaves) are trained; predictions are blended 50/50.
Validated with walk-forward validation: train on all years before
year t, test on year t, ensuring zero future leakage.
Baseline models (persistence + historical mean) provide comparison benchmarks.
Step 04: Valuation
WACC · DCF · Gordon Growth
WACC computed per-company via CAPM (Ke = Rf + β × ERP)
with market-implied cost of debt. Revenue and FCF margin projections use model predictions
with geometric decay toward long-run rates. Terminal value via
Gordon Growth Model. DCF intrinsic value compared to current price
to generate BUY / HOLD / SELL ratings.
Step 05: Risk
Monte Carlo Simulation
5,000 iterations bootstrapped from walk-forward OOF residuals
(not in-sample residuals) to get honest noise estimates. Each iteration perturbs
revenue growth, FCF margin, and WACC, re-runs the full DCF, and records the
intrinsic value. Output is a full probability distribution over fair value,
quantifying upside/downside risk beyond the point estimate.
Step 06: Explain
SHAP Waterfall Explanations
SHAP TreeExplainer decomposes each prediction into per-feature
contributions, making the model fully interpretable. Beeswarm plots show
global feature importance across the training set; waterfall plots explain
each individual stock prediction: which specific financial characteristics
are driving the revenue growth and FCF margin forecasts up or down.
Walk-Forward Validation
Unlike k-fold or group-k-fold, walk-forward is the only CV scheme that
respects chronological ordering. The model is never allowed to
train on future data when predicting the past, mirroring exactly how the
model would be deployed in production.
Persistence Baseline
The persistence model predicts next year = this year, a surprisingly
hard benchmark in finance. Beating persistence on revenue growth
is the minimum bar. Beating it on FCF margin requires capturing genuine
mean-reversion and company-specific dynamics the market hasn't priced.