TICKETS 03 OF 3 RUNS LEFTACC --
OUTCRY

← Guide BookPlay it

Finance Lab

Delta Defender

Write a hedgeRatio function that tracks a short call's true Black-Scholes delta across a fresh random scenario and GBM price path every run.

How it works

You are short one call option, and instead of adjusting a hedge by hand you write the rule: a JavaScript function hedgeRatio(S, K, T, r, sigma, tick) returning the fraction of a share to hold per option, from 0 to 1. Every run, the game draws a fresh scenario - strike fixed at 100, initial moneyness between 0.85 and 1.15, expiry from 2 to 20 trading days, volatility from 20% to 55%, rate 2% - then simulates a real geometric Brownian motion price path over 40 ticks and calls your function at every tick with the live inputs.

At each tick the game computes the true Black-Scholes delta of the call and compares it to your returned hedge ratio. Your net delta is your hedge minus the true delta; a tick counts as hedged when its absolute value is within 0.12. A playback screen shows the needle of your net delta tick by tick, with your hedge and the true delta side by side, before the final result.

Because the scenario and the path are re-randomized every run, a hard-coded constant or a formula tuned to one strike, expiry, or vol level will not survive the next click - the submission has to be a genuine formula in the inputs. A reference implementation (Black-Scholes delta via the normal CDF) can be revealed in the editor, and if your code throws, the run reports the crash and returns you to the editor.

How scoring works

There is no points total. A run is a win when your function stays within the 0.12 net-delta tolerance on at least 70% of the 40 ticks. The result screen reports your percentage of hedged ticks, your average absolute net delta, and a benchmark: the fraction of ticks a static 0.5 hedge would have been within tolerance on the exact same path - the bar a real rule needs to clear.

Delta is N(d1) - and why that shape matters

For a European call under Black-Scholes, delta equals N(d1), the standard normal CDF evaluated at d1 = (ln(S/K) + (r + sigma^2/2)T) / (sigma * sqrt(T)). Intuitively, delta is close to a (risk-adjusted) probability that the option finishes in the money: deep out-of-the-money calls hedge near 0, deep in-the-money near 1, and at-the-money near 0.5 (slightly above, because of the +sigma^2/2 drift term).

The winning submission simply computes this. You need a normal CDF - the reference code uses the Abramowitz-Stegun polynomial approximation, accurate to about 7.5e-8, and you can write the same five-coefficient formula in a few lines. Handle the T = 0 edge exactly as the engine does: at expiry the hedge is 1 if S > K, else 0.

The reason delta is the hedge at all: a short call loses value at rate delta per dollar of stock rally, so holding delta shares of stock cancels the first-order exposure. That is a Taylor-expansion statement - it kills the linear term in the P&L, leaving the second-order (gamma) and time (theta) terms, which is why the losing banner reads 'gamma got you'.

Gamma intuition: where a hedge goes stale fastest

Gamma is the rate of change of delta with the stock price - phi(d1) / (S * sigma * sqrt(T)) in Black-Scholes. It is largest at the money and explodes as expiry approaches, because a small move near the strike flips the option between 'basically stock' and 'basically nothing'. That is exactly where any fixed or sluggish hedge drifts out of the 0.12 tolerance the fastest.

This explains the static-0.5 benchmark's behaviour. On a short-dated at-the-money run that wanders around the strike, delta hovers near 0.5 and the constant hedge can look respectable. On any run that starts 10% away from the strike, or trends away from it, true delta pins toward 0 or 1 and the constant hedge fails almost every tick. Your formula wins by re-centering every tick as S, and T through the tick index, change.

If you want to go beyond the plain formula, gamma tells you where precision matters: near the strike with days left, delta moves several hundredths per dollar of stock, so any lag or coarse rounding in your rule burns tolerance there. Far from the strike, delta is flat and almost anything within reach of 0 or 1 stays hedged.

Mental delta checkpoints for the interview version

Quant interviews often ask for delta without a calculator, and a few anchors cover most cases. At the money: delta is approximately 0.5 plus a small correction, roughly 0.5 + 0.2 * sigma * sqrt(T) for low rates - for 20% vol and one month, about 0.52. The moneyness scale that matters is ln(S/K) measured in units of sigma * sqrt(T): one such standard deviation in the money puts delta near N(1), about 0.84; one out puts it near N(-1), about 0.16.

Time and vol enter only through sigma * sqrt(T). Halving time to expiry shrinks the standard-deviation yardstick by sqrt(2), which pushes deltas away from 0.5 for any option not exactly at the strike - short-dated options polarize. Raising vol does the opposite: it drags every delta toward the middle, because more uncertainty makes both finishes plausible.

You can sanity-check your function against the engine's own verified reference point: S = 100, K = 100, T = 1, r = 0.05, sigma = 0.2 gives price about 10.45 and delta about 0.637. If your normCDF and d1 reproduce that, the formula is right and the game becomes a formality.

A worked example

Suppose a run draws: 100-strike call, 10 days to expiry (T = 10/252 = 0.0397 years), sigma = 0.30, r = 0.02, and the path currently has S = 104 at tick 12. Compute d1: ln(104/100) = 0.0392; (r + sigma^2/2)T = (0.02 + 0.045) x 0.0397 = 0.00258; numerator = 0.0418. Denominator = 0.30 x sqrt(0.0397) = 0.0598. So d1 = 0.70, and delta = N(0.70) = 0.758.

Your function returns 0.758; if the true engine delta at that tick is 0.758, net delta is 0 - hedged. Compare the static benchmark: |0.5 - 0.758| = 0.258, more than double the 0.12 tolerance, so the constant hedger is unhedged at this tick and at every tick the stock stays a couple of dollars above the strike.

Now let the path rally to S = 112 by tick 35, with T down to about 0.005 years. The yardstick sigma * sqrt(T) is only 0.021, and ln(112/100) = 0.113 is more than 5 of those units - d1 is huge and delta is essentially 1.0. A correct formula glides to 1 automatically; anything that ignores T or S is now off by up to half a share. That is the whole game: the formula, evaluated fresh at each tick, is the strategy.

Common mistakes

Hard-coding a number or tuning to one scenario. The strike, expiry, vol, and path change every run by design - only a genuine function of the inputs survives.

Forgetting the T = 0 (or tiny T) edge case. d1 divides by sigma * sqrt(T); at expiry return the intrinsic hedge, 1 if S > K else 0, as the engine itself does.

Using ln(S/K) without the (r + sigma^2/2)T term, or putting sigma^2/2 with the wrong sign. Small formula errors matter most exactly where gamma is high - near the strike, close to expiry.

Returning values outside 0 to 1 or crashing on edge inputs. A crash aborts the run; an out-of-range hedge is simply a bad hedge.

Judging your rule only on runs it wins. Check the average absolute net delta and the static-0.5 benchmark - a good formula should beat the benchmark on paths far from the strike, where the constant hedge collapses.

Why interviews test this

'Walk me through delta hedging' is a staple of options-desk and quant-trading interviews, and this game is the honest version of it: not reciting that delta is N(d1), but producing a rule that holds up as spot, time, and vol move. Follow-ups you should expect map directly onto the playback screen - why the hedge bleeds near the strike into expiry (gamma), what you are paid for rebalancing (theta versus gamma P&L), and what happens to delta when vol rises (it pulls toward 0.5).

The coding format also mirrors modern quant interviews, where you implement Black-Scholes or a normal CDF live. Being able to write d1, handle the expiry edge case, and sanity-check against a known value (S=100, K=100, T=1, r=0.05, sigma=0.2 gives delta about 0.637) is a compact, demonstrable skill.

Play Delta Defender · All game guides · The arcade