Controls
Presets
Parameters
Quality
Camera
Model checks
The science
The idea. A producer who owns Q units of a commodity fears a price fall. Selling futures offsets spot losses only to the extent that spot and futures prices move together. Over the hedge horizon let the spot change be dS and the futures change dF, with standard deviations σS, σF and correlation ρ. Selling h futures per unit of exposure leaves the P&L per unit dS - h dF.
Minimum-variance hedge. Var(h) = σS² + h²σF² - 2hρσSσF is a parabola in h with its minimum at h* = ρσS/σF, which is exactly the slope of the regression of dS on dF (Johnson 1960, Stein 1961, Ederington 1979). There Var(h*) = σS²(1 - ρ²), so the hedge removes a fraction ρ² of the variance (hedge effectiveness = the R² of that regression). What is left is basis risk. A naive 1:1 hedge leaves extra variance (h* - 1)²σF². Futures trade in whole contracts, so the position is round(h*Q/contract size); the parabola is symmetric about h*, so the nearest integer is the best.
Simplifications. Spot and futures changes are jointly normal with constant parameters (real hedge ratios are estimated with error and drift, and are better fitted with GARCH or error-correction models), the horizon is a single period, margin calls, funding cost, roll-over, convexity and transaction costs are ignored, and the volatilities in the presets are illustrative, not estimates for a specific market. Checks: Monte Carlo variance versus the closed form; sampled regression slope versus h*; an independent structural generator dS = h*dF + ε for effectiveness = ρ² and the 1:1 basis variance; and a brute-force search over whole contract counts. Sampling checks use 4.5 standard errors.