Describe your exposure
Upload price history
A CSV with a date column and one price column per asset — monthly, weekly or daily levels all work. Or start from the illustrative sample already loaded below.
Current hedge ratio — rolling
The number to actually trade on: β re-estimated on only the most recent window of data, the same way the backtest below re-estimates it at every step. This is the one figure to quote in class or in a workbook — never the full-sample average further down, which blends regimes that may no longer apply.
Full-sample regression — diagnostic only
Fitted across every period uploaded. Useful for reading the overall relationship and drawing the scatter below — not the number to size a live hedge with, since it averages across whatever regimes the data happened to contain.
—
Price-change relationship — full sample
Out-of-sample backtest: hedged vs. unhedged
Three ways to turn the hedge ratio into an algorithm
Build a hedge gives you one hedge ratio at one point in time. An algo decides, period after period, whether to re-estimate it, how far to trust it, and — in one variant — whether to trade the gap it leaves behind. All three strategies share the same rolling-regression engine from the Build tab; they differ only in the decision rule layered on top.
Runs on whatever dataset and exposure are set in Build a hedge — load the sample above (it also resets Step 1's exposure to a 20,000,000-gallon short/consumer position and contract size to 42,000 gallons, 1,000 bbl), or configure your own there first. Currently loaded: —
Pick a strategy
How it works
The engine re-estimates β on the rolling window every single period, but it only applies the fresh number — actually resizes the hedge — when one of two triggers fires:
Whichever trigger fires, the fresh β is applied as-is — no blending (that's Strategy 3). This strategy never takes a view on direction; it only ever asks whether the hedge is still the right size. The volatility-spike trigger is Strategy 3's addition on top of this same clock-and-drift logic — it doesn't apply here.
How it works
Underneath, Strategy 1's hedge still runs unchanged. On top of it, this overlay z-scores the basis — the hedge residual, i.e. how far the actual relationship sits from what the rolling regression predicts this period — against its own recent mean and standard deviation, and trades the gap as a separate, small position:
At most one overlay position is open at a time. This is the one strategy here making an active call on where prices go next — everything else on this page is pure risk management.
How it works
Same rebalancing clock as Strategy 1 (plus the volatility override), but it adds one more question before applying a fresh β: how well is the proxy working right now? That's read off the rolling regression's own R², sorting every period into one of three confidence bands:
On a strong, stable proxy this strategy will often look identical to Strategy 1 — there's nothing to shrink away from. That's expected, not a bug: load a weaker cross-hedge pair in Build a hedge and switch back here to see the two strategies actually diverge.
Strategy settings
Shared — every strategy's rebalancing clock
Overlay — basis mean reversion
Regime bands — by rolling R²
Results
Cumulative P&L: unhedged vs. static hedge vs. strategy
Signal / rebalance log
Every period the strategy acted — rebalanced the hedge, opened or closed an overlay, or (strategy 3) switched regime. Most recent first, capped at 60 rows.
What a "Contracts" number above would mean as a real order
Everything on this page is a paper backtest — it never touches a real market. Worth walking through what the gap between this model and an actual trade looks like, before anyone mistakes the log above for a trading signal.
Why you sometimes have to hedge with the wrong asset
Most exposures a firm actually carries — jet fuel, a regional crude grade, a basket of inputs — don't have a liquid futures market of their own. Cross-hedging is what you do instead: hedge the exposure you have with the closest instrument that actually trades.
The problem
A consumer or producer has a real exposure to an asset's price. If that asset trades on an exchange, hedging is direct: take the opposite futures position, one-for-one. If it doesn't — no market, or a market too thin to move real size through — you need a proxy: a correlated, liquid instrument that moves with your exposure most of the time.
The catch
A proxy is never a perfect substitute. The two prices can drift apart — this is basis risk. Cross-hedging doesn't eliminate risk; it trades price risk on an untradeable asset for a smaller, more measurable risk: the gap between the proxy and the real exposure.
Finding the right hedge ratio
You don't hedge one-for-one with a proxy — you hedge in the ratio that has historically minimized the variance of your combined position. That ratio, h*, is:
This is algebraically identical to the slope β of a simple regression of the asset's price changes on the hedge instrument's price changes — which is how this tool actually computes it. Regress instead of computing ρ, σS, σF separately and you get the same number with one calculation.
Sizing the position
Once you have h*, convert it into an actual number of futures contracts:
Basis risk: direct hedge vs. cross-hedge
Basis risk is whatever risk survives after you've applied the optimal hedge ratio — R² (hedge effectiveness) is a direct read on how much of it is left. It shows up very differently depending on what you're hedging with, which the two real samples loaded in the Build tab make concrete:
The general rule: basis risk isn't something a better hedge ratio fixes — h* is already the best available ratio. Basis risk is a ceiling set by how strong the relationship is in the first place. A direct hedge starts with a low ceiling almost by construction; a cross-hedge's ceiling depends entirely on the economics linking the two assets, which is exactly why R² is worth checking before trusting one.
Why hedge ratios drift
Correlation between an asset and its proxy is not constant — supply shocks, storage bottlenecks and demand shifts can decouple them for months or years at a time. Split your history into a high-correlation and a low-correlation stretch and re-run the regression on each; a hedge ratio that moves a lot between the two is telling you the relationship itself is unstable, and that basis risk is larger than a single full-sample number would suggest.
Why backtest out-of-sample
Fitting β on the whole sample and then testing the hedge on that same sample flatters the result — you're using information you wouldn't have had in real time. A proper backtest re-estimates β on a trailing window and applies it only to the period right after that window, then rolls forward. What's left is a fair read on how much variance the hedge would actually have removed.
Worked mini example
This is a classic textbook illustration, kept because the numbers are clean enough to follow by hand — it isn't one of the loadable samples in the Build tab. For a worked example using the real data this tool ships with, see the R² ≈ 94% vs. R² ≈ 9% comparison above.
- An airline has a short exposure of 20,000,000 gallons of jet fuel — it will need to buy fuel over the coming months and loses if the price rises.
- Jet fuel isn't liquidly traded, but WTI crude futures are. Regressing monthly jet fuel price changes ($/gallon) on monthly WTI price changes ($/gallon-equivalent) over the last few years gives β ≈ 1.02, R² ≈ 0.85.
- Contract size for the WTI proxy is 42,000 gallons (1,000 barrels). N* = −(−20,000,000) × 1.02 ÷ 42,000 ≈ 486 contracts, long.
- Because the exposure is short (needs to buy), the hedger's rule says go long futures — buying 486 WTI contracts now locks in most of the airline's fuel-cost risk, leaving only the basis risk between jet fuel and WTI.
Quick glossary
- Basis risk
- The risk that the proxy and the real exposure don't move together exactly, so the hedge is imperfect even after sizing it correctly.
- Minimum-variance hedge ratio
- The hedge ratio that minimizes the variance of the combined (exposure + hedge) position, given historical price behavior.
- Hedge effectiveness (R²)
- The share of the asset's price-change variance that the hedge instrument's price changes explain — a rough read on how much risk the hedge actually removes.
- Walk-forward backtest
- A backtest that only ever uses data from before the period being tested, avoiding lookahead bias.