-- Table for ICE Coal Futures data
CREATE TABLE IF NOT EXISTS dm_ice_futures (
    id INT AUTO_INCREMENT PRIMARY KEY,
    trade_date DATE NOT NULL,
    symbol VARCHAR(20) NOT NULL,
    contract_month VARCHAR(10) NOT NULL,
    expiry_date DATE,
    open_price DECIMAL(10,2),
    high_price DECIMAL(10,2),
    low_price DECIMAL(10,2),
    settle_price DECIMAL(10,2),
    change_value DECIMAL(10,2),
    change_percent DECIMAL(8,4),
    volume INT,
    open_interest INT,
    currency VARCHAR(5) DEFAULT 'USD',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
    
    UNIQUE KEY unique_trade_symbol (trade_date, symbol, contract_month),
    KEY idx_trade_date (trade_date),
    KEY idx_symbol (symbol),
    KEY idx_contract_month (contract_month),
    KEY idx_settle_price (settle_price)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
COMMENT='ICE Coal Futures (API2 Rotterdam) - daily market data';