# Commodity Volatility and Cross-Commodity Analysis Pipeline

import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

# 1. Load Excel data and metadata from World Bank Pink Sheet ('Monthly Prices').
# 2. Clean dates, treat '...' and '…' as missing, and construct wide and tidy price DataFrames.
# 3. Build commodity schema, inventory, and group classification (Energy, Metals, Agriculture, Softs, Fertilizers).
# 4. Compute log returns, volatility, and drawdown metrics by commodity.
# 5. Analyze static correlations and regime shifts across subperiods.
# 6. Compute rolling correlations and construct spillover networks using NetworkX.
# 7. Estimate volatility models (historical, EWMA, GARCH family) using the arch library.
# 8. Generate publication-grade visualizations (prices, returns, volatility, correlations, networks).
# 9. Export all tables and figures to the /mnt/z/B011/ directory.