**輸出範例**:
```json
{
"signal": "narrative_supported",
"confidence": "medium",
"gas_shock_regimes": [
{"start": "2026-01-20", "peak": "2026-01-22", "regime_return_pct": 29.1}
],
"fert_spike_regimes": [
{"start": "2025-10-27", "peak": "2025-10-27", "regime_return_pct": 0.0}
],
"lead_lag_test": {
"best_lag_days_gas_leads_fert": 21,
"best_corr": 0.131
},
"interpretation": "天然氣領先化肥約 21 天,敘事有量化支撐"
}
注意:首次執行時,Chrome 會自動啟動並在背景抓取數據(約 60 秒),完成後自動關閉。
</quick_start>
<intake>
需要進行什麼分析?
- 快速檢查 - 查看最近是否有天然氣 shock 及化肥跟隨
- 完整分析 - 執行三段式因果檢驗並生成報告
- 合約對沖假說 - 輸入合約價格,計算價差壓力指標
- 方法論學習 - 了解 shock 偵測與領先落後分析原理
請選擇或直接提供分析參數。
</intake>
<routing>
| Response | Action |
|--------------------------------|--------------------------------------------|
| 1, "快速", "quick", "check" | 閱讀 `workflows/quick-check.md` 並執行 |
| 2, "完整", "full", "analyze" | 閱讀 `workflows/analyze.md` 並執行 |
| 3, "合約", "對沖", "hedge" | 閱讀 `workflows/hedge-hypothesis.md` 並執行|
| 4, "學習", "方法論", "why" | 閱讀 `references/methodology.md` |
| 提供參數 (如日期/商品) | 閱讀 `workflows/analyze.md` 並使用參數執行 |
路由後,閱讀對應文件並執行。
</routing>
<directory_structure>
analyze-gas-fertilizer-contract-shock/
├── SKILL.md # 本文件(路由器)
├── skill.yaml # 前端展示元數據
├── manifest.json # 技能元資料
├── workflows/
│ ├── analyze.md # 完整三段式分析工作流
│ ├── quick-check.md # 快速檢查工作流
│ └── hedge-hypothesis.md # 合約對沖假說分析
├── references/
│ ├── data-sources.md # Chrome CDP 爬蟲說明
│ ├── methodology.md # Shock 偵測與領先落後方法論
│ ├── input-schema.md # 輸入參數定義
│ └── historical-episodes.md # 歷史案例對照
├── templates/
│ ├── output-json.md # JSON 輸出模板
│ └── output-markdown.md # Markdown 報告模板
├── scripts/
│ ├── fetch_te_data.py # TradingEconomics CDP 爬蟲
│ ├── gas_fertilizer_analyzer.py # 主分析腳本
│ └── visualize_shock_regimes.py # Shock regime 視覺化
├── data/ # 數據快取目錄
│ └── cache/ # 快取檔案
└── examples/
└── sample_output.json # 範例輸出
</directory_structure>
<reference_index>
方法論: references/methodology.md
- Shock/Spike 偵測邏輯(z-score + 斜率)
- 領先落後相關分析
- Regime 合併演算法
資料來源: references/data-sources.md
- TradingEconomics Chrome CDP 爬蟲說明
- 天然氣與化肥商品代碼
- 備援數據源(FRED/World Bank)
輸入參數: references/input-schema.md
- 完整參數定義與預設值
- te_symbols、spike_detection、lead_lag 等
歷史案例: references/historical-episodes.md
- 2021-2022 歐洲天然氣危機
- 2022 俄烏衝突期間
- 季節性波動案例
</reference_index>
<workflows_index>
| Workflow | Purpose | 使用時機 |
|---|
| analyze.md | 完整三段式因果分析 | 需要驗證敘事時 |
| quick-check.md | 快速檢查最近 shock | 日常監控或快速回答 |
| hedge-hypothesis.md | 合約對沖假說分析 | 給定合約價格計算價差壓力 |
| </workflows_index> | | |
<templates_index>
| Template | Purpose |
|---|
| output-json.md | JSON 輸出結構定義 |
| output-markdown.md | Markdown 報告模板 |
| </templates_index> | |
<scripts_index>
| Script | Command | Purpose |
|---|
| fetch_te_data.py | --symbol natural-gas --symbol urea
| 全自動 CDP 爬取(自動啟動/關閉 Chrome) |
| gas_fertilizer_analyzer.py | --gas-file X.csv --fert-file Y.csv
| 完整三段式因果分析 |
| visualize_shock_regimes.py | (無參數,自動讀取快取) | Bloomberg 風格視覺化圖表 |
| </scripts_index> | | |
<input_schema>
<parameter name="start_date" required="true">
**Type**: string (ISO YYYY-MM-DD)
**Description**: 分析起始日期
**Example**: "2025-08-01"
</parameter>
<parameter name="end_date" required="true">
**Type**: string (ISO YYYY-MM-DD)
**Description**: 分析結束日期
**Example**: "2026-02-01"
</parameter>
<parameter name="te_symbols" required="true">
**Type**: object
**Description**: TradingEconomics 商品代碼
```json
{
"natural_gas": "natural-gas", // 或 "Natural Gas"
"fertilizer": "urea" // 或 "dap", "fertilizer"
}
```
</parameter>
<parameter name="spike_detection" required="false">
**Type**: object
**Defaults**:
```json
{
"return_window": 1,
"z_window": 60,
"parabolic_threshold": {"z": 3.0, "slope_pct_per_day": 1.5}
}
```
</parameter>
<parameter name="lead_lag" required="false">
**Type**: object
**Defaults**:
```json
{
"max_lag_days": 60,
"method": "corr_returns"
}
```
</parameter>
</input_schema>
<output_schema>
參見
的完整結構定義。
摘要:
json
{
"signal": "narrative_supported | narrative_weak | inconclusive",
"confidence": "high | medium | low",
"gas_shock_regimes": [...],
"fert_spike_regimes": [...],
"lead_lag_test": {
"best_lag_days": 12,
"best_corr": 0.41,
"interpretation": "gas 領先 fert"
},
"narrative_assessment": "三段式檢驗結果摘要",
"artifacts": {
"charts": ["output/gas_fert_shock.png"]
}
}
</output_schema>
<success_criteria>
分析成功時應產出:
**Sample Output**:
```json
{
"signal": "narrative_supported",
"confidence": "medium",
"gas_shock_regimes": [
{"start": "2026-01-20", "peak": "2026-01-22", "regime_return_pct": 29.1}
],
"fert_spike_regimes": [
{"start": "2025-10-27", "peak": "2025-10-27", "regime_return_pct": 0.0}
],
"lead_lag_test": {
"best_lag_days_gas_leads_fert": 21,
"best_corr": 0.131
},
"interpretation": "Natural gas leads fertilizer by about 21 days, the narrative has quantitative support"
}
Note: When executing for the first time, Chrome will automatically start and crawl data in the background (about 60 seconds), and close automatically after completion.
</quick_start>
<intake>
What analysis do you need?
- Quick Check - Check if there has been a recent natural gas shock and fertilizer follow-up
- Full Analysis - Execute the three-stage causal test and generate a report
- Contract Hedge Hypothesis - Input contract prices and calculate spread pressure indicators
- Methodology Learning - Understand the principles of shock detection and lead-lag analysis
Please select or directly provide analysis parameters.
</intake>
<routing>
| Response | Action |
|--------------------------------|--------------------------------------------|
| 1, "quick", "check" | Read `workflows/quick-check.md` and execute |
| 2, "full", "analyze" | Read `workflows/analyze.md` and execute |
| 3, "contract", "hedge" | Read `workflows/hedge-hypothesis.md` and execute|
| 4, "learn", "methodology", "why" | Read `references/methodology.md` |
| Provide parameters (e.g., dates/commodities) | Read `workflows/analyze.md` and execute with parameters |
After routing, read the corresponding file and execute.
</routing>
<directory_structure>
analyze-gas-fertilizer-contract-shock/
├── SKILL.md # This file (router)
├── skill.yaml # Frontend display metadata
├── manifest.json # Skill metadata
├── workflows/
│ ├── analyze.md # Full three-stage analysis workflow
│ ├── quick-check.md # Quick check workflow
│ └── hedge-hypothesis.md # Contract hedge hypothesis analysis
├── references/
│ ├── data-sources.md # Chrome CDP crawler description
│ ├── methodology.md # Shock detection and lead-lag methodology
│ ├── input-schema.md # Input parameter definitions
│ └── historical-episodes.md # Historical case comparisons
├── templates/
│ ├── output-json.md # JSON output template
│ └── output-markdown.md # Markdown report template
├── scripts/
│ ├── fetch_te_data.py # TradingEconomics CDP crawler
│ ├── gas_fertilizer_analyzer.py # Main analysis script
│ └── visualize_shock_regimes.py # Shock regime visualization
├── data/ # Data cache directory
│ └── cache/ # Cache files
└── examples/
└── sample_output.json # Sample output
</directory_structure>
<reference_index>
Methodology: references/methodology.md
- Shock/Spike detection logic (z-score + slope)
- Lead-lag correlation analysis
- Regime merging algorithm
Data Sources: references/data-sources.md
- TradingEconomics Chrome CDP crawler description
- Natural gas and fertilizer commodity codes
- Backup data sources (FRED/World Bank)
Input Parameters: references/input-schema.md
- Complete parameter definitions and default values
- te_symbols, spike_detection, lead_lag, etc.
Historical Cases: references/historical-episodes.md
- 2021-2022 European natural gas crisis
- 2022 Russia-Ukraine conflict period
- Seasonal fluctuation cases
</reference_index>
<workflows_index>
| Workflow | Purpose | Application Scenario |
|---|
| analyze.md | Full three-stage causal analysis | When narrative verification is needed |
| quick-check.md | Quick check of recent shocks | Daily monitoring or quick response |
| hedge-hypothesis.md | Contract hedge hypothesis analysis | Calculate spread pressure indicators given contract prices |
| </workflows_index> | | |
<templates_index>
| Template | Purpose |
|---|
| output-json.md | JSON output structure definition |
| output-markdown.md | Markdown report template |
| </templates_index> | |
<scripts_index>
| Script | Command | Purpose |
|---|
| fetch_te_data.py | --symbol natural-gas --symbol urea
| Fully automated CDP crawling (auto start/close Chrome) |
| gas_fertilizer_analyzer.py | --gas-file X.csv --fert-file Y.csv
| Full three-stage causal analysis |
| visualize_shock_regimes.py | (No parameters, automatically reads cache) | Bloomberg-style visualization charts |
| </scripts_index> | | |
<input_schema>
<parameter name="start_date" required="true">
**Type**: string (ISO YYYY-MM-DD)
**Description**: Analysis start date
**Example**: "2025-08-01"
</parameter>
<parameter name="end_date" required="true">
**Type**: string (ISO YYYY-MM-DD)
**Description**: Analysis end date
**Example**: "2026-02-01"
</parameter>
<parameter name="te_symbols" required="true">
**Type**: object
**Description**: TradingEconomics commodity codes
```json
{
"natural_gas": "natural-gas", // Or "Natural Gas"
"fertilizer": "urea" // Or "dap", "fertilizer"
}
```
</parameter>
<parameter name="spike_detection" required="false">
**Type**: object
**Defaults**:
```json
{
"return_window": 1,
"z_window": 60,
"parabolic_threshold": {"z": 3.0, "slope_pct_per_day": 1.5}
}
```
</parameter>
<parameter name="lead_lag" required="false">
**Type**: object
**Defaults**:
```json
{
"max_lag_days": 60,
"method": "corr_returns"
}
```
</parameter>
</input_schema>
<output_schema>
See the complete structure definition in
.
Summary:
json
{
"signal": "narrative_supported | narrative_weak | inconclusive",
"confidence": "high | medium | low",
"gas_shock_regimes": [...],
"fert_spike_regimes": [...],
"lead_lag_test": {
"best_lag_days": 12,
"best_corr": 0.41,
"interpretation": "gas leads fert"
},
"narrative_assessment": "Summary of three-stage test results",
"artifacts": {
"charts": ["output/gas_fert_shock.png"]
}
}
</output_schema>
<success_criteria>
When the analysis is successful, it should produce: