SuperAPI AI Directory

analyze-platinum-to-brazil-equities-transmission

Data & analytics

View repository

Updated 10-16 06:14

About this skill

<essential_principles>

This skill focuses on "validating narratives with data":

  • Input: community/news claims that "platinum trends may lead or drive the Brazilian stock market"
  • Output: test results of the transmission hypothesis on long-cycle time series

No price prediction is made; it only answers: "Does the transmission structure from platinum to the Brazilian stock market exist in the data?"

Use Cross-Correlation to scan the range [-lead_lag_max, +lead_lag_max]:

  • corr(r_ewz, r_platinum.shift(lag))
  • lag > 0: platinum leads EWZ (platinum leads)
  • lag < 0: EWZ leads platinum
  • lag ≈ 0: synchronous movement

Typical setting: weekly frequency lag max = 52 (one year), find the lag with the largest |corr|.

The relationship between platinum and the Brazilian stock market has cyclical characteristics:

  • linked_upcycle: both trends move upward together, and the transmission structure is stable
  • decoupled: the relationship breaks down, and each moves on its own
  • brazil_idiosyncratic: Brazil-specific risks (politics/exchange rate/commodity structure) dominate

Long-term regime judgment uses trend consistency within regime_window (default 104 weeks ≈ 2 years).

Quantify transmission credibility by combining three dimensions:

Dimension Weight Description
best_lead_lag_corr 30% Best lead-lag correlation coefficient
rolling_corr_stability 30% Proportion and continuity of rolling corr > 0
trend_agreement 40% Degree of long-term trend consistency

Score interpretation: ≥70 strong transmission, 50-69 moderate, <50 weak/unstable.

Mainly uses Yahoo Finance (free, no API key required):

  • Platinum futures:PL=F
  • Brazil stock market ETF:EWZ

Frequency recommendation: 1wk (weekly frequency) for long-cycle analysis, avoiding daily-frequency noise interference. Alignment method: inner join (keep only common trading days), avoiding false correlation caused by imputation.

</essential_principles>

  1. Data retrieval: obtain historical prices of platinum futures and EWZ from Yahoo Finance
  2. Dual-axis chart and normalized chart: Bloomberg-style dual-axis chart of raw values + normalized same-axis comparison
  3. Lead-lag analysis: cross-correlation to identify whether platinum leads EWZ and the number of lag periods
  4. Rolling Correlation: rolling correlation to observe the time-varying structure of the relationship
  5. Regime judgment: long-term trend consistency to determine which transmission regime is currently in effect
  6. Transmission strength score: composite score (0-100) to quantify transmission credibility

Output: transmission strength score, lead-lag determination, regime label, monitoring checklist, Bloomberg-style charts.

<quick_start>

Step 1: Install dependencies

pip install yfinance pandas numpy matplotlib scipy

Step 2: Run the full analysis

cd scripts
python analyze.py --start 2003-01-01

Step 3: Generate Bloomberg-style visualization charts

python visualize.py --start 2003-01-01
# 輸出到: output/platinum_vs_ewz_YYYY-MM-DD.png

Output examples:

{
  "signal": "transmission_moderate",
  "confidence": "medium",
  "transmission_strength_score": 74,
  "best_lead_lag": {
    "lag_weeks": 12,
    "meaning": "Platinum leads EWZ by ~12 weeks",
    "corr": 0.52
  },
  "rolling_corr": {
    "window": 52,
    "latest": 0.41,
    "positive_share_5y": 0.68
  },
  "regime_label": "linked_upcycle",
  "monitoring_notes": [
    "若 PL=F 突破長期區間,觀察 EWZ 在 8-16 週內是否趨勢翻多",
    "要求 52 週 rolling corr 維持正值至少 26 週作為確認",
    "若白金大漲而 EWZ 不動且 corr 轉負,視為 regime break"
  ]
}

</quick_start>

  1. Quick check - View the current transmission status between platinum and the Brazilian stock market
  2. Full analysis - Run the full transmission test and generate a report
  3. Visualization charts - Generate Bloomberg-style dual-axis charts and correlation analysis charts
  4. Methodology learning - Understand the principles of transmission analysis, cross-correlation, and regime judgment

Please choose or directly provide analysis parameters.

After routing, read the corresponding document and execute.

<directory_structure>

analyze-platinum-to-brazil-equities-transmission/
├── SKILL.md                           # 本文件(路由器)
├── skill.yaml                         # 前端展示元數據
├── manifest.json                      # 技能元資料
├── workflows/
│   ├── analyze.md                     # 完整傳導分析工作流
│   └── visualize.md                   # 視覺化工作流
├── references/
│   ├── data-sources.md                # 資料來源與替代方案
│   ├── methodology.md                 # 傳導分析方法論
│   └── input-schema.md                # 完整輸入參數定義
├── templates/
│   ├── output-json.md                 # JSON 輸出模板
│   └── output-markdown.md             # Markdown 報告模板
├── scripts/
│   ├── analyze.py                     # 主分析腳本
│   ├── fetch_data.py                  # 數據抓取工具(Yahoo Finance)
│   └── visualize.py                   # Bloomberg 風格視覺化
└── examples/
    └── sample_output.json             # 範例輸出

</directory_structure>

<reference_index>

Methodology: references/methodology.md

  • Cross-Correlation Lead-Lag Analysis
  • Rolling Correlation Time-Varying Structure
  • Regime Determination Logic
  • Transmission Strength Score Calculation

Data Sources: references/data-sources.md

  • Yahoo Finance(PL=F, EWZ)
  • Frequency Handling and Alignment
  • Fallback Data Sources

Input Parameters: references/input-schema.md

  • Complete Parameter Definitions and Default Values
  • start_date, frequency, corr_window, lead_lag_max, etc.

</reference_index>

<workflows_index>

Workflow Purpose When to Use
analyze.md Complete Transmission Analysis When the transmission narrative needs to be validated
visualize.md Generate Visualization Charts When Bloomberg-style charts are needed
</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
analyze.py --start DATE [--end DATE] [--freq 1wk] Complete Transmission Analysis
fetch_data.py --start DATE [--end DATE] [--freq 1wk] Data Fetching and Caching
visualize.py --start DATE [--end DATE] Bloomberg-style Visualization
</scripts_index>

<input_schema>

</input_schema>

<output_schema> See templates/output-json.md for the complete structure definition.

Summary:

{
  "signal": "transmission_strong | transmission_moderate | transmission_weak | inconclusive",
  "confidence": "high | medium | low",
  "transmission_strength_score": 74,
  "best_lead_lag": {
    "lag_weeks": 12,
    "corr": 0.52,
    "meaning": "Platinum leads EWZ by ~12 weeks"
  },
  "rolling_corr": {
    "window": 52,
    "latest": 0.41,
    "positive_share_5y": 0.68
  },
  "regime_label": "linked_upcycle | decoupled | brazil_idiosyncratic",
  "monitoring_notes": ["..."],
  "artifacts": {
    "charts": ["output/platinum_vs_ewz_YYYY-MM-DD.png"]
  }
}

</output_schema>

<success_criteria> A successful analysis should produce:

  • The lead-lag days (weeks) and correlation coefficient between Platinum and EWZ
  • The latest 52-week Rolling Correlation value and the proportion of positive values
  • Transmission strength score (0-100)
  • Current Regime Label (linked_upcycle / decoupled / brazil_idiosyncratic)
  • Transmission conclusion and alternative explanations
  • Monitoring checklist (not short-term)
  • Bloomberg-style dual-axis chart(output/platinum_vs_ewz_YYYY-MM-DD.png)
  • Clearly annotate data limitations and assumptions </success_criteria>