xiaohongshu
xiaohongshu
forecast-sector-relative-return-from-yield-spread
用美債殖利率曲線利差(如 2Y-10Y)建立「領先關係」,推估未來一段時間內成長股(Nasdaq 100)相對防禦股(Healthcare/XLV)的相對績效方向與幅度。
Full skill instructions
<essential_principles>
<principle name="lead_lag_definition"> **領先落後關係定義**殖利率利差(Yield Spread)作為領先指標:
spread_t = short_yield_t - long_yield_t
= US02Y_t - US10Y_t
spread 越高:短端相對更高(曲線更倒掛/更緊) spread 越低(或從負回到 0、轉正):曲線「回正/變陡」
此 spread 被認為領先反映:
相對強弱比率(Ratio):
ratio_t = risk_asset_t / defensive_asset_t
= QQQ_t / XLV_t
ratio 上升:成長股(Nasdaq)相對更強 ratio 下降:防禦股(Healthcare)相對更強(XLV 跑贏)
預測目標為「未來 H 個月的對數相對報酬」:
future_rel_return = log(ratio(t+H) / ratio(t))
正值 → Nasdaq 跑贏,負值 → XLV 跑贏 </principle>
<principle name="advance_alignment"> **「2 Years in Advance」的真正含義**圖表的時間對齊邏輯:
工程化寫法:
X = spread(t)
Y = future_rel_return(t, H) = log(ratio(t+H) / ratio(t))
然後做相關性/迴歸/交叉相關掃描來找「最佳領先期」。
避免直接用 ratio 水平做迴歸(有趨勢/非平穩問題),改用對數報酬。 </principle>
<principle name="validation_framework"> **領先關係驗證框架**需回答三件事:
是否真的存在穩定領先關係?
目前情境對應的預測方向
把預測翻譯成直覺語句
exp(future_rel_return) - 1殖利率來源:FRED(DGS2, DGS10) 資產價格來源:Yahoo Finance(QQQ, XLV) </principle>
</essential_principles>
<objective> 實作「殖利率利差 → 板塊相對報酬」領先關係分析:輸出:領先關係驗證、當前預測、區間估計、歷史類比、風險提示。 </objective>
<quick_start>
最快的方式:執行預設情境分析
cd skills/forecast-sector-relative-return-from-yield-spread
pip install pandas numpy yfinance matplotlib statsmodels requests # 首次使用
python scripts/spread_forecaster.py --quick
完整分析(含領先掃描與穩定性驗證)
python scripts/spread_forecaster.py \
--risk-ticker QQQ \
--defensive-ticker XLV \
--lead-months 24 \
--lookback-years 12 \
--output result.json
生成視覺化圖表
python scripts/spread_plotter.py --quick --output-dir ../../output
輸出範例:
{
"skill": "forecast_sector_relative_return_from_yield_spread",
"signal_name": "US02Y_minus_US10Y_leads_QQQ_over_XLV",
"lead_months": 24,
"current_spread": -0.35,
"model": {
"type": "lagged_regression",
"alpha": 0.02,
"beta": -0.45,
"corr_x_y": -0.32
},
"forecast": {
"future_24m_relative_return_pct": -0.077,
"interval_pct_80": [-0.22, 0.04],
"interpretation": "若此關係維持,未來24個月QQQ相對XLV期望報酬為-7.7%,XLV較可能跑贏。"
}
}
</quick_start>
<intake> 需要進行什麼操作?請選擇或直接提供分析參數。 </intake>
<routing> | Response | Action | |--------------------------------|---------------------------------------------------------------------| | 1, "快速", "quick", "分析" | 執行 `python scripts/spread_forecaster.py --quick` | | 2, "完整", "full", "自訂" | 閱讀 `workflows/analyze.md` 並執行 | | 3, "掃描", "scan", "領先" | 閱讀 `workflows/analyze.md` 並聚焦 lead_scan | | 4, "圖表", "chart", "視覺化" | 執行 `python scripts/spread_plotter.py --quick --output-dir output/`| | 5, "驗證", "穩定", "stability" | 閱讀 `workflows/analyze.md` 並聚焦穩定性驗證 | | 6, "學習", "方法論", "why" | 閱讀 `references/methodology.md` | | 提供參數 (如 ticker, lead) | 閱讀 `workflows/analyze.md` 並使用參數執行 |路由後,閱讀對應文件並執行。 </routing>
<directory_structure>
forecast-sector-relative-return-from-yield-spread/
├── SKILL.md # 本文件(路由器)
├── skill.yaml # 前端展示元數據
├── manifest.json # 技能元數據
├── workflows/
│ ├── analyze.md # 完整分析工作流
│ └── data-research.md # 數據源研究與替代方案
├── references/
│ ├── methodology.md # 方法論與計算邏輯
│ ├── input-schema.md # 完整輸入參數定義
│ └── data-sources.md # 數據來源與獲取方式
├── templates/
│ ├── output-json.md # JSON 輸出模板
│ └── output-markdown.md # Markdown 報告模板
├── scripts/
│ ├── spread_forecaster.py # 主計算腳本
│ └── spread_plotter.py # 視覺化圖表腳本
└── examples/
└── sample-output.json # 範例輸出
</directory_structure>
<reference_index>
方法論: references/methodology.md
資料來源: references/data-sources.md
輸入參數: references/input-schema.md
</reference_index>
<workflows_index>
| Workflow | Purpose | 使用時機 |
|---|---|---|
| analyze.md | 完整情境分析 | 需要自訂參數驗證領先關係與預測 |
| data-research.md | 數據源研究 | 了解如何獲取或替代殖利率/資產數據 |
| </workflows_index> |
<templates_index>
| Template | Purpose |
|---|---|
| output-json.md | JSON 輸出結構定義 |
| output-markdown.md | Markdown 報告模板 |
| </templates_index> |
<scripts_index>
| Script | Command | Purpose |
|---|---|---|
| spread_forecaster.py | --quick | 快速分析 QQQ/XLV, 24m lead |
| spread_forecaster.py | --lead-months 12 --lookback-years 15 | 自訂領先期與回測長度 |
| spread_forecaster.py | --lead-scan --scan-range 6,12,18,24,30 | 領先期掃描 |
| spread_plotter.py | --quick --output-dir ../../output | 快速生成基本版圖表 |
| spread_plotter.py | --comprehensive --start-date 2007-01-01 | 完整版圖表(含領先對齊) |
| </scripts_index> |
<input_schema_summary>
核心參數
| 參數 | 類型 | 預設值 | 說明 |
|---|---|---|---|
| risk_ticker | string | QQQ | 代表成長股的標的 |
| defensive_ticker | string | XLV | 代表防禦股的標的 |
| short_tenor | string | 2Y | 短端殖利率期限 |
| long_tenor | string | 10Y | 長端殖利率期限 |
| lead_months | int | 24 | 領先期(月) |
| lookback_years | int | 12 | 回測/估計歷史年數 |
進階參數
| 參數 | 類型 | 預設值 | 說明 |
|---|---|---|---|
| freq | string | weekly | 資料頻率(daily/weekly/monthly) |
| smoothing_window | int | 13 | 平滑視窗(週數) |
| return_horizon_months | int | 24 | 預測的相對報酬視窗 |
| model_type | string | lagged_regression | 模型類型 |
| confidence_level | float | 0.80 | 區間估計信心水準 |
完整參數定義見 references/input-schema.md。
</input_schema_summary>
<output_schema_summary>
{
"skill": "forecast_sector_relative_return_from_yield_spread",
"inputs": {
"risk_ticker": "QQQ",
"defensive_ticker": "XLV",
"lead_months": 24,
"lookback_years": 12
},
"signal_name": "US02Y_minus_US10Y_leads_QQQ_over_XLV",
"lead_months": 24,
"current_spread": -0.35,
"model": {
"type": "lagged_regression",
"alpha": 0.02,
"beta": -0.45,
"fit_quality": {
"corr_x_y": -0.32,
"r_squared": 0.10,
"notes": "負 beta 意味歷史上倒掛/緊縮的 spread 對應未來 QQQ 相對走弱"
}
},
"forecast": {
"future_24m_relative_return_log": -0.08,
"future_24m_relative_return_pct": -0.077,
"interval_pct_80": [-0.22, 0.04],
"interpretation": "若此關係維持,未來24個月QQQ相對XLV期望報酬為-7.7%,XLV較可能跑贏;但區間仍含正值,需搭配其他條件確認。"
},
"diagnostics": {
"lead_scan": {
"best_lead_months": 24,
"correlation_by_lead": {"6": -0.15, "12": -0.22, "18": -0.28, "24": -0.32, "30": -0.30}
},
"stability_checks": {
"first_half_corr": -0.30,
"second_half_corr": -0.34,
"consistency": "medium-high"
}
},
"summary": "殖利率利差(2Y-10Y)對 QQQ/XLV 相對報酬有約 24 個月的領先性...",
"notes": [
"領先關係反映的是『歷史統計規律』,不保證未來成立。",
"當前 spread 水準與變化率皆需考慮。",
"建議搭配:景氣指標、估值分位、資金流向做交叉驗證。"
]
}
完整輸出結構見 templates/output-json.md。
</output_schema_summary>
<success_criteria> 執行成功時應產出:
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience