zeberg-salomon-rotator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<essential_principles>
<principle name="two_state_model"> **兩態切換模型核心**
Zeberg–Salomon 模型將市場簡化為兩種狀態:
  • RISK_ON: 持有股票(SPY),景氣擴張期
  • RISK_OFF: 持有長債(TLT),景氣收縮期
切換邏輯基於「領先指標先轉弱,同時指標後確認」的景氣循環規律。 </principle>
<principle name="leading_coincident"> **領先 vs 同時指標**
類型作用典型成分領先時間
Leading預警殖利率曲線、新訂單、房市許可6-12 月
Coincident確認就業、工業生產、實質收入同步
合成方式
  1. 各序列做 transform(yoy/mom/diff)
  2. 統一方向(direction +1/-1)
  3. Rolling z-score 標準化
  4. EMA 平滑
  5. 加權合成 </principle>
<principle name="iceberg_sinking"> **冰山事件 vs 下沉事件**
Iceberg Event: LeadingIndex < iceberg_threshold
  → 預警:景氣開始轉弱
  → 搭配「領先指標下降」+ 可選「市場亢奮」濾鏡

Sinking Event: CoincidentIndex < sinking_threshold
  → 確認:實體經濟收縮
  → 通常在 Iceberg 之後數月發生
狀態機邏輯
  • RISK_ON → RISK_OFF:Iceberg 連續確認 + 斜率為負
  • RISK_OFF → RISK_ON:領先指標回升超過 (threshold + hysteresis) </principle>
<principle name="data_access"> **資料取得方式**
本 skill 使用無需 API key 的資料來源:
  • FRED CSV:
    https://fred.stlouisfed.org/graph/fredgraph.csv?id={SERIES_ID}
  • Yahoo Finance:
    yfinance
    套件抓取 SPY, TLT, VIX
腳本位於
scripts/
目錄,可直接執行。 </principle>
</essential_principles>
<objective> 實作 Zeberg–Salomon 兩態輪動策略:
  1. 建構指標:從 FRED 數據合成 LeadingIndex 與 CoincidentIndex
  2. 偵測事件:識別「冰山」(領先轉弱)與「下沉」(同時確認)
  3. 切換訊號:產生 RISK_ON ↔ RISK_OFF 切換事件
  4. 回測績效:計算累積報酬、MaxDD、CAGR、與 benchmark 比較
輸出:切換事件清單、指標時間序列、回測摘要、診斷資訊。 </objective>
<quick_start>
最快的方式:執行預設回測
bash
cd skills/zeberg-salomon-rotator
pip install pandas numpy yfinance pandas-datareader  # 首次使用
python scripts/rotator.py --quick
輸出範例:
json
{
  "state": "RISK_ON",
  "latest_indices": {"LeadingIndex": 0.41, "CoincidentIndex": 0.22},
  "iceberg_event": false,
  "sinking_event": false,
  "last_switch": {"date": "2023-06-30", "action": "EXIT_LONG_BOND_ENTER_EQUITY"}
}
完整回測
bash
python scripts/rotator.py --start 2000-01-01 --end 2026-01-01 --output result.json
</quick_start>
<intake> 需要進行什麼操作?
  1. 快速檢查 - 查看目前的景氣狀態與最新指標
  2. 完整回測 - 執行完整的歷史回測與績效分析
  3. 視覺化圖表 - 生成多面板回測結果圖表
  4. 監控模式 - 設定持續監控與切換警報
  5. 方法論學習 - 了解 Zeberg-Salomon 模型的邏輯
請選擇或直接提供分析參數。 </intake>
<routing> | Response | Action | |-------------------------------|---------------------------------------------| | 1, "快速", "quick", "check" | 執行 `python scripts/rotator.py --quick` | | 2, "回測", "backtest", "full" | 閱讀 `workflows/backtest.md` 並執行 | | 3, "視覺化", "chart", "plot" | 閱讀 `workflows/visualize.md` 並執行 | | 4, "監控", "monitor", "alert" | 閱讀 `workflows/monitor.md` 並執行 | | 5, "學習", "方法論", "why" | 閱讀 `references/methodology.md` | | 提供參數 (如日期範圍) | 閱讀 `workflows/backtest.md` 並使用參數執行 |
路由後,閱讀對應文件並執行。 </routing>
<directory_structure>
zeberg-salomon-rotator/
├── SKILL.md                           # 本文件(路由器)
├── skill.yaml                         # 前端展示元數據
├── manifest.json                      # 技能元數據
├── workflows/
│   ├── backtest.md                    # 完整回測工作流
│   ├── visualize.md                   # 視覺化工作流
│   ├── monitor.md                     # 持續監控工作流
│   └── analyze.md                     # 深度分析工作流
├── references/
│   ├── data-sources.md                # FRED 系列代碼與資料來源
│   ├── methodology.md                 # Zeberg-Salomon 方法論解析
│   └── input-schema.md                # 完整輸入參數定義
├── templates/
│   ├── output-json.md                 # JSON 輸出模板
│   └── output-markdown.md             # Markdown 報告模板
└── scripts/
    ├── rotator.py                     # 主輪動腳本
    ├── visualize.py                   # 視覺化繪圖工具
    └── fetch_data.py                  # 數據抓取工具
</directory_structure>
<reference_index>
方法論: references/methodology.md
  • Zeberg-Salomon 模型概念
  • 冰山/下沉事件定義
  • 兩態切換邏輯
資料來源: references/data-sources.md
  • FRED 系列代碼(領先/同時)
  • Yahoo Finance 資產代碼
  • 數據頻率與對齊
輸入參數: references/input-schema.md
  • 完整參數定義
  • 預設值與建議範圍
</reference_index>
<workflows_index>
WorkflowPurpose使用時機
backtest.md完整歷史回測需要績效分析時
visualize.md生成視覺化圖表需要圖表展示時
monitor.md持續監控狀態日常監控或警報
analyze.md深度指標分析理解當前市場狀態
</workflows_index>
<templates_index>
TemplatePurpose
output-json.mdJSON 輸出結構定義
output-markdown.mdMarkdown 報告模板
</templates_index>
<scripts_index>
ScriptCommandPurpose
rotator.py
--quick
快速檢查當前狀態
rotator.py
--start DATE --end DATE
完整回測
visualize.py
-i result.json -o chart.png
生成視覺化圖表
fetch_data.py
--series T10Y3M,PAYEMS
抓取 FRED 資料
</scripts_index>
<input_schema_summary>
核心參數
參數類型預設值說明
start_datestring2000-01-01回測起始日
end_datestringtoday回測結束日
freqstringM頻率(M=月)
equity_proxystringSPY風險資產代理
bond_proxystringTLT長債代理
門檻參數
參數類型預設值說明
iceberg_thresholdnumber-0.3領先指標門檻
sinking_thresholdnumber-0.5同時指標門檻
confirm_periodsint2連續確認期數
hysteresisnumber0.15進出場間距
完整參數定義見
references/input-schema.md
</input_schema_summary>
<output_schema_summary>
json
{
  "skill": "zeberg-salomon-rotator",
  "as_of": "2026-01-14",
  "state": "RISK_ON",
  "latest_indices": {
    "LeadingIndex": 0.41,
    "CoincidentIndex": 0.22,
    "iceberg_event": false,
    "sinking_event": false
  },
  "switch_events": [...],
  "backtest_summary": {
    "cagr": 0.123,
    "max_drawdown": -0.27,
    "turnovers": 10
  }
}
完整輸出結構見
templates/output-json.md
。 </output_schema_summary>
<success_criteria> 執行成功時應產出:
  • 當前狀態(RISK_ON 或 RISK_OFF)
  • LeadingIndex 與 CoincidentIndex 數值
  • 冰山/下沉事件判定
  • 切換事件清單(含日期、原因)
  • 回測績效摘要(CAGR, MaxDD, 換手次數)
  • 與 benchmark 比較(買入持有、60/40)
  • 診斷資訊(各指標貢獻)
  • 視覺化圖表(可選,輸出至
    output/
    目錄) </success_criteria>
<essential_principles>
<principle name="two_state_model"> **Core of Two-State Switching Model**
The Zeberg–Salomon model simplifies the market into two states:
  • RISK_ON: Hold equities (SPY), business cycle expansion phase
  • RISK_OFF: Hold long-term bonds (TLT), business cycle contraction phase
The switching logic is based on the business cycle rule that "leading indicators weaken first, followed by confirmation from coincident indicators." </principle>
<principle name="leading_coincident"> **Leading vs Coincident Indicators**
TypeFunctionTypical ComponentsLead Time
LeadingEarly WarningYield curve, new orders, housing permits6-12 months
CoincidentConfirmationEmployment, industrial production, real incomeSynchronous
Synthesis Method:
  1. Transform each series (yoy/mom/diff)
  2. Unify direction (+1/-1)
  3. Rolling z-score standardization
  4. EMA smoothing
  5. Weighted synthesis </principle>
<principle name="iceberg_sinking"> **Iceberg Event vs Sinking Event**
Iceberg Event: LeadingIndex < iceberg_threshold
  → 預警:景氣開始轉弱
  → 搭配「領先指標下降」+ 可選「市場亢奮」濾鏡

Sinking Event: CoincidentIndex < sinking_threshold
  → 確認:實體經濟收縮
  → 通常在 Iceberg 之後數月發生
State Machine Logic:
  • RISK_ON → RISK_OFF: Iceberg Event confirmed consecutively + negative slope
  • RISK_OFF → RISK_ON: Leading indicator rebounds above (threshold + hysteresis) </principle>
<principle name="data_access"> **Data Acquisition Methods**
This skill uses data sources that do not require an API key:
  • FRED CSV:
    https://fred.stlouisfed.org/graph/fredgraph.csv?id={SERIES_ID}
  • Yahoo Finance: Fetch SPY, TLT, VIX using the
    yfinance
    package
Scripts are located in the
scripts/
directory and can be executed directly. </principle>
</essential_principles>
<objective> Implement the Zeberg–Salomon two-state rotation strategy:
  1. Construct Indicators: Synthesize LeadingIndex and CoincidentIndex from FRED data
  2. Detect Events: Identify "Iceberg" (leading indicator weakening) and "Sinking" (coincident indicator confirmation) events
  3. Generate Switch Signals: Produce RISK_ON ↔ RISK_OFF switch events
  4. Backtest Performance: Calculate cumulative returns, MaxDD, CAGR, and compare with benchmarks
Outputs: List of switch events, indicator time series, backtest summary, diagnostic information. </objective>
<quick_start>
Fastest Way: Run Default Backtest
bash
cd skills/zeberg-salomon-rotator
pip install pandas numpy yfinance pandas-datareader  # First-time use
python scripts/rotator.py --quick
Sample Output:
json
{
  "state": "RISK_ON",
  "latest_indices": {"LeadingIndex": 0.41, "CoincidentIndex": 0.22},
  "iceberg_event": false,
  "sinking_event": false,
  "last_switch": {"date": "2023-06-30", "action": "EXIT_LONG_BOND_ENTER_EQUITY"}
}
Full Backtest:
bash
python scripts/rotator.py --start 2000-01-01 --end 2026-01-01 --output result.json
</quick_start>
<intake> What operation do you need to perform?
  1. Quick Check - View current business cycle state and latest indicators
  2. Full Backtest - Perform complete historical backtest and performance analysis
  3. Visualization Charts - Generate multi-panel backtest result charts
  4. Monitoring Mode - Set up continuous monitoring and switch alerts
  5. Methodology Learning - Understand the logic of the Zeberg-Salomon model
Please select or provide analysis parameters directly. </intake>
<routing> | Response | Action | |-------------------------------|---------------------------------------------| | 1, "quick", "check" | Execute `python scripts/rotator.py --quick` | | 2, "backtest", "full" | Read `workflows/backtest.md` and execute | | 3, "chart", "plot" | Read `workflows/visualize.md` and execute | | 4, "monitor", "alert" | Read `workflows/monitor.md` and execute | | 5, "learn", "methodology", "why" | Read `references/methodology.md` | | Provide parameters (e.g., date range) | Read `workflows/backtest.md` and execute with parameters |
After routing, read the corresponding document and execute. </routing>
<directory_structure>
zeberg-salomon-rotator/
├── SKILL.md                           # 本文件(路由器)
├── skill.yaml                         # 前端展示元數據
├── manifest.json                      # 技能元數據
├── workflows/
│   ├── backtest.md                    # 完整回測工作流
│   ├── visualize.md                   # 視覺化工作流
│   ├── monitor.md                     # 持續監控工作流
│   └── analyze.md                     # 深度分析工作流
├── references/
│   ├── data-sources.md                # FRED 系列代碼與資料來源
│   ├── methodology.md                 # Zeberg-Salomon 方法論解析
│   └── input-schema.md                # 完整輸入參數定義
├── templates/
│   ├── output-json.md                 # JSON 輸出模板
│   └── output-markdown.md             # Markdown 報告模板
└── scripts/
    ├── rotator.py                     # 主輪動腳本
    ├── visualize.py                   # 視覺化繪圖工具
    └── fetch_data.py                  # 數據抓取工具
</directory_structure>
<reference_index>
Methodology: references/methodology.md
  • Zeberg-Salomon model concepts
  • Definitions of Iceberg/Sinking events
  • Two-state switching logic
Data Sources: references/data-sources.md
  • FRED series codes (leading/coincident)
  • Yahoo Finance asset codes
  • Data frequency and alignment
Input Parameters: references/input-schema.md
  • Complete parameter definitions
  • Default values and recommended ranges
</reference_index>
<workflows_index>
WorkflowPurposeUsage Scenario
backtest.mdComplete historical backtestWhen performance analysis is needed
visualize.mdGenerate visualization chartsWhen chart presentation is needed
monitor.mdContinuous state monitoringFor daily monitoring or alerts
analyze.mdIn-depth indicator analysisTo understand current market conditions
</workflows_index>
<templates_index>
TemplatePurpose
output-json.mdJSON output structure definition
output-markdown.mdMarkdown report template
</templates_index>
<scripts_index>
ScriptCommandPurpose
rotator.py
--quick
Quick check of current state
rotator.py
--start DATE --end DATE
Complete backtest
visualize.py
-i result.json -o chart.png
Generate visualization charts
fetch_data.py
--series T10Y3M,PAYEMS
Fetch FRED data
</scripts_index>
<input_schema_summary>
Core Parameters
ParameterTypeDefault ValueDescription
start_datestring2000-01-01Backtest start date
end_datestringtodayBacktest end date
freqstringMFrequency (M=Monthly)
equity_proxystringSPYRisk asset proxy
bond_proxystringTLTLong-term bond proxy
Threshold Parameters
ParameterTypeDefault ValueDescription
iceberg_thresholdnumber-0.3Leading indicator threshold
sinking_thresholdnumber-0.5Coincident indicator threshold
confirm_periodsint2Number of consecutive confirmation periods
hysteresisnumber0.15Entry/exit gap
Complete parameter definitions can be found in
references/input-schema.md
.
</input_schema_summary>
<output_schema_summary>
json
{
  "skill": "zeberg-salomon-rotator",
  "as_of": "2026-01-14",
  "state": "RISK_ON",
  "latest_indices": {
    "LeadingIndex": 0.41,
    "CoincidentIndex": 0.22,
    "iceberg_event": false,
    "sinking_event": false
  },
  "switch_events": [...],
  "backtest_summary": {
    "cagr": 0.123,
    "max_drawdown": -0.27,
    "turnovers": 10
  }
}
Complete output structure is available in
templates/output-json.md
. </output_schema_summary>
<success_criteria> When execution is successful, the following should be produced:
  • Current state (RISK_ON or RISK_OFF)
  • Values of LeadingIndex and CoincidentIndex
  • Iceberg/Sinking event determination
  • List of switch events (including date, reason)
  • Backtest performance summary (CAGR, MaxDD, number of turnovers)
  • Comparison with benchmarks (buy-and-hold, 60/40)
  • Diagnostic information (contribution of each indicator)
  • Visualization charts (optional, output to
    output/
    directory) </success_criteria>