SuperAPI AI Directory

detect-palladium-lead-silver-turns

Data & analytics

View repository

Updated 10-16 06:06

About this skill

<essential_principles>

The hypothesis that "palladium leads silver" requires quantifiable verification:

  • Use cross-correlation to estimate the optimal lead-lag
  • When silver shows a turning point, check whether palladium first or simultaneously shows a same-direction turning point within the confirmation window
  • Unconfirmed turning points are treated as candidates for "failed pushes"
Lead-Lag = argmax(cross_correlation(pd_ret[t-k:t], ag_ret[t:t+k]))
Confirmed = pd_turn exists within [ag_turn.ts - window, ag_turn.ts + window]
Method Principle Applicable scenarios
pivot Local extrema within N bars to the left and right Trends with clear structure
peaks scipy find_peaks + prominence Automated density control
slope_change Trend slope changes from positive to negative or vice versa Smoothed trend tracking

It is recommended to start from pivot with 3-5 bars on each side, then adjust as needed.

There are multiple ways to measure whether palladium "participates" in silver's moves:

Indicator Definition Suggested threshold
returns_corr Rolling correlation coefficient of returns > 0.5
direction_agree Proportion of same-direction rises and falls > 60%
vol_expansion Both volatilities expand in sync σ_pd / σ_ag > 0.8
breakout_confirm When silver breaks out, palladium also breaks out Same-direction breakout

When the threshold is not met, silver's move may be "liquidity noise" rather than trend confirmation.

Turn "silver moves without palladium participation" into backtestable rules:

Rule Definition Consequence
no_confirm_then_revert No confirmation + silver retraces past the starting point within N bars Mark as failed_move
no_confirm_then_break_fail No confirmation + after silver breaks out, it falls back below the breakout point False breakout

Historical statistics: failure rate of unconfirmed events vs. success rate of confirmed events.

</essential_principles>

  1. Data acquisition: OHLCV for silver and palladium (yfinance: SI=F, PA=F)
  2. Turning point detection: identify local highs and lows of both (pivot / peaks / slope_change)
  3. Lead-lag estimation: use cross-correlation to find the optimal lag
  4. Cross-metal confirmation: whether silver's turning point is confirmed by a same-direction palladium turning point within the window
  5. Failed move determination: whether unconfirmed silver turning points meet the failure rules

Output: confirmation rate, failure rate, detailed determination for each event, and risk control recommendations.

<quick_start>

The fastest way: detect whether silver's recent turning points are confirmed by palladium

cd skills/detect-palladium-lead-silver-turns
pip install pandas numpy yfinance scipy statsmodels  # 首次使用
python scripts/palladium_lead_silver.py --silver SI=F --palladium PA=F --quick

Example output:

{
  "symbol_pair": {"silver": "SI=F", "palladium": "PA=F"},
  "as_of": "2026-01-14",
  "timeframe": "1h",
  "estimated_pd_leads_by_bars": 6,
  "lead_lag_corr": 0.42,
  "confirmation_rate": 0.71,
  "unconfirmed_failure_rate": 0.64,
  "latest_event": {
    "ts": "2026-01-15T14:00:00Z",
    "turn": "top",
    "confirmed": false,
    "participation_ok": false,
    "failed_move": true
  }
}

Full analysis:

python scripts/palladium_lead_silver.py --silver SI=F --palladium PA=F --timeframe 1h --lookback 1000 --output result.json

Generate Bloomberg-style visualization charts(recommended):

pip install matplotlib yfinance  # 首次使用
python scripts/plot_bloomberg_style.py --input result.json --output output/palladium_silver_2026-01-26.png

Chart features:

  • Bloomberg professional color scheme: dark background, orange-red silver line, orange-yellow palladium line
  • Background color band markers: green background = confirmed turning point area, red background = unconfirmed turning point area (does not block the trend lines)
  • Latest event annotation: prominently mark the confirmation status and price of the latest turning point
  • Pd/Ag price ratio chart: shows the relative price change of palladium versus silver, including a 20-period moving average
  • Rolling confirmation rate: dynamically shows the effectiveness trend of the confirmation logic
  • Statistics Dashboard: Key metrics such as confirmation rate, failure rate, total number of pivots
  • Market Interpretation: Current state assessment and actionable recommendations

Traditional Three-in-One Chart(Technical Analysis-oriented):

python scripts/plot_palladium_silver.py --silver SI=F --palladium PA=F --output output/

Includes:

  • Silver/Palladium price overlay with pivot markers
  • Confirmed/Unconfirmed event distribution
  • Rolling correlation coefficient time series
  • Failed trend statistics

</quick_start>

  1. Quick Detection - Check whether the most recent silver pivot is confirmed by palladium
  2. Historical Backtest - Retrospectively analyze the effectiveness of cross-metal confirmation
  3. Continuous Monitoring - Set alerts to notify when a new pivot appears
  4. Parameter Tuning - Find the optimal confirmation window and participation threshold
  5. Methodology Learning - Understand the theoretical basis of cross-metal lead-lag

Please select or directly provide analysis parameters to begin.

After routing, read the corresponding document and execute.

<directory_structure>

detect-palladium-lead-silver-turns/
├── SKILL.md                           # 本文件(路由器)
├── skill.yaml                         # 前端展示元數據
├── manifest.json                      # 技能元數據
├── workflows/
│   ├── detect.md                      # 單次偵測工作流
│   ├── backtest.md                    # 歷史回測工作流
│   └── monitor.md                     # 持續監控工作流
├── references/
│   ├── methodology.md                 # 跨金屬領先滯後方法論
│   ├── input-schema.md                # 完整輸入參數定義
│   └── data-sources.md                # 資料來源說明
├── templates/
│   ├── output-json.md                 # JSON 輸出模板
│   └── output-markdown.md             # Markdown 報告模板
├── scripts/
│   ├── palladium_lead_silver.py       # 主偵測腳本
│   ├── plot_bloomberg_style.py        # Bloomberg 風格視覺化(推薦)
│   └── plot_palladium_silver.py       # 傳統三合一圖表
└── examples/
    └── silver-palladium-2024.json     # 範例輸出

</directory_structure>

<reference_index>

Methodology: references/methodology.md

  • Cross-Metal Lead-Lag Principles
  • Detailed Explanation of the Three Pivot Detection Methods
  • Participation and Confirmation Logic
  • Market Implications of Failed Trends

Data Sources: references/data-sources.md

  • Yahoo Finance Futures Symbols
  • Macro Filter Data Sources
  • Data Frequency and Alignment

Input Parameters: references/input-schema.md

  • Complete Parameter Definitions
  • Default Values and Recommended Ranges

</reference_index>

<workflows_index>

Workflow Purpose When to Use
detect.md Single Detection Check a specific time range
backtest.md Historical Backtest Validate the effectiveness of the confirmation logic
monitor.md Continuous Monitoring Daily tracking or alerts
</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
palladium_lead_silver.py --silver SI=F --palladium PA=F --quick Quickly check the current status
palladium_lead_silver.py --silver SI=F --palladium PA=F --lookback 1000 Complete historical analysis
plot_bloomberg_style.py --input result.json --output output/chart.png Bloomberg-style chart (recommended)
plot_palladium_silver.py --silver SI=F --palladium PA=F --output dir/ Traditional Three-in-One Chart
</scripts_index>

<input_schema_summary>

Core Parameters

Parameter Type Default Value Description
silver_symbol string (required) Silver instrument symbol
palladium_symbol string (required) Palladium instrument symbol
timeframe string 1h Analysis timeframe
lookback_bars int 1000 Number of bars to look back

Pivot Detection Parameters

Parameter Type Default Value Description
turn_method string pivot Pivot detection method
pivot_left int 3 Number of confirmation bars on the left side of the pivot
pivot_right int 3 Number of confirmation bars on the right side of the pivot
confirm_window_bars int 6 Cross-metal confirmation window
lead_lag_max_bars int 24 Maximum lag in bars for lead-lag

Participation Parameters

Parameter Type Default Value Description
participation_metric string direction_agree Participation measurement method
participation_threshold float 0.6 Participation threshold
failure_rule string no_confirm_then_revert Failed trend rules

See for complete parameter definitions references/input-schema.md。

</input_schema_summary>

<output_schema_summary>

{
  "skill": "detect-palladium-lead-silver-turns",
  "symbol_pair": {"silver": "SI=F", "palladium": "PA=F"},
  "as_of": "2026-01-14",
  "timeframe": "1h",
  "lookback_bars": 1200,
  "summary": {
    "estimated_pd_leads_by_bars": 6,
    "lead_lag_corr": 0.42,
    "confirmation_rate": 0.71,
    "unconfirmed_failure_rate": 0.64,
    "total_ag_turns": 24,
    "confirmed_turns": 17,
    "failed_moves": 5
  },
  "events": [
    {
      "ts": "2026-01-08T10:00:00Z",
      "turn": "bottom",
      "confirmed": true,
      "confirmation_lag_bars": -3,
      "participation_ok": true,
      "failed_move": false
    }
  ],
  "interpretation": {
    "regime_assessment": "...",
    "tactics": ["...", "..."]
  }
}

See for the complete output structure templates/output-json.md。 </output_schema_summary>

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

  • Best lead-lag estimate of palladium versus silver (bars)
  • Correlation coefficient of the lead-lag
  • Confirmation rate of silver turning points confirmed by palladium
  • Proportion of failed trends among unconfirmed events
  • Detailed assessment of each silver turning point (confirmed, participation, failed)
  • Market interpretation and tactical recommendations
  • Time series data (optional, for visualization)
  • Visualization chart PNG (optional, using plot_palladium_silver.py) </success_criteria>