quantPython 3.11+1 runtime dependency● CI passing

Adjoint Greeks, and the payoff where they lie.

A finite difference needs one revaluation per input. A reverse sweep produces every partial derivative at a constant multiple of the forward cost. This repo measures that claim, then measures the case where the derivative it returns is exactly zero and exactly wrong.

49×faster than bumped finite differences at 50 inputs
1.7–2.4×AAD cost over one pricing, flat across a 50× input range
5.6e-16relative error vs. closed-form Black-Scholes delta
100%error on a digital payoff, without smoothing
the cost claim

Flat against linear.

One arithmetic basket, 40,000 paths. As the asset count grows 50×, AAD's cost relative to one pricing stays between 1.7× and 2.4×. Bumping grows close to the 2n+1 its construction implies.

AAD / pricebump / price
0×25×50×75×100× 15102550 assets 103.1× 2.1×
Apple M-series, Python 3.13, numpy. Timings vary about ±10% run to run; the shape is the result, not the third significant figure. Reproduce with make bench.
the accuracy claim

Two ulps from the closed form.

The oracle is the textbook Black-Scholes formulas typed out by hand. It shares no code with the AD engine, which is the only reason agreement means anything. Finite differences have a sweet spot you can't know in advance. AAD has no bump to tune.

analytic  0.5987063256829237
AAD       0.5987063256829240
rel err   5.6e-16
Central-difference delta error as the bump shrinks
bump hrelative error
1e+011.16e-02
1e-011.21e-06
1e-031.13e-10 ← best
1e-064.64e-10
1e-081.48e-06
1e-101.14e-04
where it loses

On a digital option, pathwise AAD returns delta 0.000000. No NaN, no warning, no clue.

The payoff is a step function, so its derivative is zero almost everywhere and the reverse sweep faithfully propagates zero. The crude method this repo argues against gets it right to 0.1%. Smoothing into a call spread fixes it, and brings back a bias you now have to choose.

true delta 0.019333 · error
0true value 0.019333

the ledger

What this doesn't do.

Reproduce every number on this page
git clone https://github.com/asp53826/aad-greeks
cd aad-greeks && make test && make bench
More projects →