<essential_principles>
<principle name="transmission_verification">
**傳導驗證而非預測**
本技能專注於「用數據驗證敘事」:
- 輸入:社群/新聞宣稱「白金走勢可能領先或驅動巴西股市」
- 輸出:長週期時間序列上的傳導假說檢驗結果
不做價格預測,只回答:「白金→巴西股市的傳導結構在數據上是否存在?」
</principle>
<principle name="lead_lag_cross_correlation">
**交叉相關判斷領先落後**
使用 Cross-Correlation 掃描 [-lead_lag_max, +lead_lag_max] 範圍:
corr(r_ewz, r_platinum.shift(lag))
- lag > 0:白金領先 EWZ(platinum leads)
- lag < 0:EWZ 領先白金
- lag ≈ 0:同步移動
典型設定:週頻 lag max = 52(一年),找 |corr| 最大的 lag。
</principle>
<principle name="regime_awareness">
**Regime-Dependent 關聯**
白金與巴西股市的關聯具有週期性特徵:
- linked_upcycle:兩者趨勢同向上行,傳導結構穩固
- decoupled:關聯斷裂,各走各的
- brazil_idiosyncratic:巴西特有風險(政治/匯率/商品結構)主導
長期 regime 判斷使用 regime_window(預設 104 週 ≈ 2 年)內的趨勢一致性。
</principle>
<principle name="transmission_strength_score">
**傳導強度分數(0–100)**
綜合三個維度量化傳導可信度:
| 維度 | 權重 | 說明 |
|---|
| best_lead_lag_corr | 30% | 最佳領先落後相關係數 |
| rolling_corr_stability | 30% | rolling corr > 0 的佔比與連續性 |
| trend_agreement | 40% | 長期趨勢一致程度 |
分數解讀:≥70 強傳導、50-69 中等、<50 弱/不穩定。
</principle>
<principle name="data_source">
**資料來源**
主要使用 Yahoo Finance(免費、無需 API key):
頻率建議:1wk(週頻)用於長週期分析,避免日頻噪音干擾。
對齊方式:inner join(只保留共同交易日),避免補值造成假相關。
</principle>
</essential_principles>
<objective>
量化驗證「白金(Platinum)→ 巴西股市(EWZ)」的長週期傳導關係:
- 數據取得:從 Yahoo Finance 取得白金期貨與 EWZ 歷史價格
- 雙軸圖與正規化圖:Bloomberg 風格原值雙軸圖 + 正規化同軸對比
- 領先落後分析:交叉相關找出白金是否領先 EWZ 及滯後期數
- Rolling Correlation:滾動相關觀察關聯的時變結構
- Regime 判斷:長期趨勢一致性判斷當前處於哪種傳導體制
- 傳導強度分數:綜合評分(0-100)量化傳導可信度
輸出:傳導強度分數、領先落後判定、regime label、監控清單、Bloomberg 風格圖表。
</objective>
<quick_start>
Step 1:安裝依賴
bash
pip install yfinance pandas numpy matplotlib scipy
Step 2:執行完整分析
bash
cd scripts
python analyze.py --start 2003-01-01
Step 3:生成 Bloomberg 風格視覺化圖表
bash
python visualize.py --start 2003-01-01
<essential_principles>
<principle name="transmission_verification">
**Transmission Verification Instead of Prediction**
This skill focuses on "verifying narratives with data":
- Input: Community/news claims that "Platinum trends may lead or drive the Brazilian stock market"
- Output: Results of transmission hypothesis testing on long-term time series
No price prediction, only answers: "Does the transmission structure from Platinum to the Brazilian stock market exist in the data?"
</principle>
<principle name="lead_lag_cross_correlation">
**Lead-Lag Judgment via Cross-Correlation**
Use Cross-Correlation to scan the range [-lead_lag_max, +lead_lag_max]:
corr(r_ewz, r_platinum.shift(lag))
- lag > 0: Platinum leads EWZ
- lag < 0: EWZ leads Platinum
- lag ≈ 0: Synchronous movement
Typical setting: Weekly frequency with lag max = 52 (one year), find the lag with the maximum |corr|.
</principle>
<principle name="regime_awareness">
**Regime-Dependent Correlation**
The correlation between Platinum and the Brazilian stock market has cyclical characteristics:
- linked_upcycle: Both trends move upward in the same direction, with a stable transmission structure
- decoupled: Correlation breaks, each moves independently
- brazil_idiosyncratic: Brazil-specific risks (politics/exchange rate/commodity structure) dominate
Long-term regime judgment uses trend consistency within the regime_window (default 104 weeks ≈ 2 years).
</principle>
<principle name="transmission_strength_score">
**Transmission Strength Score (0–100)**
Quantify transmission credibility by integrating three dimensions:
| Dimension | Weight | Description |
|---|
| best_lead_lag_corr | 30% | Best lead-lag correlation coefficient |
| rolling_corr_stability | 30% | Proportion and continuity of rolling corr > 0 |
| trend_agreement | 40% | Degree of long-term trend consistency |
Score interpretation: ≥70 Strong transmission, 50-69 Moderate, <50 Weak/unstable.
</principle>
<principle name="data_source">
**Data Sources**
Mainly use Yahoo Finance (free, no API key required):
- Platinum Futures:
- Brazilian Stock Market ETF:
Frequency recommendation: 1wk (weekly) for long-term analysis, avoid daily frequency noise interference.
Alignment method: inner join (only retain common trading days) to avoid false correlation caused by filling values.
</principle>
</essential_principles>
<objective>
Quantitatively verify the long-term transmission relationship between "Platinum → Brazilian Stock Market (EWZ)":
- Data Acquisition: Obtain historical prices of Platinum futures and EWZ from Yahoo Finance
- Dual-Axis Chart and Normalized Chart: Bloomberg-style original value dual-axis chart + normalized single-axis comparison
- Lead-Lag Analysis: Use cross-correlation to determine whether Platinum leads EWZ and the lag period
- Rolling Correlation: Observe the time-varying structure of the correlation via rolling correlation
- Regime Judgment: Determine the current transmission regime based on long-term trend consistency
- Transmission Strength Score: Comprehensive score (0-100) to quantify transmission credibility
Output: Transmission strength score, lead-lag determination, regime label, monitoring list, Bloomberg-style charts.
</objective>
<quick_start>
Step 1: Install Dependencies
bash
pip install yfinance pandas numpy matplotlib scipy
Step 2: Execute Complete Analysis
bash
cd scripts
python analyze.py --start 2003-01-01
Step 3: Generate Bloomberg-Style Visualization Charts
bash
python visualize.py --start 2003-01-01