SuperAPI AI Directory

analyze-copper-stock-resilience-dependency

General & other

View repository

Updated 10-15 21:41

About this skill

<essential_principles>

Whether copper prices break through key levels or back-and-fill is not determined solely by copper itself, but depends heavily on equity resilience:

銅價走勢 = f(技術面關卡狀態) × f(股市韌性) × f(中國利率環境)

Key insights:

  • When equity resilience is high: the probability of copper "continuing" after breaking through a key level is higher
  • When equity resilience is low: copper is more likely to experience a "back-and-fill" pullback to the support zone
  • China 10Y yield: serves as a two-sided signal of risk pressure/policy easing

Copper's important psychological round numbers (such as 10,000 / 13,000 USD/ton) are key to judging breakouts and back-and-fills:

State Condition Meaning
up close > SMA(60) and slope is positive Uptrend
down close < SMA(60) and slope is negative Downtrend
range Other Range-bound consolidation

Key-level determination:

  • near_resistance: approaching the upper key level
  • near_support: approaching lower support

Quantify "equity resilience" into a calculable score:

Factor Weight Calculation method
12-month momentum 40% 12m return percentile (vs history)
Moving average position 40% Whether it is above the 12-month moving average (yes=100, no=0)
Recent drawdown 20% The smaller the drawdown over the past 3m, the better (reverse scoring)

Score interpretation:

  • 70-100: high resilience, higher probability of copper continuing after breaking through a key level
  • 30-70: neutral, other factors need to be observed
  • 0-30: low resilience, back-and-fill risk rises significantly

Calculate the rolling beta coefficient of copper prices to equities and China yields:

Δcopper ~ β1 × Δequity + β2 × Δchina_yield + ε
  • The larger and more positive β1 (equity beta): the more copper resembles a risk asset and the more it depends on equities
  • β1 high percentile: the market is currently trading copper together as a risk asset
  • β1 < 0 (negative correlation): copper decouples from equities, showing independent logic (haven/supply/energy transition narrative)
  • β2 (yield beta): positive = rising yields are bullish for copper (inflation narrative), negative = the opposite

This skill uses the following public data sources:

Data Code/Source Method of retrieval
Copper futures price COMEX Copper (HG=F) Yahoo Finance
Global equity market capitalization VT (Vanguard Total World Stock ETF) Yahoo Finance
China 10Y yield MacroMicro Selenium + Highcharts

Unit conversion:

  • HG=F is $/lb, automatically multiplied by 2204.62262 to convert to $/ton
  • VT ETF price is multiplied by a coefficient to convert to an estimate of global market capitalization (trillion USD)
  • China 10Y is a percentage (%)

</essential_principles>

  1. Data retrieval: fetch copper prices, global equities, and China 10Y yield
  2. Trend and key-level determination: calculate SMA, trend state, and which key level is nearby
  3. Equity resilience score: calculate equity_resilience_score
  4. Quantification of dependencies: rolling regression to calculate β coefficients
  5. Back-and-fill probability estimation: historical statistical back-and-fill frequency (high resilience vs low resilience)
  6. Scenario Assessment: Output whether the current scenario is "continuation" or "back-and-fill"

Output: current state, dependency strength, back-and-fill probability, actionable alert flag.

<quick_start>

Fastest way: run the default analysis

cd skills/analyze-copper-stock-resilience-dependency
pip install pandas numpy yfinance scipy statsmodels matplotlib  # 首次使用
python scripts/copper_stock_analyzer.py --quick

Output example:

{
  "as_of": "2026-01-22",
  "latest_state": {
    "copper_price_usd_per_ton": 12727,
    "copper_trend": "up",
    "equity_resilience_score": 83,
    "rolling_beta_equity_24m": -0.80
  },
  "diagnosis": {
    "narrative": "銅價上升趨勢中,接近 13,000 關卡,股市韌性高檔。"
  }
}

Generate Bloomberg-style charts:

python scripts/visualize.py \
  --start 2015-01-01 \
  -o output/copper_resilience_2026-01-22.png

The charts include:

  • Copper monthly chart + SMA60 (right axis, orange-red/yellow)
  • Global stock market capitalization (left axis, orange area chart)
  • China 10Y yield (left axis, yellow line)
  • Threshold lines (10,000 / 13,000)

Generate dependency analysis charts(three-panel composite chart):

python scripts/plot_dependency_analysis.py \
  --start 2015-01-01 \
  -o ../../output/copper-dependency-analysis-2026-01-22.png

The charts include three panels:

  1. Copper price panel: Copper price + SMA60 + trend background color (green=rising, red=falling) + threshold lines
  2. β coefficient panel: Rolling β time series + ±1σ interval + current percentile + negative value warning
  3. Resilience panel: Stock market resilience score + high/low threshold lines

Full analysis:

python scripts/copper_stock_analyzer.py \
  --start 2015-01-01 \
  --end 2026-01-22 \
  --copper HG=F \
  --equity ACWI \
  --output result.json

</quick_start>

  1. Quick check - View the current copper price, stock market resilience, and threshold status
  2. Full analysis - Analyze the dependency relationship and back-and-fill probability within a time range
  3. Visualization charts - Generate visualization charts of copper prices and dependency factors
  4. Dependency analysis chart - Generate a three-panel dependency analysis chart (copper price + β coefficient + resilience)
  5. Methodology learning - Understand the logic of the cross-asset dependency model

Please select or directly provide analysis parameters.

After routing, read the corresponding file and execute.

<directory_structure>

analyze-copper-stock-resilience-dependency/
├── SKILL.md                           # 本文件(路由器)
├── skill.yaml                         # 前端展示元數據
├── manifest.json                      # 技能元數據
├── workflows/
│   ├── analyze.md                     # 完整分析工作流
│   ├── quick-check.md                 # 快速檢查工作流
│   └── visualize.md                   # 視覺化工作流
├── references/
│   ├── methodology.md                 # 跨資產依賴方法論
│   ├── data-sources.md                # 數據來源與爬蟲說明
│   └── input-schema.md                # 完整輸入參數定義
├── templates/
│   ├── output-json.md                 # JSON 輸出模板
│   └── output-markdown.md             # Markdown 報告模板
├── scripts/
│   ├── copper_stock_analyzer.py       # 主分析腳本
│   ├── fetch_data.py                  # 數據抓取工具
│   ├── visualize.py                   # Bloomberg 風格圖表
│   └── plot_dependency_analysis.py    # 三面板依賴度分析圖表
├── data/
│   └── cache/                         # 數據快取目錄
└── examples/
    └── sample-output.json             # 範例輸出

</directory_structure>

<reference_index>

Methodology: references/methodology.md

  • Comparison of cross-asset dependency concepts and research reports
  • Stock market resilience score design
  • Rolling regression and beta interpretation
  • Back-and-fill determination logic

Data sources: references/data-sources.md

  • Yahoo Finance (yfinance) usage instructions
  • China 10Y yield scraper design
  • Data frequency and alignment methods

Input parameters: references/input-schema.md

  • Complete parameter definitions
  • Default values and recommended ranges

</reference_index>

<workflows_index>

Workflow Purpose When to use
analyze.md Full analysis Need detailed dependency relationships and back-and-fill analysis
quick-check.md Quick check Only want to see the current state
visualize.md Generate visualization charts Need chart presentation
</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
copper_stock_analyzer.py --quick Quick check of the current state
copper_stock_analyzer.py --start DATE --end DATE Full analysis
fetch_data.py --series HG=F,ACWI Fetch market data
visualize.py --start 2015-01-01 -o output/chart.png Generate Bloomberg-style charts
plot_dependency_analysis.py --start 2015-01-01 -o output/chart.png Generate a three-panel dependency analysis chart
</scripts_index>

<input_schema_summary>

Core parameters

Parameter Type Default value Description
start_date string 2020-01-01 Analysis start date
end_date string today Analysis end date
freq string 1mo Frequency (monthly)
copper_series string HG=F Copper price series ticker
equity_proxy_series string ACWI Stock market proxy series
china_10y_yield_series string Scrape China 10Y yield

Model parameters

Parameter Type Default value Description
ma_window int 60 Moving average window
rolling_window int 24 Rolling regression window (months)
round_levels list [10000, 13000] Level position
backfill_max_drawdown float 0.25 Maximum retracement magnitude

For complete parameter definitions, see references/input-schema.md。

</input_schema_summary>

<output_schema_summary>

{
  "skill": "analyze-copper-stock-resilience-dependency",
  "as_of": "2026-01-22",
  "inputs": {
    "copper_series": "HG=F (converted to USD/ton)",
    "equity_proxy_series": "ACWI",
    "ma_window": 60,
    "rolling_window": 24
  },
  "latest_state": {
    "copper_price_usd_per_ton": 12727,
    "copper_sma_60": 9355,
    "copper_trend": "up",
    "near_resistance_levels": [13000],
    "near_support_levels": [],
    "equity_resilience_score": 91,
    "rolling_beta_equity_24m": -0.80,
    "rolling_beta_yield_24m": -0.05
  },
  "diagnosis": {
    "narrative": "銅價上升趨勢中,接近 13,000 關卡,股市韌性高檔。",
    "scenario": "續航機率較高",
    "dependency_status": "滾動 β 為負值 (-0.80),銅與股市呈反向關係,脫離傳統風險資產模式"
  },
  "actionable_flags": [
    {
      "flag": "APPROACHING_RESISTANCE",
      "meaning": "接近重要阻力位,關注能否突破"
    },
    {
      "flag": "NEGATIVE_BETA_REGIME",
      "meaning": "銅與股市呈反向關係,脫離傳統風險資產模式"
    },
    {
      "flag": "LOW_BETA_ANOMALY",
      "meaning": "β 處於歷史極端低位,銅正展現獨立於股市的上漲邏輯"
    }
  ]
}

For the complete output structure, see templates/output-json.md。 </output_schema_summary>

<success_criteria> On successful execution, the following should be produced:

  • Current copper price and trend state (up/down/range)
  • Nearby level position (resistance/support)
  • Stock market resilience score (0-100)
  • Rolling beta coefficients (β_equity, β_yield)
  • Retracement probability estimates (overall / high_resilience / low_resilience)
  • Scenario interpretation narrative
  • Actionable alert flags
  • Visualization charts (optional, output to output/ directory) </success_criteria>