monitor-etf-holdings-drawdown-risk

Original🇨🇳 Chinese
Translated
4 scriptsChecked / no sensitive code detected

Detect the divergence phenomenon where commodity prices rise but the holdings of corresponding physical ETFs/trusts decline, and use multi-indicator cross-validation to assess the risk of physical supply tightness/delivery pressure.

11installs
Added on

NPX Install

npx skill4agent add fatfingererr/macro-skills monitor-etf-holdings-drawdown-risk

SKILL.md Content (Chinese)

View Translation Comparison →
<essential_principles>
<principle name="divergence_core"> **Core Logic of Divergence Signals**
Definition of Divergence Event:
  • Price Rise:
    price_return >= min_price_return_pct
    (e.g., +15%)
  • Inventory Decline:
    inventory_change <= -min_inventory_drawdown_pct
    (e.g., -10%)
  • Concurrent Occurrence: Both conditions are met within the same window period (e.g., 180 days)
It is normal when prices and inventory move in the same direction (both rise or fall); vigilance is required only when they move in opposite directions (prices rise while inventory declines). </principle>
<principle name="dual_hypothesis"> **Dual Hypothesis Validation**
Do not directly interpret "inventory decline" as "physical hoarding"; cross-validation is required:
HypothesisSupporting ConditionsRefuting Conditions
Physical TightnessDecline in COMEX/LBMA inventories, backwardation, rising lease rates, widening retail premiumsStable other inventories, contango, stable premiums
Capital Flow/RedemptionETF outflows but stable exchange inventories, non-tight futures structureSynchronized decline in multiple inventories
Output both interpretations for users to judge which one better fits the current data. </principle>
<principle name="data_access"> **Data Acquisition Methods**
This skill prioritizes using:
  • ETF Official Website Inventory: Scraped using Selenium to simulate human browser behavior (to avoid API restrictions)
  • Yahoo Finance: Spot/futures prices obtained via the
    yfinance
    package
  • Cross-Validation: Public data such as COMEX inventories and futures structures
Scripts are located in the
scripts/
directory and follow the anti-detection strategy in
references/data-sources.md
. </principle>
<principle name="stress_scoring"> **Stress Score Calculation**
stress_score = 100 × min(1.0,
    0.6 × divergence_severity +      # Divergence severity
    0.2 × decade_low_bonus +         # Decade-low bonus
    0.2 × ratio_extreme_bonus        # Extreme ratio bonus
)
Score RangeInterpretation
0-30Normal, no obvious divergence
30-60Mild divergence, worthy of attention
60-80Moderate divergence, in-depth verification recommended
80-100Severe divergence, high alert
</principle>
</essential_principles>
<objective> Monitor the divergence between holdings of physical ETFs (e.g., SLV, PSLV, GLD) and commodity prices:
  1. Detect Divergence: Prices rise but ETF inventory declines
  2. Assess Severity: Calculate divergence degree, decade-low levels, and extreme ratios
  3. Cross-Validation: Use indicators such as COMEX data, futures structures, and retail premiums
  4. Generate Insights: Provide two opposing hypotheses to avoid single-narrative bias
Output: Divergence status, stress score, cross-validation results, and recommendations for next-step checks. </objective>
<quick_start>
Fastest Way: Check SLV Divergence Status
bash
cd skills/monitor-etf-holdings-drawdown-risk
pip install pandas numpy yfinance selenium webdriver-manager beautifulsoup4 matplotlib  # First-time use
python scripts/divergence_detector.py --etf SLV --quick
Sample Output:
json
{
  "asof": "2026-01-20",
  "divergence": false,
  "price_return_window": 1.92,
  "inventory_change_window": 0.15,
  "inventory_decade_low": false,
  "stress_score_0_100": 20.0,
  "interpretations": ["Physical Tightness", "ETF Flow Hypothesis"]
}
Full Analysis + Visualization Report:
bash
# 1. Execute divergence detection
python scripts/divergence_detector.py \
  --etf SLV \
  --start 2010-01-01 \
  --end 2026-01-20 \
  --output result.json

# 2. Generate visualization report
python scripts/visualize_divergence.py \
  --result result.json \
  --output ../../../output/
Output:
  • JSON analysis result:
    result.json
  • Visualization report:
    output/SLV_divergence_report_20260120.png
  • PDF report:
    output/SLV_divergence_report_20260120.pdf
</quick_start>
<intake> What operation do you need to perform?
  1. Quick Check - View the current divergence status and stress score of the specified ETF
  2. Full Analysis - Perform a complete historical divergence analysis
  3. Cross-Validation - Verify the authenticity of divergence signals using multiple indicators
  4. Monitoring Mode - Set up continuous monitoring and divergence alerts
  5. Methodology Learning - Understand divergence detection and dual hypothesis logic
Please select or directly provide analysis parameters (e.g., ETF ticker symbol). </intake>
<routing> | Response | Action | |---------------------------------|-----------------------------------------------| | 1, "快速", "quick", "check" | Execute `scripts/divergence_detector.py --quick` | | 2, "分析", "analyze", "full" | Read `workflows/analyze.md` and execute | | 3, "驗證", "validate", "cross" | Read `workflows/cross-validate.md` and execute| | 4, "監控", "monitor", "alert" | Read `workflows/monitor.md` and execute | | 5, "學習", "方法論", "why" | Read `references/methodology.md` | | Provide ETF ticker (e.g., SLV, GLD) | Read `workflows/analyze.md` and execute with parameters |
After routing, read the corresponding file and execute. </routing>
<directory_structure>
monitor-etf-holdings-drawdown-risk/
├── SKILL.md                           # This file (router)
├── skill.yaml                         # Frontend display metadata
├── manifest.json                      # Skill metadata
├── workflows/
│   ├── analyze.md                     # Full divergence analysis workflow
│   ├── monitor.md                     # Continuous monitoring workflow
│   └── cross-validate.md              # Cross-validation workflow
├── references/
│   ├── data-sources.md                # ETF inventory and price data sources
│   ├── methodology.md                 # Divergence detection methodology
│   └── input-schema.md                # Complete input parameter definition
├── templates/
│   ├── output-json.md                 # JSON output template
│   └── output-markdown.md             # Markdown report template
└── scripts/
    ├── divergence_detector.py         # Main detection script
    ├── fetch_etf_holdings.py          # ETF inventory scraping (Selenium)
    └── fetch_prices.py                # Commodity price scraping
</directory_structure>
<reference_index>
Methodology: references/methodology.md
  • Divergence detection logic
  • Dual hypothesis validation framework
  • Stress score calculation
Data Sources: references/data-sources.md
  • ETF official website inventory scraping (Selenium)
  • Yahoo Finance price data
  • Cross-validation data sources (COMEX, LBMA)
Input Parameters: references/input-schema.md
  • Complete parameter definition
  • Default values and recommended ranges
</reference_index>
<workflows_index>
WorkflowPurposeUsage Scenario
analyze.mdFull Divergence AnalysisWhen complete historical analysis is needed
monitor.mdContinuous Status MonitoringFor daily monitoring or alerts
cross-validate.mdCross-Validate Divergence SignalsWhen verifying the authenticity of divergence
</workflows_index>
<templates_index>
TemplatePurpose
output-json.mdJSON Output Structure Definition
output-markdown.mdMarkdown Report Template
</templates_index>
<scripts_index>
ScriptCommandPurpose
divergence_detector.py
--etf SLV --quick
Quick Divergence Status Check
divergence_detector.py
--start DATE --end DATE --output FILE
Complete Historical Analysis
visualize_divergence.py
--result result.json --output DIR
Generate Visualization Report
fetch_etf_holdings.py
--etf SLV --output holdings.csv
Scrape ETF Inventory
fetch_prices.py
--symbol SI=F --output prices.csv
Scrape Commodity Prices
</scripts_index>
<input_schema_summary>
Core Parameters
ParameterTypeDefault ValueDescription
etf_tickerstring(Required)ETF/trust ticker symbol (e.g., SLV)
commodity_price_symbolstring(Required)Commodity price symbol (e.g., XAGUSD)
start_datestring10 years agoAnalysis start date
end_datestringtodayAnalysis end date
Divergence Parameters
ParameterTypeDefaultDescription
divergence_window_daysint180Divergence calculation window (days)
decade_low_window_daysint3650Decade-low calculation window (days)
min_price_return_pctfloat0.15Price rise threshold
min_inventory_drawdown_pctfloat0.10Inventory decline threshold
Complete parameter definition can be found in
references/input-schema.md
.
</input_schema_summary>
<output_schema_summary>
json
{
  "skill": "monitor-etf-holdings-drawdown-risk",
  "asof": "2026-01-16",
  "inputs": {
    "etf_ticker": "SLV",
    "commodity_price_symbol": "XAGUSD"
  },
  "result": {
    "divergence": true,
    "price_return_window": 0.32,
    "inventory_change_window": -0.18,
    "inventory_decade_low": true,
    "inventory_to_price_ratio_z": -2.4,
    "stress_score_0_100": 78.5
  },
  "interpretations": [...],
  "next_checks": [...]
}
Complete output structure can be found in
templates/output-json.md
. </output_schema_summary>
<success_criteria> Upon successful execution, the following should be generated:
  • Divergence status determination (divergence: true/false)
  • Price change and inventory change values
  • Decade-low determination
  • Inventory/price ratio Z-score
  • Stress score (0-100)
  • Two opposing hypothesis interpretations
  • List of next-step verification recommendations </success_criteria>