<essential_principles>
<principle name="ratio_decomposition">
**Core Formula for Ratio Decomposition**
The Mining Stock/Metal Price Ratio can be decomposed into four fundamental factors:
R_t ≈ K × M_t × (1-L_t) × C_t × D_t
Where:
- K: Calibration constant (estimated from observed values)
- M_t: Multiple factor (EV/EBITDA)
- (1-L_t): Leverage factor (1 - NetDebt/EV)
- C_t: Cost factor (1 - AISC/S_t)
- D_t: Dilution factor (Shares_base / Shares_t)
This decomposition provides quantifiable attributable explanations for "ratio changes".
</principle>
<principle name="aisc_extraction">
**AISC Extraction Priority Order**
All-In Sustaining Cost (AISC) is the core driver of mining stock valuation:
| Priority | Source | Method |
|---|
| 1 | MD&A / Financial Footnotes | Keyword extraction: "AISC", "all-in sustaining" |
| 2 | Annual Report Presentation PDF | Parse tables: $/oz or $/ounce |
| 3 | Proxy Calculation | (OpCost + SustCapex + G&A - Byproduct) / Oz |
When direct disclosure is unavailable, supplement with proxy calculation; record
to mark the source.
</principle>
<principle name="backsolve_logic">
**Backsolve Logic**
Objective: Given a target ratio R* (e.g., historical peak 1.7), back-calculate the required factor conditions.
Single-factor Backsolve: Assume other factors remain unchanged, adjust only one factor
M* = M_now × (R*/R_now) # Required multiple
(1-L*) = (1-L_now) × (R*/R_now) # Required deleveraging level
C* = C_now × (R*/R_now) # Required cost improvement → implied AISC*
D* = D_now × (R*/R_now) # Required dilution discount
Two-factor Combination: List feasible combinations in a grid (e.g., +20% multiple + -15% silver price).
</principle>
<principle name="event_study">
**Event Study Methodology**
Identify historical events where the ratio fell into the bottom quantile, and review the status of the four factors during those events:
- Did AISC rise?: Cost pressure
- Did NetDebt/EV deteriorate?: Leverage pressure
- Did EV/EBITDA compress?: Multiple pressure
- Did shares increase?: Dilution pressure
Rank "which factor contributed the most" to identify the main driver of the bottom.
</principle>
<principle name="data_priority">
**Data Source Priority Order**
Follow the "structured data first" principle:
- SEC XBRL (10-K/10-Q): Directly extract fields (debt, cash, share count, CFO, Capex)
- SEDAR+ (Canada): Silver mining companies are often listed in Canada
- Corporate IR Annual Reports/MD&A: Supplement non-standard fields such as AISC and production volume
- ETF Holdings: Official CSV or SEC N-PORT
Use Selenium to simulate human behavior during crawling to avoid being blocked.
</principle>
</essential_principles>
<objective>
Implement a fundamental back-calculation system for the "Mining Stock/Metal Price Ratio":
- Data Integration: Crawl price data, ETF holdings, financial statements, and operational disclosures
- Factor Calculation: Calculate the four core factors: AISC, leverage, multiple, and dilution
- Ratio Decomposition: Establish the approximation formula R_t ≈ K × M × (1-L) × C × D
- Threshold Backsolve: Given a target ratio, back-calculate the required factor combinations
- Event Study: Factor-driven analysis of historical bottom events
- Report Output: Structured JSON and human-readable Markdown
Target Users: Investors who want to verify the driving factors using "actual financial statements" when the SIL/silver ratio reaches extreme levels.
</objective>
<quick_start>
Fastest Way: Use Default Parameters for Analysis
bash
cd skills/backsolve-miner-vs-metal-ratio-with-fundamentals
pip install pandas numpy yfinance matplotlib # First-time use
python scripts/fundamental_analyzer.py --quick
Full Analysis (Including Financial Statement Crawling)
bash
python scripts/fundamental_analyzer.py \
--metal-symbol SI=F \
--miner-universe etf:SIL \
--region-profile us_sec \
--start-date 2015-01-01 \
--output result.json
Generate Visualization Dashboard
bash
python scripts/visualize_factors.py --quick --output output/
# Output: output/sil_silver_factor_analysis_YYYY-MM-DD.png
The visualization dashboard includes four panels:
- Ratio Time Series: Historical trend + quantile intervals (bottom/top)
- Factor Radar Chart: Overview of the health status of the four factors
- Factor Score Bar Chart: Scores for cost, leverage, multiple, and dilution
- Scenario Heatmap: Combination analysis of multiple expansion × silver price changes
Co-rise Scenario Simulation
bash
python scripts/scenario_path_simulator.py --quick --output output/
# Output: output/scenario_path_YYYY-MM-DD.png + return_heatmap_YYYY-MM-DD.png
Core Formula: Mining stock return = (1 + silver price return) × (R₁/R₀) - 1
Custom Parameters:
bash
python scripts/scenario_path_simulator.py \
--silver-monthly 5 \ # Silver price monthly return 5%
--ratio-start 1.10 \ # Ratio starting point
--ratio-end 1.20 \ # Ratio ending point
--months 6 \ # Simulate 6 months
--heatmap # Generate return heatmap simultaneously
Output Example:
json
{
"now": {
"metal_price": 94.4,
"miner_price": 103.4,
"ratio": 1.13,
"ratio_percentile": 0.111
},
"thresholds": {
"bottom_ratio": 1.20,
"top_ratio": 1.70,
"median_ratio": 1.51
},
"fundamentals_weighted": {
"aisc_usd_per_oz": 28.0,
"net_debt_to_ev": 0.25,
"ev_to_ebitda": 6.4,
"shares_yoy_change": 0.12
},
"factors_now": {
"cost_factor_C": 0.7034,
"leverage_factor_1_minus_L": 0.75,
"multiple_M": 6.4,
"dilution_discount_D": 0.89
},
"backsolve_to_top": {
"multiple_only_need": 9.1,
"deleverage_only_need_1_minus_L": 1.12,
"cost_only_implied_aisc": 15.6,
"dilution_only_need_D": 1.26
}
}
</quick_start>
<intake>
What operation do you need to perform?
- Quick Analysis - Calculate current factor status using default parameters (SIL / SI=F)
- Full Analysis - Crawl financial statements, calculate factors, back-calculate thresholds
- Factor Decomposition - Deep dive into the calculation logic of the four factors
- Threshold Backsolve - Given a target ratio, calculate the required factor combinations
- Event Study - Factor-driven ranking of historical bottom events
- Methodology Learning - Understand back-calculation logic and data sources
- Visualization - Generate four-panel dashboard charts
- Co-rise Scenario - Simulate the proportional relationship and path of simultaneous rise in silver price and mining stocks
Please select or provide analysis parameters directly.
</intake>
<routing>
| Response | Action |
|--------------------------------|----------------------------------------------------------------|
| 1, "快速", "quick", "分析" | Execute `python scripts/fundamental_analyzer.py --quick` |
| 2, "完整", "full", "財報" | Read `workflows/analyze.md` and execute |
| 3, "因子", "factor", "拆解" | Read `references/fundamental-factors.md` |
| 4, "反推", "backsolve", "門檻" | Read `references/backsolve-math.md` and execute back-solve analysis |
| 5, "事件", "event", "底部" | Read `workflows/analyze.md` and focus on event study |
| 6, "學習", "方法論", "why" | Read `references/fundamental-factors.md` + `backsolve-math.md` |
| 7, "視覺化", "圖", "chart" | Execute `python scripts/visualize_factors.py --quick` |
| 8, "共同上漲", "情境", "路徑" | Execute `python scripts/scenario_path_simulator.py --quick` |
| "比例關係", "漲幅", "要漲多少" | Execute `python scripts/scenario_path_simulator.py --quick` |
| Provide parameters (e.g., ETF/metal proxy) | Read `workflows/analyze.md` and execute with the specified parameters |
After routing, read the corresponding file and execute.
</routing>
<directory_structure>
backsolve-miner-vs-metal-ratio-with-fundamentals/
├── SKILL.md # This file (router)
├── skill.yaml # Frontend display metadata
├── manifest.json # Skill metadata
├── workflows/
│ ├── analyze.md # Full analysis workflow
│ └── data-fetch.md # Data crawling workflow
├── references/
│ ├── input-schema.md # Complete input parameter definition
│ ├── data-sources.md # Data source description
│ ├── fundamental-factors.md # Calculation logic of the four factors
│ └── backsolve-math.md # Backsolve mathematical formulas
├── templates/
│ ├── output-json.md # JSON output template
│ └── output-markdown.md # Markdown report template
├── scripts/
│ ├── fundamental_analyzer.py # Main calculation script
│ ├── visualize_factors.py # Visualization dashboard script
│ └── scenario_path_simulator.py # Co-rise scenario simulator
└── examples/
└── sample-output.json # Sample output
</directory_structure>
<reference_index>
Input Parameters: references/input-schema.md
- Complete parameter definitions
- Default values and recommended ranges
- Description of each method option
Data Sources: references/data-sources.md
- Price data (yfinance / stooq / alphavantage)
- Financial statement data (SEC EDGAR / SEDAR+ / corporate IR)
- ETF holdings (official CSV / N-PORT / manual URL)
Factor Calculation: references/fundamental-factors.md
- AISC cost factor
- Leverage factor
- Multiple factor
- Dilution factor
Backsolve Mathematics: references/backsolve-math.md
- Single-factor backsolve formulas
- Two-factor combination grid
- Calibration constant estimation
</reference_index>
<workflows_index>
| Workflow | Purpose | Usage Scenario |
|---|
| analyze.md | Full analysis | Need to crawl financial statements and calculate factors |
| data-fetch.md | Data crawling | Understand how to crawl ETF holdings and financial statements |
| </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 |
|---|
| fundamental_analyzer.py | | Quick analysis of SIL/SI=F |
| fundamental_analyzer.py | --miner-universe etf:SILJ
| Custom mining stock ETF |
| fundamental_analyzer.py | | Specify target ratio for backsolve |
| fundamental_analyzer.py | --event-study --min-separation 180
| Execute event study |
| visualize_factors.py | | Generate four-panel visualization dashboard |
| visualize_factors.py | | Generate charts from JSON results |
| scenario_path_simulator.py | | Co-rise scenario path simulation |
| scenario_path_simulator.py | --silver-monthly 5 --months 6
| Custom silver monthly return and simulation months |
| scenario_path_simulator.py | --ratio-start 1.10 --ratio-end 1.20
| Custom ratio start and end points |
| scenario_path_simulator.py | | Generate return heatmap simultaneously |
| </scripts_index> | | |
<input_schema_summary>
Core Parameters
| Parameter | Type | Default Value | Description |
|---|
| metal_symbol | string | SI=F | Metal price ticker (SI=F for silver, GC=F for gold) |
| miner_universe | object | etf:SIL | Mining stock/ETF definition |
| region_profile | string | us_sec | Regulatory and disclosure source (us_sec / canada_sedar) |
| time_range.start | string | 5 years ago | Analysis start date (YYYY-MM-DD) |
| time_range.end | string | today | Analysis end date |
| time_range.frequency | string | weekly | Sampling frequency (daily/weekly/monthly) |
Factor Method Selection
| Parameter | Type | Default Value | Description |
|---|
| fundamental_methods.aisc | string | hybrid | AISC extraction method |
| fundamental_methods.leverage | string | net_debt_to_ev | Leverage calculation method |
| fundamental_methods.multiple | string | ev_to_ebitda | Multiple calculation method |
| fundamental_methods.dilution | string | weighted_avg_shares | Dilution calculation method |
Quantile Thresholds
| Parameter | Type | Default Value | Description |
|---|
| ratio_thresholds.bottom | float | 0.20 | Bottom quantile threshold |
| ratio_thresholds.top | float | 0.80 | Top quantile threshold |
Complete parameter definitions can be found in
references/input-schema.md
.
</input_schema_summary>
<output_schema_summary>
json
{
"skill": "backsolve_miner_vs_metal_ratio_with_fundamentals",
"inputs": {
"metal_symbol": "SI=F",
"miner_universe": {"type": "etf_holdings", "etf_ticker": "SIL"},
"region_profile": "us_sec"
},
"now": {
"metal_price": 94.4,
"miner_price": 103.4,
"ratio": 1.13,
"ratio_percentile": 0.111
},
"thresholds": {
"bottom_ratio": 1.20,
"top_ratio": 1.70,
"median_ratio": 1.51
},
"fundamentals_weighted": {
"aisc_usd_per_oz": 28.0,
"net_debt_to_ev": 0.25,
"ev_to_ebitda": 6.4,
"shares_yoy_change": 0.12
},
"factors_now": {
"cost_factor_C": 0.7034,
"leverage_factor_1_minus_L": 0.75,
"multiple_M": 6.4,
"dilution_discount_D": 0.89
},
"backsolve_to_top": {
"multiple_only_need": 9.1,
"deleverage_only_need_1_minus_L": 1.12,
"cost_only_implied_aisc": 15.6,
"dilution_only_need_D": 1.26,
"two_factor_grid_examples": [
{"multiple_up": 1.20, "metal_down": -0.15, "hits_top": true},
{"deleverage": -0.10, "multiple_up": 1.15, "hits_top": true}
]
},
"event_study": {
"bottom_events": [
{
"date": "2026-01-02",
"ratio": 1.13,
"aisc": 29.1,
"net_debt_to_ev": 0.27,
"ev_to_ebitda": 5.8,
"shares_yoy": 0.14,
"dominant_driver": "multiple_compression"
}
]
},
"summary": "The ratio is at a historical bottom, mainly driven by multiple compression...",
"notes": [
"AISC was calculated using hybrid method, some values are proxy estimates for certain companies",
"Recommended cross-validation: COT positions, ETF flows, USD/real interest rates"
]
}
Complete output structure can be found in
.
</output_schema_summary>
<success_criteria>
When execution is successful, the following should be produced: