Skip to main content
ClaudeWave
Skill12k repo starsupdated today

commodity-analysis

The commodity-analysis skill evaluates crude oil, gold, and copper using supply-demand dynamics, pricing models, inventory cycles, and futures structure to generate directional trading signals. Use this skill for backtesting commodity strategies that incorporate OPEC compliance, shale production, global PMI, real interest rates, dollar strength, safe-haven demand, and economic cycle indicators across energy, precious metals, and industrial commodities.

Install in Claude Code
Copy
git clone --depth 1 https://github.com/HKUDS/Vibe-Trading /tmp/commodity-analysis && cp -r /tmp/commodity-analysis/agent/src/skills/commodity-analysis ~/.claude/skills/commodity-analysis
Then start a new Claude Code session; the skill loads automatically.

SKILL.md

# Commodity Analysis

## Overview

Analyze commodities from four dimensions — supply-demand balance, pricing model, inventory cycle, and futures structure — and output directional signals suitable for backtesting. Focuses on crude oil (global pricing anchor), gold (safe haven + inflation hedge), and copper (economic barometer).

## Core Concepts

### 1. Crude Oil Supply-Demand Balance

**Key supply-side variables:**

| Variable | Data Source | Frequency | Direction of Impact |
|------|--------|------|---------|
| OPEC production | OPEC monthly report | Monthly | Production cuts → oil price ↑ |
| US shale output | EIA weekly report | Weekly | Higher output → oil price ↓ |
| Rig count (Baker Hughes) | Baker Hughes | Weekly | Leads production by 3-6 months |
| Strategic Petroleum Reserve (SPR) | EIA | Weekly | SPR release → short-term oil price ↓ |

**Key demand-side variables:**
- IEA global oil demand forecast (quarterly)
- China crude imports (customs monthly data)
- US gasoline demand (EIA weekly report, implied demand)
- Global PMI (leads demand by 1-2 months)

**Supply-demand balance signals:**

```python
# Simplified supply-demand judgment
if opec_compliance > 90% and us_rig_count_declining:
    supply_signal = "tight"  # bullish for oil
elif opec_compliance < 80% and us_production_rising:
    supply_signal = "loose"  # bearish for oil

if global_pmi > 50 and china_import_yoy > 5%:
    demand_signal = "strong"  # bullish for oil
elif global_pmi < 48 and china_import_yoy < 0:
    demand_signal = "weak"    # bearish for oil
```

### 2. Gold Pricing Framework

**Four-factor model:**

| Factor | Weight | Logic | Indicator |
|------|------|------|------|
| Real rates | 40% | Real rates ↓ → lower opportunity cost of holding gold → gold ↑ | 10Y TIPS yield |
| US dollar index | 25% | USD ↓ → gold becomes cheaper in pricing terms → gold ↑ | DXY |
| Safe-haven demand | 20% | Risk ↑ → safe-haven buying → gold ↑ | VIX + geopolitical risk index |
| Central-bank buying | 15% | Central-bank purchases → structural demand support | WGC quarterly report |

**Practical rules:**
- 10Y TIPS < 0%: strong support for gold (negative real rates mean negative holding cost)
- 10Y TIPS > 2%: pressure on gold (positive real rates reduce attractiveness)
- Correlation between DXY and gold is around -0.6, but not absolute (they both rose in 2022 due to safe-haven demand)
- Central-bank purchases >1000 tons / year (2022-2023 level): long-term structural bullish support

### 3. Dr. Copper as an Economic Predictor

**Copper as a leading indicator:**
- YoY copper-price change leads industrial production by about 2-3 months
- Copper / gold ratio is highly positively correlated with the US 10Y Treasury yield (`r > 0.7`)
- Copper breakout above the prior high confirms economic recovery

**Copper fundamental tracking:**

| Indicator | Data Source | Threshold |
|------|--------|------|
| LME copper inventory | LME daily report | <150k tons = tight |
| SHFE copper inventory | SHFE weekly report | WoW decline >10% = tight |
| Copper concentrate TC/RC | SMM | TC < $30/ton = tight mining supply |
| China copper imports | Customs monthly report | YoY growth >10% = strong demand |

### 4. Inventory Cycle Analysis

**Visible inventory vs hidden inventory:**
- Visible inventory: published by exchanges (LME / SHFE / COMEX), transparent and trackable
- Hidden inventory: bonded areas / trader warehouses, opaque but potentially larger
- The true turning point in prices is the turning point in total inventory

**Four inventory-cycle stages (using copper as example):**

```
Active restocking (price↑ volume↑) -> Passive restocking (price↓ volume↑) -> Active destocking (price↓ volume↓) -> Passive destocking (price↑ volume↓)
      mid bull market                 late bull market                 mid bear market                 late bear / early bull market
```

**Signal mapping:**

| Stage | Inventory Direction | Price Direction | Trading Signal |
|------|---------|---------|---------|
| Passive destocking | ↓ | ↑ | Long (best buying point) |
| Active restocking | ↑ | ↑ | Keep long positions |
| Passive restocking | ↑ | ↓ | Close longs (warning) |
| Active destocking | ↓ | ↓ | Short or stay neutral |

### 5. Futures Premium / Discount Structure

**Contango (futures > spot, normal market):**
- Supply is abundant, and the market prices in carrying costs (storage + funding)
- Roll yield is negative (`roll yield < 0`), unfavorable for long holders
- Deep contango (`far month - near month > 5%`) = severe oversupply

**Backwardation (futures < spot, inverted market):**
- Supply is tight, and spot premium reflects strong immediate demand
- Roll yield is positive (`roll yield > 0`), favorable for long holders
- Deep backwardation (`near month - far month > 3%`) = squeeze or extreme shortage

**Term-structure signal:**

```python
# Spread ratio = (front month - second month) / front month
spread_ratio = (front_month - second_month) / front_month

if spread_ratio > 0.02:    # backwardation > 2%
    signal = "strongly bullish"  # spot shortage
elif spread_ratio < -0.03: # contango > 3%
    signal = "bearish"           # oversupply
else:
    signal = "neutral"
```

### 6. Seasonality

**Oil seasonality:**
- March-May: refinery maintenance ends + summer inventory build → seasonal rise (ahead of the "driving season")
- September-October: hurricane season (Gulf of Mexico) → supply disruption → higher volatility
- November-December: heating-oil demand → stronger diesel crack spread

**Gold seasonality:**
- January-February: Lunar New Year + Indian wedding-season physical demand → relatively strong
- July-August: traditional soft season → relatively weak
- October-November: Diwali + Christmas restocking → relatively strong

**Copper seasonality:**
- March-April: China construction season starts → demand recovery
- June-July: off-season inventory buildup → pressure
- September-October: "Golden September, Silver October" → demand recovery

## Analysis Framewor
vibe-tradingSkill

Professional finance research toolkit — backtesting (7 engines + benchmark comparison panel), factor analysis, Alpha Zoo (452 pre-built alphas across qlib158/alpha101/gtja191/academic), options pricing, 77 finance skills, 29 multi-agent swarm teams, Trade Journal analyzer, and Shadow Account (extract → backtest → render) across 7 data sources (tushare, yfinance, okx, akshare, mootdx, ccxt, futu).

adr-hshareSkill

ADR/H-share/A-share cross-listing premium analysis — track pricing gaps between US-listed ADRs, HK-listed H-shares, and A-shares for arbitrage signals, dual-listing valuation, and delisting risk assessment.

akshareSkill

AKShare financial data aggregator (18k+ stars). Free, no API key. Covers A-shares, US, HK, futures, macro, forex. Primary fallback for tushare and yfinance.

alpha-zooSkill

Browse and bench the bundled alpha zoos — prebuilt cross-sectional factor libraries (Kakushadze 101, GTJA 191, Qlib 158, Fama-French / Carhart). Use when the user asks "which alphas exist", wants metadata on a named alpha, or wants to run IC/IR on a whole zoo over a universe.

ashare-pre-st-filterSkill

A 股 ST/*ST 风险预测框架 — 基于最新中报/三季报或业绩预告/快报,预测下一财年是否会因营收、利润、净资产、分红不达标而被风险警示,并将新浪监管处罚记录作为独立证据面纳入风险等级。仅适用于 A 股,不预测财务造假。

asset-allocationSkill

Asset allocation theory and optimizer usage — MPT / Black-Litterman / risk budgeting / all-weather strategy, including guides for 4 optimizers and rebalancing rules.

backtest-diagnoseSkill

Diagnose failed or underperforming backtests, locate the root cause, and fix the issue

behavioral-financeSkill

Behavioral finance applications: theories of overreaction and underreaction, behavioral explanations for momentum and reversal, investor sentiment cycles, cognitive-bias checklists, and debiasing quantitative strategies.