「鈀金領先白銀」的假說需要可量化驗證:
- 以 cross-correlation 估計最佳領先滯後(lead-lag)
- 當銀出現拐點時,檢查鈀金是否在確認窗口內先行或同步出現同向拐點
- 未被確認的拐點視為「失敗推動」的候選
Lead-Lag = argmax(cross_correlation(pd_ret[t-k:t], ag_ret[t:t+k]))
Confirmed = pd_turn exists within [ag_turn.ts - window, ag_turn.ts + window]
| 方法 |
原理 |
適用場景 |
pivot |
左右 N 根K棒內的局部極值 |
結構明確的趨勢 |
peaks |
scipy find_peaks + prominence |
自動化密度控制 |
slope_change |
趨勢斜率由正轉負或反之 |
平滑趨勢追蹤 |
建議從 pivot 開始,左右各 3-5 根K棒,再依需求調整。
鈀金是否「參與」銀的走勢,有多種衡量方式:
| 指標 |
定義 |
門檻建議 |
returns_corr |
報酬率滾動相關係數 |
> 0.5 |
direction_agree |
同向漲跌的比例 |
> 60% |
vol_expansion |
兩者波動同步擴張 |
σ_pd / σ_ag > 0.8 |
breakout_confirm |
銀突破時鈀金也突破 |
同向突破 |
未達門檻時,銀的動作可能是「流動性噪音」而非趨勢確認。
將「無鈀金參與的銀動作」落地為可回測的規則:
| 規則 |
定義 |
後果 |
no_confirm_then_revert |
無確認 + 銀在 N 根K內回撤過起點 |
標記為 failed_move |
no_confirm_then_break_fail |
無確認 + 銀突破後回落跌破突破點 |
假突破 |
歷史統計:未確認事件的失敗率 vs 已確認事件的成功率。
- 數據取得:白銀與鈀金的 OHLCV(yfinance: SI=F, PA=F)
- 拐點偵測:識別兩者的局部高低點(pivot / peaks / slope_change)
- 領先滯後估計:cross-correlation 找最佳 lag
- 跨金屬確認:銀的拐點是否在窗口內被鈀金同向拐點確認
- 失敗走勢判定:未確認的銀拐點是否符合失敗規則
輸出:確認率、失敗率、每個事件的詳細判定、風控建議。
最快的方式:偵測白銀近期拐點是否被鈀金確認
cd skills/detect-palladium-lead-silver-turns
pip install pandas numpy yfinance scipy statsmodels # 首次使用
python scripts/palladium_lead_silver.py --silver SI=F --palladium PA=F --quick
輸出範例:
{
"symbol_pair": {"silver": "SI=F", "palladium": "PA=F"},
"as_of": "2026-01-14",
"timeframe": "1h",
"estimated_pd_leads_by_bars": 6,
"lead_lag_corr": 0.42,
"confirmation_rate": 0.71,
"unconfirmed_failure_rate": 0.64,
"latest_event": {
"ts": "2026-01-15T14:00:00Z",
"turn": "top",
"confirmed": false,
"participation_ok": false,
"failed_move": true
}
}
完整分析:
python scripts/palladium_lead_silver.py --silver SI=F --palladium PA=F --timeframe 1h --lookback 1000 --output result.json
生成 Bloomberg 風格視覺化圖表(推薦):
pip install matplotlib yfinance # 首次使用
python scripts/plot_bloomberg_style.py --input result.json --output output/palladium_silver_2026-01-26.png
圖表特色:
- Bloomberg 專業配色:深色背景、橙紅色白銀線、橙黃色鈀金線
- 背景色帶標記:綠色背景 = 已確認拐點區域,紅色背景 = 未確認拐點區域(不擋住走勢線)
- 最新事件標註:醒目標示最新拐點的確認狀態與價格
- Pd/Ag 價格比率圖:顯示鈀金對白銀的相對價格變化,含 20 期均線
- 滾動確認率:動態顯示確認邏輯的有效性趨勢
- 統計面板:確認率、失敗率、總拐點數等關鍵指標
- 行情解讀:當前狀態評估與可操作建議
傳統三合一圖表(技術分析向):
python scripts/plot_palladium_silver.py --silver SI=F --palladium PA=F --output output/
包含:
- 銀/鈀價格疊加與拐點標記
- 確認/未確認事件分布
- 滾動相關係數時間序列
- 失敗走勢統計
- 快速偵測 - 檢查最近白銀拐點是否被鈀金確認
- 歷史回測 - 回溯分析跨金屬確認的有效性
- 持續監控 - 設定警報當出現新拐點時通知
- 參數調校 - 找出最佳的確認窗口與參與度門檻
- 方法論學習 - 了解跨金屬領先滯後的理論基礎
請選擇或直接提供分析參數開始。
路由後,閱讀對應文件並執行。
方法論: references/methodology.md
- 跨金屬領先滯後原理
- 拐點偵測三法詳解
- 參與度與確認邏輯
- 失敗走勢的市場含義
資料來源: references/data-sources.md
- Yahoo Finance 期貨代碼
- 宏觀濾鏡數據來源
- 數據頻率與對齊
輸入參數: references/input-schema.md
| Script |
Command |
Purpose |
| palladium_lead_silver.py |
--silver SI=F --palladium PA=F --quick |
快速檢查當前狀態 |
| palladium_lead_silver.py |
--silver SI=F --palladium PA=F --lookback 1000 |
完整歷史分析 |
| plot_bloomberg_style.py |
--input result.json --output output/chart.png |
Bloomberg 風格圖表(推薦) |
| plot_palladium_silver.py |
--silver SI=F --palladium PA=F --output dir/ |
傳統三合一圖表 |
|
|
|
核心參數
| 參數 |
類型 |
預設值 |
說明 |
| silver_symbol |
string |
(required) |
白銀標的代碼 |
| palladium_symbol |
string |
(required) |
鈀金標的代碼 |
| timeframe |
string |
1h |
分析時間尺度 |
| lookback_bars |
int |
1000 |
回溯K棒數 |
拐點偵測參數
| 參數 |
類型 |
預設值 |
說明 |
| turn_method |
string |
pivot |
拐點偵測方法 |
| pivot_left |
int |
3 |
pivot 左側確認K數 |
| pivot_right |
int |
3 |
pivot 右側確認K數 |
| confirm_window_bars |
int |
6 |
跨金屬確認窗口 |
| lead_lag_max_bars |
int |
24 |
領先滯後最大滯後K數 |
參與度參數
| 參數 |
類型 |
預設值 |
說明 |
| participation_metric |
string |
direction_agree |
參與度衡量方式 |
| participation_threshold |
float |
0.6 |
參與度門檻 |
| failure_rule |
string |
no_confirm_then_revert |
失敗走勢規則 |
完整參數定義見 references/input-schema.md。
完整輸出結構見 templates/output-json.md。
1---2name: detect-palladium-lead-silver-turns3description: 以鈀金的先行轉向作為確認條件,檢驗白銀短期漲跌是否獲得工業景氣與風險情緒的同步支持,並標記缺乏鈀金參與度的失敗走勢。4---5
6<essential_principles>
7
8<principle name="cross_metal_confirmation">
9**跨金屬確認核心**
10
11「鈀金領先白銀」的假說需要可量化驗證:
12- 以 cross-correlation 估計最佳領先滯後(lead-lag)
13- 當銀出現拐點時,檢查鈀金是否在確認窗口內先行或同步出現同向拐點
14- 未被確認的拐點視為「失敗推動」的候選
15
16```
17Lead-Lag = argmax(cross_correlation(pd_ret[t-k:t], ag_ret[t:t+k]))
18Confirmed = pd_turn exists within [ag_turn.ts - window, ag_turn.ts + window]
19```
20</principle>
21
22<principle name="turning_point_detection">
23**拐點偵測三法**
24
25| 方法 | 原理 | 適用場景 |
26|----------------|-------------------------------|----------------|
27| `pivot` | 左右 N 根K棒內的局部極值 | 結構明確的趨勢 |
28| `peaks` | scipy find_peaks + prominence | 自動化密度控制 |
29| `slope_change` | 趨勢斜率由正轉負或反之 | 平滑趨勢追蹤 |
30
31建議從 `pivot` 開始,左右各 3-5 根K棒,再依需求調整。
32</principle>
33
34<principle name="participation_judgment">
35**參與度判定**
36
37鈀金是否「參與」銀的走勢,有多種衡量方式:
38
39| 指標 | 定義 | 門檻建議 |
40|--------------------|--------------------|-------------------|
41| `returns_corr` | 報酬率滾動相關係數 | > 0.5 |
42| `direction_agree` | 同向漲跌的比例 | > 60% |
43| `vol_expansion` | 兩者波動同步擴張 | σ_pd / σ_ag > 0.8 |
44| `breakout_confirm` | 銀突破時鈀金也突破 | 同向突破 |
45
46未達門檻時,銀的動作可能是「流動性噪音」而非趨勢確認。
47</principle>
48
49<principle name="failure_move_detection">
50**失敗走勢判定**
51
52將「無鈀金參與的銀動作」落地為可回測的規則:
53
54| 規則 | 定義 | 後果 |
55|------------------------------|---------------------------------|--------------------|
56| `no_confirm_then_revert` | 無確認 + 銀在 N 根K內回撤過起點 | 標記為 failed_move |
57| `no_confirm_then_break_fail` | 無確認 + 銀突破後回落跌破突破點 | 假突破 |
58
59歷史統計:未確認事件的失敗率 vs 已確認事件的成功率。
60</principle>
61
62</essential_principles>
63
64<objective>
65偵測「鈀金領先、白銀跟隨」的跨金屬拐點:
66
671. **數據取得**:白銀與鈀金的 OHLCV(yfinance: SI=F, PA=F)
682. **拐點偵測**:識別兩者的局部高低點(pivot / peaks / slope_change)
693. **領先滯後估計**:cross-correlation 找最佳 lag
704. **跨金屬確認**:銀的拐點是否在窗口內被鈀金同向拐點確認
715. **失敗走勢判定**:未確認的銀拐點是否符合失敗規則
72
73輸出:確認率、失敗率、每個事件的詳細判定、風控建議。
74</objective>
75
76<quick_start>
77
78**最快的方式:偵測白銀近期拐點是否被鈀金確認**
79
80```bash
81cd skills/detect-palladium-lead-silver-turns
82pip install pandas numpy yfinance scipy statsmodels # 首次使用
83python scripts/palladium_lead_silver.py --silver SI=F --palladium PA=F --quick
84```
85
86輸出範例:
87```json
88{
89 "symbol_pair": {"silver": "SI=F", "palladium": "PA=F"},
90 "as_of": "2026-01-14",
91 "timeframe": "1h",
92 "estimated_pd_leads_by_bars": 6,
93 "lead_lag_corr": 0.42,
94 "confirmation_rate": 0.71,
95 "unconfirmed_failure_rate": 0.64,
96 "latest_event": {
97 "ts": "2026-01-15T14:00:00Z",
98 "turn": "top",
99 "confirmed": false,
100 "participation_ok": false,
101 "failed_move": true
102 }
103}
104```
105
106**完整分析**:
107```bash
108python scripts/palladium_lead_silver.py --silver SI=F --palladium PA=F --timeframe 1h --lookback 1000 --output result.json
109```
110
111**生成 Bloomberg 風格視覺化圖表**(推薦):
112```bash
113pip install matplotlib yfinance # 首次使用
114python scripts/plot_bloomberg_style.py --input result.json --output output/palladium_silver_2026-01-26.png
115```
116
117圖表特色:
118- **Bloomberg 專業配色**:深色背景、橙紅色白銀線、橙黃色鈀金線
119- **背景色帶標記**:綠色背景 = 已確認拐點區域,紅色背景 = 未確認拐點區域(不擋住走勢線)
120- **最新事件標註**:醒目標示最新拐點的確認狀態與價格
121- **Pd/Ag 價格比率圖**:顯示鈀金對白銀的相對價格變化,含 20 期均線
122- **滾動確認率**:動態顯示確認邏輯的有效性趨勢
123- **統計面板**:確認率、失敗率、總拐點數等關鍵指標
124- **行情解讀**:當前狀態評估與可操作建議
125
126**傳統三合一圖表**(技術分析向):
127```bash
128python scripts/plot_palladium_silver.py --silver SI=F --palladium PA=F --output output/
129```
130
131包含:
132- 銀/鈀價格疊加與拐點標記
133- 確認/未確認事件分布
134- 滾動相關係數時間序列
135- 失敗走勢統計
136
137</quick_start>
138
139<intake>
140需要進行什麼操作?
141
1421. **快速偵測** - 檢查最近白銀拐點是否被鈀金確認
1432. **歷史回測** - 回溯分析跨金屬確認的有效性
1443. **持續監控** - 設定警報當出現新拐點時通知
1454. **參數調校** - 找出最佳的確認窗口與參與度門檻
1465. **方法論學習** - 了解跨金屬領先滯後的理論基礎
147
148**請選擇或直接提供分析參數開始。**
149</intake>
150
151<routing>
152| Response | Action |
153|------------------------------------|--------------------------------------------------------|
154| 1, "快速", "quick", "check" | 執行 `python scripts/palladium_lead_silver.py --quick` |
155| 2, "回測", "backtest", "history" | 閱讀 `workflows/backtest.md` 並執行 |
156| 3, "監控", "monitor", "alert" | 閱讀 `workflows/monitor.md` 並執行 |
157| 4, "調校", "optimize", "tune" | 閱讀 `workflows/detect.md` 的參數調校部分 |
158| 5, "學習", "方法論", "why" | 閱讀 `references/methodology.md` |
159| 提供參數(如 timeframe, lookback) | 閱讀 `workflows/detect.md` 並使用參數執行 |
160
161**路由後,閱讀對應文件並執行。**
162</routing>
163
164<directory_structure>
165```
166detect-palladium-lead-silver-turns/
167├── SKILL.md # 本文件(路由器)
168├── skill.yaml # 前端展示元數據
169├── manifest.json # 技能元數據
170├── workflows/
171│ ├── detect.md # 單次偵測工作流
172│ ├── backtest.md # 歷史回測工作流
173│ └── monitor.md # 持續監控工作流
174├── references/
175│ ├── methodology.md # 跨金屬領先滯後方法論
176│ ├── input-schema.md # 完整輸入參數定義
177│ └── data-sources.md # 資料來源說明
178├── templates/
179│ ├── output-json.md # JSON 輸出模板
180│ └── output-markdown.md # Markdown 報告模板
181├── scripts/
182│ ├── palladium_lead_silver.py # 主偵測腳本
183│ ├── plot_bloomberg_style.py # Bloomberg 風格視覺化(推薦)
184│ └── plot_palladium_silver.py # 傳統三合一圖表
185└── examples/
186 └── silver-palladium-2024.json # 範例輸出
187```
188</directory_structure>
189
190<reference_index>
191
192**方法論**: references/methodology.md
193- 跨金屬領先滯後原理
194- 拐點偵測三法詳解
195- 參與度與確認邏輯
196- 失敗走勢的市場含義
197
198**資料來源**: references/data-sources.md
199- Yahoo Finance 期貨代碼
200- 宏觀濾鏡數據來源
201- 數據頻率與對齊
202
203**輸入參數**: references/input-schema.md
204- 完整參數定義
205- 預設值與建議範圍
206
207</reference_index>
208
209<workflows_index>
210| Workflow | Purpose | 使用時機 |
211|-------------|----------|--------------------|
212| detect.md | 單次偵測 | 檢查特定時間範圍 |
213| backtest.md | 歷史回測 | 驗證確認邏輯有效性 |
214| monitor.md | 持續監控 | 日常追蹤或警報 |
215</workflows_index>
216
217<templates_index>
218| Template | Purpose |
219|--------------------|-------------------|
220| output-json.md | JSON 輸出結構定義 |
221| output-markdown.md | Markdown 報告模板 |
222</templates_index>
223
224<scripts_index>
225| Script | Command | Purpose |
226|--------------------------|--------------------------------------------------|------------------|
227| palladium_lead_silver.py | `--silver SI=F --palladium PA=F --quick` | 快速檢查當前狀態 |
228| palladium_lead_silver.py | `--silver SI=F --palladium PA=F --lookback 1000` | 完整歷史分析 |
229| plot_bloomberg_style.py | `--input result.json --output output/chart.png` | Bloomberg 風格圖表(推薦) |
230| plot_palladium_silver.py | `--silver SI=F --palladium PA=F --output dir/` | 傳統三合一圖表 |
231</scripts_index>
232
233<input_schema_summary>
234
235**核心參數**
236
237| 參數 | 類型 | 預設值 | 說明 |
238|------------------|--------|------------|--------------|
239| silver_symbol | string | (required) | 白銀標的代碼 |
240| palladium_symbol | string | (required) | 鈀金標的代碼 |
241| timeframe | string | 1h | 分析時間尺度 |
242| lookback_bars | int | 1000 | 回溯K棒數 |
243
244**拐點偵測參數**
245
246| 參數 | 類型 | 預設值 | 說明 |
247|---------------------|--------|--------|---------------------|
248| turn_method | string | pivot | 拐點偵測方法 |
249| pivot_left | int | 3 | pivot 左側確認K數 |
250| pivot_right | int | 3 | pivot 右側確認K數 |
251| confirm_window_bars | int | 6 | 跨金屬確認窗口 |
252| lead_lag_max_bars | int | 24 | 領先滯後最大滯後K數 |
253
254**參與度參數**
255
256| 參數 | 類型 | 預設值 | 說明 |
257|-------------------------|--------|------------------------|----------------|
258| participation_metric | string | direction_agree | 參與度衡量方式 |
259| participation_threshold | float | 0.6 | 參與度門檻 |
260| failure_rule | string | no_confirm_then_revert | 失敗走勢規則 |
261
262完整參數定義見 `references/input-schema.md`。
263
264</input_schema_summary>
265
266<output_schema_summary>
267```json
268{
269 "skill": "detect-palladium-lead-silver-turns",
270 "symbol_pair": {"silver": "SI=F", "palladium": "PA=F"},
271 "as_of": "2026-01-14",
272 "timeframe": "1h",
273 "lookback_bars": 1200,
274 "summary": {
275 "estimated_pd_leads_by_bars": 6,
276 "lead_lag_corr": 0.42,
277 "confirmation_rate": 0.71,
278 "unconfirmed_failure_rate": 0.64,
279 "total_ag_turns": 24,
280 "confirmed_turns": 17,
281 "failed_moves": 5
282 },
283 "events": [
284 {
285 "ts": "2026-01-08T10:00:00Z",
286 "turn": "bottom",
287 "confirmed": true,
288 "confirmation_lag_bars": -3,
289 "participation_ok": true,
290 "failed_move": false
291 }
292 ],
293 "interpretation": {
294 "regime_assessment": "...",
295 "tactics": ["...", "..."]
296 }
297}
298```
299
300完整輸出結構見 `templates/output-json.md`。
301</output_schema_summary>
302
303<success_criteria>
304執行成功時應產出:
305
306- [ ] 鈀金對白銀的最佳領先滯後估計(bars)
307- [ ] 領先滯後的相關係數
308- [ ] 白銀拐點被鈀金確認的確認率
309- [ ] 未確認事件的失敗走勢比例
310- [ ] 每個白銀拐點的詳細判定(confirmed, participation, failed)
311- [ ] 行情解讀與戰術建議
312- [ ] 時間序列資料(可選,用於視覺化)
313- [ ] 視覺化圖表 PNG(可選,使用 plot_palladium_silver.py)
314</success_criteria>