evaluate-exponential-trend-deviation-regimes
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<essential_principles>
資產趨勢偏離度分析 核心原則
<principle name="exponential_trend_fitting">
**指數趨勢線擬合**
多數資產在長期(數十年)尺度上遵循指數成長路徑。透過對數價格線性回歸(y = a + b*t where y = log(price))擬合趨勢線,trend = exp(a + b*t)。偏離度 = (price / trend - 1) × 100%。
</principle>
<principle name="historical_context">
**歷史極端對照**
透過計算當前偏離度在歷史分布中的分位數,以及與歷史峰值/谷值的比較,提供市場位置的脈絡。使用者可指定特定日期作為參考點,或由系統自動識別歷史極端值。
</principle>
<principle name="regime_classification">
**行情體質判定(選用)**
針對特定資產(如黃金、股指),可結合宏觀因子進行行情體質分析。不同資產有不同的體質分類框架,使用者可自定義判定規則與因子權重。
</principle>
<principle name="universal_applicability">
**通用適用性**
本技能適用於任何具有長期指數成長特性的資產:商品(黃金、原油)、股票指數、加密貨幣、房地產等。核心邏輯不預設特定資產或歷史峰值。
</principle>
</essential_principles>
<intake>
**您想要執行什麼操作?**
- 單資產偵測 - 計算單一資產的趨勢偏離度與歷史分位數
- 歷史對照分析 - 將當前偏離度與使用者指定的歷史日期或自動識別的極端值進行比較
- 宏觀因子分解 - 詳細拆解各宏觀代理指標對行情體質判定的貢獻(適用於支援的資產類別)
等待回應後再繼續。
</intake>
<routing>
| Response | Workflow | Description |
|------------------------------------|-----------------------|-------------|
| 1, "detect", "single", "偵測" | workflows/detect.md | 單資產趨勢偏離度偵測與體質判定 |
| 2, "compare", "historical", "對照" | workflows/compare.md | 歷史峰值詳細對照分析 |
| 3, "macro", "breakdown", "因子" | workflows/macro.md | 宏觀因子分解與貢獻度分析 |
讀取工作流程後,請完全遵循其步驟。
</routing>
<quick_start>
快速開始
bash
undefined<essential_principles>
Core Principles of Asset Trend Deviation Analysis
<principle name="exponential_trend_fitting">
**Exponential Trend Line Fitting**
Most assets follow an exponential growth path over long-term (decades-long) scales. Fit the trend line via logarithmic price linear regression (y = a + b*t where y = log(price)), trend = exp(a + b*t). Deviation = (price / trend - 1) × 100%.
</principle>
<principle name="historical_context">
**Historical Extreme Comparison**
Provide context for the market position by calculating the quantile of the current deviation in the historical distribution, as well as comparing it with historical peaks/troughs. Users can specify a specific date as a reference point, or the system can automatically identify historical extreme values.
</principle>
<principle name="regime_classification">
**Market Regime Assessment (Optional)**
For specific assets (such as gold, stock indices), macro factor analysis can be integrated to assess market regimes. Different assets have different regime classification frameworks, and users can customize assessment rules and factor weights.
</principle>
<principle name="universal_applicability">
**Universal Applicability**
This skill is applicable to any asset with long-term exponential growth characteristics: commodities (gold, crude oil), stock indices, cryptocurrencies, real estate, etc. The core logic does not presuppose specific assets or historical peaks.
</principle>
</essential_principles>
<intake>
**What operation would you like to perform?**
- Single Asset Detection - Calculate the trend deviation and historical quantile of a single asset
- Historical Comparison Analysis - Compare the current deviation with a user-specified historical date or automatically identified extreme values
- Macro Factor Decomposition - Detailed breakdown of the contribution of each macro proxy indicator to market regime assessment (applicable to supported asset classes)
Please respond to continue.
</intake>
<routing>
| Response | Workflow | Description |
|------------------------------------|-----------------------|-------------|
| 1, "detect", "single", "偵測" | workflows/detect.md | Single asset trend deviation detection and regime assessment |
| 2, "compare", "historical", "對照" | workflows/compare.md | Detailed historical peak comparison analysis |
| 3, "macro", "breakdown", "因子" | workflows/macro.md | Macro factor decomposition and contribution analysis |
After reading the workflow, please follow its steps exactly.
</routing>
<quick_start>
Quick Start
bash
undefined安裝依賴
Install dependencies
pip install pandas numpy yfinance pandas-datareader statsmodels
pip install pandas numpy yfinance pandas-datareader statsmodels
快速偵測(範例:黃金期貨)
Quick Detection (Example: Gold Futures)
cd skills/evaluate-exponential-trend-deviation-regimes
python scripts/trend_deviation.py --symbol GC=F --quick
cd skills/evaluate-exponential-trend-deviation-regimes
python scripts/trend_deviation.py --symbol GC=F --quick
分析其他資產(範例:S&P 500)
Analyze Other Assets (Example: S&P 500)
python scripts/trend_deviation.py --symbol ^GSPC --start 1950-01-01
python scripts/trend_deviation.py --symbol ^GSPC --start 1950-01-01
完整分析(含宏觀因子,目前支援黃金)
Full Analysis (Including Macro Factors, Currently Supports Gold)
python scripts/trend_deviation.py --symbol GC=F --start 1970-01-01 --include-macro
python scripts/trend_deviation.py --symbol GC=F --start 1970-01-01 --include-macro
指定歷史參考日期
Specify Historical Reference Date
python scripts/trend_deviation.py --symbol GC=F --compare-peaks "2011-09-06,2020-08-07"
python scripts/trend_deviation.py --symbol GC=F --compare-peaks "2011-09-06,2020-08-07"
生成視覺化圖表(輸出 PNG + JSON)
Generate Visualization Charts (Output PNG + JSON)
python scripts/generate_chart.py --output ./output/
</quick_start>
<reference_index>
**參考文件** (`references/`)
| 文件 | 內容 |
|------|------|
| input-schema.md | 輸入參數詳細定義與驗證規則 |
| methodology.md | 指數趨勢擬合與偏離度計算方法論 |
| regime-rules.md | 1970s-like vs 2000s-like 體質判定規則 |
| data-sources.md | 數據來源與替代方案說明 |
</reference_index>
<workflows_index>
| Workflow | Purpose |
|----------|---------|
| detect.md | 單資產趨勢偏離度偵測與體質判定 |
| compare.md | 歷史峰值詳細對照分析 |
| macro.md | 宏觀因子分解與貢獻度分析 |
</workflows_index>
<templates_index>
| Template | Purpose |
|----------|---------|
| output-json.md | JSON 輸出結構定義 |
| output-markdown.md | Markdown 報告輸出模板 |
</templates_index>
<scripts_index>
| Script | Purpose |
|--------|---------|
| trend_deviation.py | 主要分析腳本:趨勢擬合、偏離度計算、體質判定 |
| generate_chart.py | 視覺化圖表生成:偏離度歷史圖表與峰值標註 |
</scripts_index>
<examples_index>
**範例輸出** (`examples/`)
| 文件 | 內容 |
|------|------|
| gold-deviation-2026.json | 2026 年黃金趨勢偏離度分析範例 |
</examples_index>
<success_criteria>
Skill 成功執行時:
- [ ] 成功擬合黃金價格的指數趨勢線
- [ ] 計算出當前偏離度百分比與歷史分位數
- [ ] 與 2011/1980 峰值進行有效比較
- [ ] 綜合宏觀代理指標得出 regime 判定(1970s-like / 2000s-like)
- [ ] 輸出完整的 JSON 或 Markdown 報告
- [ ] (選用)生成視覺化圖表(PNG)標註歷史峰值與當前位置
</success_criteria>python scripts/generate_chart.py --output ./output/
</quick_start>
<reference_index>
**Reference Documents** (`references/`)
| Document | Content |
|------|------|
| input-schema.md | Detailed definition and validation rules for input parameters |
| methodology.md | Methodology for exponential trend fitting and deviation calculation |
| regime-rules.md | Regime assessment rules for 1970s-like vs 2000s-like |
| data-sources.md | Data sources and alternative solutions description |
</reference_index>
<workflows_index>
| Workflow | Purpose |
|----------|---------|
| detect.md | Single asset trend deviation detection and regime assessment |
| compare.md | Detailed historical peak comparison analysis |
| macro.md | Macro factor decomposition and contribution analysis |
</workflows_index>
<templates_index>
| Template | Purpose |
|----------|---------|
| output-json.md | JSON output structure definition |
| output-markdown.md | Markdown report output template |
</templates_index>
<scripts_index>
| Script | Purpose |
|--------|---------|
| trend_deviation.py | Main analysis script: trend fitting, deviation calculation, regime assessment |
| generate_chart.py | Visualization chart generation: historical deviation chart and peak annotation |
</scripts_index>
<examples_index>
**Example Outputs** (`examples/`)
| Document | Content |
|------|------|
| gold-deviation-2026.json | Example of gold trend deviation analysis in 2026 |
</examples_index>
<success_criteria>
When the skill is successfully executed:
- [ ] Successfully fit the exponential trend line of gold prices
- [ ] Calculate the current deviation percentage and historical quantile
- [ ] Effectively compare with the 2011/1980 peaks
- [ ] Combine macro proxy indicators to reach a regime assessment (1970s-like / 2000s-like)
- [ ] Output a complete JSON or Markdown report
- [ ] (Optional) Generate a visualization chart (PNG) annotating historical peaks and current position
</success_criteria>