Expand description
Adjoint Algorithmic Differentiation (AAD): tape-based reverse-mode differentiation for pricing code.
Write a pricer over Var instead of f64 — the operator
overloading records every operation on a Tape — and one backward
sweep (Var::grad) returns the sensitivity of the output to
every input at once, at a fixed small multiple of the pricing
cost. That is the AAD trade against bump-and-reprice: bumping costs
one full reprice per input, the adjoint sweep costs ~one reprice
total, however many inputs there are — the difference between
seconds and hours on a book with per-pillar curve and surface
sensitivities.
Two worked and tested quant applications live in this module’s tests:
black_scholes: the closed form written overVar; a single sweep produces delta, dual delta, rho, carry rho, vega and the maturity sensitivity simultaneously, matching the library’s closed-form Greeks to near machine precision;- pathwise Monte Carlo Greeks: differentiate through the simulation itself (one small tape per path), giving delta, vega and rho from the same paths that price — the standard pathwise estimator, validated against the closed forms.
The max(x, 0) payoff kink is handled by the almost-everywhere
derivative (Var::maxf), which is exactly the classical pathwise
estimator’s requirement (fine for vanillas and smooth-density
payoffs; digitals need smoothing or likelihood-ratio methods).
Re-exports§
Modules§
- tape
- The AAD tape (Wengert list) and the backward sweep.
- var
- The differentiable value type:
Varrecords every operation on the tape via operator overloading, so pricing code written overVarlooks like ordinary arithmetic.
Functions§
- black_
scholes - Black-Scholes price recorded on the tape: differentiate to get every first-order Greek from one backward sweep.