S&P 500 板塊波動 ML 分析
503 支股票 · 11 個 GICS 板塊 · 3 年歷史資料 · 混合 LGBM+XGBoost Walk-Forward
11
GICS 板塊
503
成分股
~750
交易日(3 年)
—
波動最高板塊
—
均值 range_pct
—
波動最低板塊
1
各板塊描述統計(range_pct)
日內波動幅 range_pct = (High − Low) / Close × 100,代表每日最高價與最低價之間的振幅相對於收盤價的百分比。下表依均值由高到低排列,並以色條視覺化差異。
range_pct = (High − Low) / Close × 100 (unit: %)
載入中…
解讀:
2
各板塊波動分布箱型圖
依各板塊 range_pct 中位數降序排列。箱體寬度代表四分位距(IQR = P75 − P25),鬚線延伸至 1.5 × IQR,超出者以圓點標示為離群值,反映單日極端波動的頻率。
解讀:
3
跨板塊相關性分析(Pearson r vs Spearman ρ)
計算 11 個板塊每日平均 range_pct 時間序列之間的相關性。Pearson r 衡量線性相關,對極端值敏感;Spearman ρ 基於排名順序,對非線性關係與離群值更穩健。兩者結果接近表示關係接近線性。
Pearson r(X,Y) = Σ[(Xᵢ−X̄)(Yᵢ−Ȳ)] / [σ_X × σ_Y × (n−1)]
Spearman ρ(X,Y) = Pearson r( rank(X), rank(Y) )
Heatmap colour: Dark Blue = strong positive correlation (r→1) Dark Red = strong negative (r→−1) ★ marks r ≥ 0.7
Pearson r — 線性相關熱力圖
Spearman ρ — 排名相關熱力圖
解讀:
多數板塊間 Pearson r 在 0.7–0.9,顯示板塊波動高度同步——市場整體恐慌時(如 VIX 飆升),所有板塊同步波動。相關性最高的板塊對通常同屬景氣循環類(IT + 工業)或防禦類(必需品 + 公用事業),分散化效益有限。
5
60 日滾動相關性 — 市場狀態切換
固定相關係數無法反映市場狀態切換。以 60 個交易日為窗口滾動計算 Pearson r,挑選相關係數最高的 6 對板塊組合展示時間演變。市場危機期間(關稅衝擊、央行意外決策)相關性通常急速拉高,反映板塊聯動加強。
r_rolling(t) = Pearson r( X[t−59 : t], Y[t−59 : t] )
Interpretation: when r_rolling jumps from 0.5 to 0.9, the market has entered a "Risk-Off" regime —
all sectors sell off in unison and individual sector stock-picking alpha collapses.
解讀:
2025 年 4 月關稅衝擊後可見各板塊對滾動相關性快速收斂至高位(0.85–0.95),說明危機期間「分散化失靈」。此圖可用作市場恐慌指標:當多條線同時拉高,應縮減曝險或切換至避險策略。
5
偏態與峰態分析 — 厚尾特性確認
偏態(Skewness)衡量分布不對稱程度;峰態(Kurtosis)衡量尾部厚度。金融時序普遍呈現正偏態與超額峰態(Excess Kurtosis = Kurtosis − 3 > 0),俗稱「厚尾(Fat Tail)」分布,意味著極端波動事件出現頻率遠超常態分布的預期。
Skewness = E[(X−μ)³] / σ³
→ > 0: right tail longer than left (large positive swings more common than large negative)
Kurtosis = E[(X−μ)⁴] / σ⁴
→ Normal distribution Kurtosis = 3 (Excess Kurtosis = Kurtosis − 3)
→ Kurtosis > 3: fatter tails than normal — extreme events are underestimated
Risk implication: using a normal distribution to estimate VaR / CVaR will severely
underestimate tail-loss probability. Use Student-t or Cornish-Fisher correction instead.
解讀:
▶
離群事件深度解析 — Financials 峰態 718.5 成因
11
板塊全部平穩
—
Granger 顯著對數
—
最高 GARCH 預測波動
—
最低 GARCH 預測波動
1
平穩性檢定 — ADF + KPSS
時間序列建模(GARCH、VAR)的前提是序列平穩(stationary)。使用兩種互補檢定:ADF 拒絕「有單位根」假設(p<0.05 = 平穩),KPSS 不拒絕「平穩」假設(p≥0.05 = 平穩)。兩者同時成立時結論最可靠。另設離群值穩健性分析:將序列 ±3σ 截尾後重新檢定,確認結論不受極端報酬衝擊影響。
ADF (Augmented Dickey-Fuller)
H₀: unit root exists (non-stationary) → reject if p < 0.05 → series is STATIONARY
KPSS (Kwiatkowski-Phillips-Schmidt-Shin)
H₀: series is stationary → fail-to-reject if p ≥ 0.05 → series is STATIONARY
Both agree → high confidence in stationarity conclusion.
Outlier robustness check (Winsorize ±3σ):
Outlier = |z-score| = |(x − μ) / σ| > 3 (extreme single-day return shock)
Treatment: clip series to [μ−3σ, μ+3σ], re-run ADF + KPSS
Robust ✓ → verdict unchanged after clipping (conclusion is not outlier-driven)
Sensitive ✗ → verdict changes → extreme days are inflating/deflating the test statistic
載入中…
解讀:
2
Engle-Granger 共整合分析
共整合(Cointegration)檢定兩個非平穩序列是否存在穩定的長期均衡關係。雖然各板塊日報酬率本身已平穩,仍可透過共整合判斷板塊間是否有長期聯動的結構性關係。
Engle-Granger Two-Step Test:
Step 1: regress Y_t = α + β·X_t + ε_t (OLS)
Step 2: ADF test on residuals ε̂_t
→ reject H₀ (p < 0.05) → X and Y are COINTEGRATED (share long-run equilibrium)
Heatmap: cell colour = p-value Dark = significant (p < 0.05) Light = not cointegrated
Outlier robustness: repeat test on ±3σ winsorized price indices (reconstructed from clipped returns)
Robust ✓ (green) — cointegrated in both raw and winsorized price paths
Sensitive ✗ (amber) — cointegrated in raw only; extreme co-movement days are driving the result
原始 p 值熱圖
穩健性分類(R = 穩健 !! = 離群值驅動)
解讀:
3
GARCH(1,1) 條件波動率
GARCH 模型捕捉金融時序的「波動群聚」現象:大波動後往往接著大波動。GARCH(1,1) 估計每天的條件波動率,並預測隔日波動。
GARCH(1,1) specification:
σ²_t = ω + α · ε²_{t-1} + β · σ²_{t-1}
where:
σ²_t = conditional variance on day t
ε_{t-1} = yesterday's return shock (innovation)
α = ARCH term — sensitivity to yesterday's shock
β = GARCH term — persistence of yesterday's variance
ω = long-run variance floor
Stationarity: α + β < 1 (variance reverts to mean over time)
Half-life = ln(0.5) / ln(α+β) days for shock to decay 50%
EGARCH(1,1,1) — adds asymmetric (leverage) effect:
ln σ²_t = ω + α · |z_{t-1}| + γ · z_{t-1} + β · ln σ²_{t-1}
where z_{t-1} = ε_{t-1}/σ_{t-1} (standardised shock)
γ < 0 → negative shocks amplify vol more than positive (leverage effect)
γ ≈ 0 → symmetric — no leverage
Ljung-Box (LB) test on squared std residuals (lag 10):
H₀: no serial correlation in ε²/σ² → GARCH is adequate (p ≥ 0.05)
p < 0.05 → remaining ARCH effects → consider EGARCH / GJR-GARCH
各板塊 GARCH 1 日波動預測(%)
載入中…
解讀:
4
VAR + Granger 因果分析
Granger 因果檢定透過 VAR 模型判斷「板塊 A 的過去報酬是否有助於預測板塊 B 的未來報酬」。若有,稱 A Granger-causes B(p<0.05)。
VAR(p) model for sector pair (X, Y):
Y_t = c + Σᵢ A_i · [X_{t-i}, Y_{t-i}]ᵀ + ε_t (i = 1 … p lags)
Granger causality F-test:
H₀: lagged X coefficients in Y equation are all zero (X does NOT Granger-cause Y)
Reject H₀ (p < 0.05) → X GRANGER-CAUSES Y (X's past predicts Y's future)
Heatmap: row = effect sector (Y), col = cause sector (X)
★ = p < 0.05 (X Granger-causes Y) darker cell = more significant
Outlier robustness: repeat test on ±3σ winsorized range_pct series
Robust ✓ (green) — significant in both raw and winsorized
Sensitive ✗ (amber) — significant in raw only; extreme spike days driving the result
原始 Granger 因果 p 值
穩健性分類(R = 穩健 !! = 離群值驅動)
解讀:
—
Walk-forward 折數
—
優化後 Sharpe
—
優化後累計報酬
T-1
Open→Close 主目標
1
特徵工程 — T-1 Open→Close 主模型
目前正式版以 T-1 為每日主模型;預測標的是下一個交易日 Open→Close 方向。Raw IC 保留原始模型品質,Router IC/命中率代表正式決策層。
Final production layout — T-1 Open→Close primary — 2026-05-14
Primary target : next-trading-day sector Open→Close direction
target = sign(Close_next / Open_next − 1)
Verification : compare predicted direction with realised next-day Open→Close,
not with Close→Close sector performance cards
Universe : 11 GICS sectors, sector-specific child models
Production model:
Base model : T-1 S+U hybrid LGBM+XGBoost sector ensemble
Promoted overlays:
Materials : 4-sector proxy top-100 child model
Communication Services : selector/proxy child model
Utilities : selector/proxy child model
Decision layer:
Sector-specific regime router keeps Raw prediction as baseline,
then applies validated sector rules where full-sample OOS improves.
Metrics:
Raw IC is preserved for diagnostic quality control.
Router IC is shown separately for the deployed decision layer.
T-5 auxiliary:
Use : medium-term context only; it is not the main Phase 6 date table
Current OOS accuracy:
Raw : 60D 54.39% / 120D 53.71% / 252D 52.63%
Regime router : 30D 73.94% / 60D 67.73% / 120D 65.08% / 252D 56.82%
Interpretation:
T-1 remains the daily production model because Open→Close results can be verified
on the next trading day. The sector-specific regime router is the current
decision layer: it keeps the global regime for stable sectors, but allows
lagging sectors to use a one-condition router without adding features.
Ensemble : hybrid LGBMClassifier + XGBClassifier per sector
Split : Walk-forward time-series validation, no random split, no look-ahead leakage
Scaling : zero-mean unit-variance per training fold
Loading target contract...
各 Batch 設計原理詳解
▶
LightGBM 模型超參數
| 超參數 | Walk-forward 模型 | 最終模型 | 說明 |
|---|---|---|---|
| n_estimators | 200 | 300 | 樹的數量 |
| learning_rate | 0.05 | 0.05 | 學習率 |
| max_depth | 4 | 4 | 最大樹深 |
| num_leaves | 15 | 15 | 最大葉節點 |
| subsample | 0.8 | 0.8 | 樣本抽樣比 |
| colsample_bytree | 0.8 | 0.8 | 特徵抽樣比 |
| reg_alpha / reg_lambda | 0.1 / 0.1 | 0.1 / 0.1 | L1 / L2 正則化 |
| min_child_samples | 10 | 10 | 最少葉樣本 |
特徵設計原理:
滯後特徵源自 Phase 3 Granger 分析;VIX/TNX 補充宏觀信號;技術指標捕捉動能;Batch K–R 遞進添加離群值體制、銅期貨、反偏差、財報週標記(Batch P)、SPY 200MA 多空體制(Batch R)。所有特徵在訓練折內標準化。
2
Walk-forward 預測 vs 實際報酬
Walk-forward 驗證嚴格禁止未來資訊洩漏:每折訓練集僅含歷史資料,預測下一期 30 天。折數與 OOS 測試日數由資料自動決定,詳見下方表格。
各折驗證統計
載入中…
解讀:
載入中…
3
特徵重要性 — 混合集成(LightGBM)+ SHAP
混合集成特徵重要性(以 LightGBM 代表);目前正式模組為 T-1 Open→Close sector-select + sector regime router。
SHAP (Shapley Additive Explanations):
φᵢ(f, x) = Σ_{S ⊆ F\{i}} [|S|!(|F|−|S|−1)! / |F|!] · [f(S∪{i}) − f(S)]
where:
F = full feature set
S = feature subset (without feature i)
φᵢ = Shapley value (average marginal contribution of feature i)
Property: Σᵢ φᵢ(f, x) = f(x) − E[f(x)] (sum of SHAP = prediction − baseline)
LightGBM 內建特徵重要性 (split count)
SHAP 特徵重要性 (mean |SHAP value|)
解讀:
載入中…
—
年化 Sharpe
—
累計報酬
—
最大回撤
—
正 Router IC 板塊
1
策略驗證儀表板
Phase 5 驗證 T-1 Open→Close 主模型;用隔日實際 Open→Close 報酬計算多空 P&L 與 IC。
Open→Close realised return:
actual_oc_return_t+1 = Close_t+1 / Open_t+1 − 1
Information Coefficient (IC):
IC_t = Pearson_r(predicted_open_close_return_t, actual_oc_return_t+1)
across 11 sectors each prediction date
Long-short strategy P&L:
PnL_t = (actual_oc_return_long − actual_oc_return_short) / 2 − 2 × 3bps
Performance metrics:
Sharpe = mean(PnL) / std(PnL) × √252 (annualised)
Calmar = cumulative_return / |max_drawdown|
IC IR = mean(IC) / std(IC) (signal consistency)
載入中…
解讀:
【本次 Phase 5 解讀】正式版採用 T-1 Open→Close 主模型;Raw IC 保留,Router IC 代表正式決策層。
目前配置:
T-1 Open→Close 主模型 + sector-specific regime router:30D 73.94%、60D 67.73%、120D 65.08%、252D 56.82%。
Sector Regime Router:
Regime router 仍是決策層;每日執行以 T-1 Regime Router 欄位為主。
2
各板塊 IC 表現
依板塊分組同時顯示近 120 日 Raw IC 與 Router IC;Raw IC 保留原始模型品質,Router IC 代表正式決策層。
載入中…
解讀:
3
壓力測試 — 波動率分位數分析
測試日按橫截面報酬波動率分四個分位,分析模型在各市場環境下的表現。
載入中…
解讀:
載入中…
1
T-1 Open→Close 板塊方向預測(主模型)
以 T-1 sector-select ensemble 輸出下一交易日 Open→Close 方向機率;命中以隔日 Close / Open − 1 為準。
Phase 6 推論一致性:
目前正式介面保存 T1;採用 sector-select promotion + sector-specific regime router。
載入中…
解讀:
2
系統監控狀態
自動執行四道監控:Raw/Router IC、極端信號、特徵漂移(PSI)與 VIX 倉位縮放。
載入中…
3
預測正確率(OOS 歷史回測)
基於 T-1 Open→Close 主模型的 Walk-Forward OOS 顯示 Raw 與 Sector Regime Router 完整樣本準確率;命中率以隔日 Close / Open − 1 為準。
測試期範圍:
載入中...
解讀:
載入中…
4
板塊專用模型與 Regime Router 配置
這裡列出目前正式部署的 T-1 Open→Close 模組、板塊子模型與 Regime router 規則。
上方績效卡讀取 Phase 6 frozen history 的正式 Active 準確度,Raw 作為對照;下方規則表讀取實際 CSV/manifest,不再寫死舊數字。
Loading production module...
5
Phase 6 決策摘要與自我進化
決策儀表板只顯示目前正式模式、候選模式與下一次評估;技術細節收在展開區。舊預測一旦寫入歷史就固定,候選只從啟用後的新 report 開始比較。
載入自我進化狀態...
6
預測 vs 實際比對(近期 OOS 回測)
T-1 主模型預測 vs 實際 T-1 方向對照;最上方顯示最新預測基準日,下方為已驗證歷史。
目前顯示:
最新預測列來自 Phase 6 T-1 daily report,尚未有實際報酬與命中率;已驗證列才計算策略淨損益。
注意:模型命中率採用下一交易日 Open→Close;產業表現卡片多為 Close→Close,兩者可能一正一負。
注意:模型命中率採用下一交易日 Open→Close;產業表現卡片多為 Close→Close,兩者可能一正一負。
顯示最近
交易日
載入中...
6
執行說明
建議排程:
每個美股收盤後執行(台灣時間早上 6–7 點);滾動 IC 持續為負時重新訓練 Phase 4–5。