<essential_principles>
<principle name="cross_metal_confirmation">
**Core of Cross-Metal Confirmation**
The hypothesis of "Palladium leads Silver" requires quantifiable verification:
- Estimate the optimal lead-lag using cross-correlation
- When a turning point appears in silver, check if palladium has a同向 turning point leading or synchronously within the confirmation window
- Unconfirmed turning points are candidates for "failed moves"
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]
</principle>
<principle name="turning_point_detection">
**Three Methods for Turning Point Detection**
| Method | Principle | Applicable Scenario |
|---|
| Local extremum within N candlesticks on both sides | Trends with clear structure |
| scipy find_peaks + prominence | Automated density control |
| Trend slope reverses from positive to negative or vice versa | Smooth trend tracking |
It is recommended to start with
, using 3-5 candlesticks on each side, then adjust as needed.
</principle>
<principle name="participation_judgment">
**Participation Judgment**
There are multiple ways to measure whether palladium "participates" in silver's trend:
| Indicator | Definition | Recommended Threshold |
|---|
| Rolling correlation coefficient of returns | > 0.5 |
| Proportion of same-direction price movements | > 60% |
| Synchronized volatility expansion of both | σ_pd / σ_ag > 0.8 |
| Palladium also breaks out when silver breaks out | Same-direction breakout |
When thresholds are not met, silver's movements may be "liquidity noise" rather than trend confirmation.
</principle>
<principle name="failure_move_detection">
**Failed Trend Judgment**
Translate "silver movements without palladium participation" into backtestable rules:
| Rule | Definition | Consequence |
|---|
| No confirmation + silver retraces beyond the starting point within N candlesticks | Marked as failed_move |
no_confirm_then_break_fail
| No confirmation + silver breaks out then falls back below the breakout level | False breakout |
Historical statistics: Failure rate of unconfirmed events vs success rate of confirmed events.
</principle>
</essential_principles>
<objective>
Detect cross-metal turning points where "Palladium leads, Silver follows":
- Data Acquisition: OHLCV data of Silver and Palladium (yfinance: SI=F, PA=F)
- Turning Point Detection: Identify local highs and lows of both (pivot / peaks / slope_change)
- Lead-Lag Estimation: Find the optimal lag using cross-correlation
- Cross-Metal Confirmation: Check if silver's turning point is confirmed by a same-direction turning point of palladium within the window
- Failed Trend Judgment: Check if unconfirmed silver turning points meet the failure rules
Output: Confirmation rate, failure rate, detailed judgment of each event, risk control suggestions.
</objective>
<quick_start>
Quickest Way: Detect if recent silver turning points are confirmed by palladium
bash
cd skills/detect-palladium-lead-silver-turns
pip install pandas numpy yfinance scipy statsmodels # First-time use
python scripts/palladium_lead_silver.py --silver SI=F --palladium PA=F --quick
Output Example:
json
{
"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:
bash
python scripts/palladium_lead_silver.py --silver SI=F --palladium PA=F --timeframe 1h --lookback 1000 --output result.json
Generate Bloomberg-Style Visualization Chart (Recommended):
bash
pip install matplotlib yfinance # First-time use
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 Band Marking: Green background = Confirmed turning point area, Red background = Unconfirmed turning point area (does not block price lines)
- Latest Event Annotation: Prominently marks the confirmation status and price of the latest turning point
- Pd/Ag Price Ratio Chart: Shows relative price changes of palladium to silver, including 20-period moving average
- Rolling Confirmation Rate: Dynamically displays the validity trend of the confirmation logic
- Statistics Panel: Key indicators such as confirmation rate, failure rate, total number of turning points
- Market Interpretation: Current status assessment and actionable suggestions
Traditional Three-in-One Chart (Technical Analysis Oriented):
bash
python scripts/plot_palladium_silver.py --silver SI=F --palladium PA=F --output output/
Includes:
- Silver/Palladium price overlay with turning point markings
- Distribution of confirmed/unconfirmed events
- Time series of rolling correlation coefficient
- Failed trend statistics
</quick_start>
<intake>
What operation do you need to perform?
- Quick Detection - Check if the latest silver turning point is confirmed by palladium
- Historical Backtest - Backtest the effectiveness of cross-metal confirmation
- Continuous Monitoring - Set up alerts to notify when new turning points appear
- Parameter Tuning - Find the optimal confirmation window and participation thresholds
- Methodology Learning - Understand the theoretical basis of cross-metal lead-lag
Please select or directly provide analysis parameters to start.
</intake>
<routing>
| Response | Action |
|------------------------------------|--------------------------------------------------------|
| 1, "quick", "fast", "check" | Execute `python scripts/palladium_lead_silver.py --quick` |
| 2, "backtest", "history", "historical" | Read `workflows/backtest.md` and execute |
| 3, "monitor", "alert", "watch" | Read `workflows/monitor.md` and execute |
| 4, "optimize", "tune", "adjust" | Read the parameter tuning section in `workflows/detect.md` |
| 5, "learn", "methodology", "theory" | Read `references/methodology.md` |
| Provide parameters (e.g., timeframe, lookback) | Read `workflows/detect.md` and execute with parameters |
After routing, read the corresponding file and execute.
</routing>
<directory_structure>
detect-palladium-lead-silver-turns/
├── SKILL.md # This file (router)
├── skill.yaml # Frontend display metadata
├── manifest.json # Skill metadata
├── workflows/
│ ├── detect.md # One-time detection workflow
│ ├── backtest.md # Historical backtest workflow
│ └── monitor.md # Continuous monitoring workflow
├── references/
│ ├── methodology.md # Cross-metal lead-lag methodology
│ ├── input-schema.md # Complete input parameter definition
│ └── data-sources.md # Data source description
├── templates/
│ ├── output-json.md # JSON output structure definition
│ └── output-markdown.md # Markdown report template
├── scripts/
│ ├── palladium_lead_silver.py # Main detection script
│ ├── plot_bloomberg_style.py # Bloomberg-style visualization (Recommended)
│ └── plot_palladium_silver.py # Traditional three-in-one chart
└── examples/
└── silver-palladium-2024.json # Example output
</directory_structure>
<reference_index>
Methodology: references/methodology.md
- Cross-metal lead-lag principles
- Detailed explanation of three turning point detection methods
- Participation and confirmation logic
- Market implications of failed trends
Data Sources: references/data-sources.md
- Yahoo Finance futures codes
- 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 | Applicable Scenario |
|---|
| detect.md | One-time detection | Check specific time ranges |
| backtest.md | Historical backtest | Verify the validity of 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
| Quick check of 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 target code |
| palladium_symbol | string | (required) | Palladium target code |
| timeframe | string | 1h | Analysis time scale |
| lookback_bars | int | 1000 | Number of historical candlesticks to look back |
Turning Point Detection Parameters
| Parameter | Type | Default Value | Description |
|---|
| turn_method | string | pivot | Turning point detection method |
| pivot_left | int | 3 | Number of confirmation candlesticks on the left for pivot method |
| pivot_right | int | 3 | Number of confirmation candlesticks on the right for pivot method |
| confirm_window_bars | int | 6 | Cross-metal confirmation window |
| lead_lag_max_bars | int | 24 | Maximum number of lag candlesticks for lead-lag estimation |
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 rule |
Complete parameter definition can be found in
references/input-schema.md
.
</input_schema_summary>
<output_schema_summary>
json
{
"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": ["...", "..."]
}
}
Complete output structure can be found in
.
</output_schema_summary>
<success_criteria>
Successful execution should produce: