<essential_principles>
Core understanding: Turn "visual analogy" into quantifiable "shape matching", but "similar" does not mean "will happen":
- Correlation coefficient (corr): linear shape similarity between the recent window vs. the baseline window
- Dynamic Time Warping (DTW): allows "a bit faster/a bit slower" but similar shape
- Shape features (shape_features): trend slope, inflection point structure, volatility expansion
The output "pattern_similarity_score" only answers "does it look alike", not "will it happen".
Separate "shape similarity" from "stress verification":
- pattern_similarity_score: measures only shape similarity
- stress_confirmation_score: measures whether cross-validation indicators are deteriorating in sync
- composite_risk_score: weighted composite, but must include "which indicators support/oppose"
Counterintuitive check:
- If similarity is very high, but cross-validation indicators show no stress signals → it may just be graphical similarity caused by interest rates/holding structure/accounting amortization
- If similarity is moderate, but most stress indicators are deteriorating in sync → instead, raise vigilance
Causes of WUDSHO (Unamortized Discounts):
- When the Federal Reserve purchases bonds, if the purchase price is below face value, the difference is recorded as "unamortized discount"
- Rising interest rate period: market prices fall → discount on purchased bonds increases → WUDSHO rises
- Falling interest rate period: market prices rise → premium on purchased bonds increases → WUDSHO falls
Important: Changes in WUDSHO may reflect:
- Changes in the interest rate environment (most common)
- Duration structure of held bonds
- Accounting amortization schedule
- Genuine financial stress(requires cross-validation to confirm)
Community narratives based on "graphical analogy" often lack counterevidence:
- ❌ "This line replicates COVID, a black swan within 60 days" → analogy only, no verification
- ✅ Output of this skill: "Shape similarity 0.88, but credit spreads are neutral and equity volatility is low → does not support the systemic stress hypothesis"
Counterevidence items that must be output:
- Alternative explanations for "shape similarity" (interest rate effects, accounting effects)
- Current status of "stress indicators" (support/oppose the risk hypothesis)
- Conditional distribution of "historical aftermath" (not a forecast)
This skill uses FRED public weekly data:
- WUDSHO: Unamortized discounts on securities held by the Fed
- Cross-validation indicators: credit spreads, volatility, short-end spreads, etc.
Must disclose:
- FRED weekly data may have a T+1 ~ T+3 delay
- Some indicators (such as window tool usage) require alternative proxies
- Shape matching results are affected by resample frequency
</essential_principles>
- Obtain target series: obtain weekly data for WUDSHO (or a specified series) from FRED
- Window matching: perform shape matching between the recent window and historical baseline windows (such as COVID 2020)
- Similarity calculation: use multiple methods such as correlation coefficient, DTW, shape features, etc.
- Cross-validation: Check whether credit spreads, volatility, and liquidity indicators are deteriorating in sync
- Risk Score Synthesis: Output quantifiable risk scores and counterevidence analysis
- Scenario Narrative: Describe the subsequent development of historical analogies (not a forecast)
Output: shape similarity, stress validation score, composite risk score, counterevidence analysis, scenario projection.
<quick_start>
Fastest way: run the full analysis
cd skills/detect-fed-unamortized-discount-pattern
pip install pandas numpy requests scipy matplotlib # 首次使用
python scripts/pattern_detector.py --quick
Output:
output/pattern_analysis_YYYY-MM-DD.json- JSON results
Full Analysis (specify parameters):
python scripts/pattern_detector.py \
--target_series WUDSHO \
--baseline_windows "COVID_2020:2020-01-01:2020-06-30" \
--recent_window_days 120 \
--output result.json
Bloomberg-style visualization(output to project root directory output/):
python scripts/visualize_pattern.py
Generate charts using existing analysis results:
python scripts/visualize_pattern.py --json output/pattern_analysis_YYYY-MM-DD.json
Output charts:
output/fed_unamortized_discount_pattern_YYYY-MM-DD.png- Shape comparison and stress dashboardoutput/fed_unamortized_discount_history_YYYY-MM-DD.png- Historical trend overview
</quick_start>
- Quick Check (recommended) - View the current shape similarity and stress score
- Full Analysis - Run the full shape comparison and cross-validation
- Visualization Analysis - Generate shape comparison charts
- Historical Event Comparison - Gain a deeper understanding of the subsequent development of historical benchmark windows
- Methodology Learning - Understand the logic of shape comparison and cross-validation
- Custom Parameters - Specify parameters such as series, window, thresholds, etc.
Please select or directly provide analysis parameters.
After routing, read the corresponding document and execute.
<directory_structure>
detect-fed-unamortized-discount-pattern/
├── SKILL.md # 本文件(路由器)
├── skill.yaml # 前端展示元數據
├── manifest.json # 技能元數據
├── workflows/
│ ├── execute-analysis.md # 完整分析工作流
│ ├── visualize-analysis.md # 視覺化分析工作流
│ └── historical-episodes.md # 歷史事件對照工作流
├── references/
│ ├── methodology.md # 形狀比對與交叉驗證方法論
│ ├── data-sources.md # 資料來源與 FRED 系列代碼
│ ├── wudsho-mechanism.md # WUDSHO 指標機制說明
│ └── input-schema.md # 完整輸入參數定義
├── templates/
│ ├── output-json.md # JSON 輸出模板
│ └── output-markdown.md # Markdown 報告模板
├── scripts/
│ ├── pattern_detector.py # 主分析腳本
│ ├── visualize_pattern.py # 視覺化腳本
│ └── fetch_data.py # 資料抓取工具
└── examples/
└── sample_output.json # 範例輸出
</directory_structure>
<reference_index>
Methodology: references/methodology.md
- Shape comparison methods (correlation coefficient, DTW, shape features)
- Normalization and window alignment
- Similarity score calculation
- Cross-validation logic
Data Sources: references/data-sources.md
- FRED series code list
- Data frequency and lag
- Public alternative data description
Indicator Mechanisms: references/wudsho-mechanism.md
- Causes and interpretation of WUDSHO
- Rate effect vs. stress effect
- Common misreadings and counterevidence
Input Parameters: references/input-schema.md
- Complete parameter definitions
- Default values and recommended ranges
</reference_index>
<workflows_index>
| Workflow | Purpose | When to use |
|---|---|---|
| execute-analysis.md | Full shape comparison analysis | When a full report is needed |
| visualize-analysis.md | Visualization analysis | When charts are needed |
| historical-episodes.md | In-depth historical event analysis | Understand historical analogies and subsequent developments |
| </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 |
|---|---|---|
| pattern_detector.py | --quick |
Quick check of current status |
| pattern_detector.py | --output FILE |
Full analysis |
| visualize_pattern.py | (no parameters) | Bloomberg-style visualization (output to project root directory output/) |
| visualize_pattern.py | --json FILE |
Generate charts using existing JSON results |
| fetch_data.py | --series WUDSHO |
Fetch FRED data |
| </scripts_index> |
<input_schema_summary>
Core Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
| target_series | string | WUDSHO | Target FRED series code |
| baseline_windows | array[object] | [COVID] | Historical reference event window |
| recent_window_days | int | 120 | Recent comparison window length |
| resample_freq | string | W | Data frequency |
| normalize_method | string | zscore | Normalization method |
Similarity Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
| similarity_metrics | array[string] | [corr, dtw, shape_features] | Similarity Metrics |
| alert_thresholds | object | {corr_min: 0.7, ...} | Alert Trigger Threshold |
Cross-Validation Parameters
| Parameter | Type | Default Value | Description |
|---|---|---|---|
| confirmatory_indicators | array[object] | [Credit Spread...] | List of cross-validation indicators |
| lookahead_days | int | 60 | Forward-looking period (scenario narrative) |
For the complete parameter definitions, see references/input-schema.md。
</input_schema_summary>
<output_schema_summary>
{
"skill": "detect-fed-unamortized-discount-pattern",
"as_of_date": "2026-01-26",
"target_series": "WUDSHO",
"best_match": {
"baseline": "COVID_2020",
"segment_start": "2020-01-08",
"segment_end": "2020-06-17",
"corr": 0.91,
"dtw": 0.38,
"feature_sim": 0.82,
"pattern_similarity_score": 0.88
},
"stress_confirmation": {
"score": 0.22,
"details": [
{"name": "credit_spread", "signal": "neutral", "z": 0.4},
{"name": "equity_vol", "signal": "mild_risk_on", "z": -0.2},
{"name": "funding_stress_proxy", "signal": "neutral", "z": 0.1}
]
},
"composite_risk_score": 0.49,
"interpretation": {
"summary": "走勢形狀與 COVID 早期片段相似度高,但壓力驗證指標偏中性...",
"what_to_watch_next_60d": ["..."],
"rebuttal_to_claim": ["..."]
},
"caveats": [
"形狀相似不代表因果相同;該序列可能強烈受利率、持有期限結構與會計攤銷影響。",
"若缺乏壓力指標同步惡化,不應把圖形類比直接升級成『黑天鵝預言』。"
]
}
For the complete output structure, see templates/output-json.md。
</output_schema_summary>
<success_criteria> On successful execution, the following should be produced:
- Pattern similarity score (pattern_similarity_score)
- Best-matching historical segment (baseline, segment_start/end)
- Multi-dimensional similarity (corr, dtw, feature_sim)
- Stress confirmation score (stress_confirmation_score)
- Details of each validation indicator (name, signal, z-score)
- Composite risk score (composite_risk_score)
- Interpretation framework (summary, what_to_watch, rebuttal)
- Data quality notes and risk warnings (caveats)
Visualization Output(using visualize_pattern.py, Bloomberg style):
- Shape comparison and stress dashboard chart (
fed_unamortized_discount_pattern_YYYY-MM-DD.png)- Top left: Normalized shape comparison of recent vs. historical baseline window
- Top right: Similarity score panel (corr, DTW, feature_sim, composite risk)
- Bottom left: Stress validation indicator horizontal bar chart (Z-Score)
- Bottom right: Interpretation notes (signal statistics, conclusion)
- Historical trend overview chart (
fed_unamortized_discount_history_YYYY-MM-DD.png)- Full WUDSHO historical trend
- Historical baseline window markers (COVID_2020, GFC_2008, TAPER_2013, RATE_HIKE_2022)
- Recent window and best-matching segment highlighted
- Latest value annotation </success_criteria>