METHODOLOGY

The 4-Factor Model

Hierarchical residual attribution — market, sector, sub-sector, idiosyncratic

THE 4-FACTOR HIERARCHICAL MODEL

rstock=βmkt· rmarket+βsec· rSPDRsec+βsub· rSPDRsub+ε

Sector and sub-sector ETFs are auto-detected per stock via sequential OLS on residuals

MARKET
βmkt × rSPY
S&P 500 broad market exposure
SECTOR
βsec × rSPDR
Best-fit SPDR on market residual (auto-detected per stock)
SUB-SECTOR
βsub × rSPDR
Best-fit SPDR on sector residual, excluding sector ETF
FUNDAMENTAL
ε  (residual)
Pure idiosyncratic — informed money
FUND%  =  |εcum|  ÷  ( |mktcum|  +  |seccum|  +  |subcum|  +  |εcum| )

High FUND% = the stock is moving for reasons the market, sector, and sub-sector can't explain. That's the informed-money signal.

◆ Compression Signal

Fires when all three systematic factors are negative (mkt_cum < 0, sec_cum < 0, sub_cum < 0) while the idiosyncratic component is positive (ε_cum > 0). This pattern suggests informed accumulation against macro and sector headwinds — the stock is being bought for fundamental reasons despite broad market and sector drag.

Shown as a purple ring on heatmap cells and a badge on the stock detail page.

1 − var(ε) / var(rstock)
Model fit — how much of daily variance is explained by the 3 systematic factors
α / day
mean(ε) × 10,000
Average daily idiosyncratic return in basis points

Implementation details

Regression: Sequential OLS without intercept. Level 1: regress rstock on rSPY → βmkt, residual₁. Level 2: regress residual₁ on all 11 SPDRs, pick highest |β| → βsec, residual₂. Level 3: regress residual₂ on remaining 10 SPDRs, pick highest |β| → βsub, ε. Mirrors the MFRA Pine Script approach.

Lookback: 1M, 3M, 6M, 12M (selectable on the screen). All four periods are computed from a single price download each day. Minimum bar floor scales with lookback (≥14 bars for 1M, ≥40 for 3M+).

Sector ETFs: XLE, XLB, XLI, XLY, XLP, XLV, XLF, XLK, XLC, XLU, XLRE — all 11 SPDRs evaluated at every level. ETF assignments are data-driven, not hardcoded from GICS.

Universe: All current S&P 500 constituents (sourced from Wikipedia). Top 10 per sector exported per lookback period.

Refresh cadence: GitHub Actions runs the screen daily after market close (21:30 UTC) and commits fresh JSON for all four lookback periods. Vercel auto-deploys on every commit.