Module sabr
Expand description
SABR implied volatilities and the at-the-money α solve that lets a surface be parameterised by the ATM vol a desk quotes.
The model is dF = α̂(F + s)^β dW₁, dα̂ = να̂ dW₂, dW₁dW₂ = ρ dt, under
the forward’s own measure. Three readings of its implied vol:
SabrFormula::HaganLognormal— eq. 2.17a: a Black vol ofF + sstruck atK + s.SabrFormula::HaganNormal— eq. B.69a: a Bachelier vol, forward and strike shifted bys.SabrFormula::NormalBetaZero— eq. B.59a with a constant local vol:α·ζ/x(ζ)·(1 + (2 − 3ρ²)ν²τ/24),ζ = (ν/α)(F − K). Defined at any forward and strike, negative ones included; β and the shift are not read.
Stability. Every expression is generic in the AD scalar and stays exact where the closed form is 0/0 or cancels:
- at the money
z/x(z)is its Taylor series1 − ρz/2 + (2 − 3ρ²)z²/12 + (5ρ − 6ρ³)z³/24(from the Legendre series of1/√(1 − 2ρu + u²), exact through third order, soJet2is exact there), andln(F/K)isln_1p((F − K)/K); x(z)is taken asln_1pof its excess over one, with√B − 1written(z² − 2ρz)/(√B + 1); forz < 0, where√B + z − ρcancels, in its conjugate formln[(1 + ρ)/(√B − z + ρ)](the identityB − (z − ρ)² = 1 − ρ²), so no branch takes the log of a cancelled sum;- a vol the expansion’s correction takes to zero or below is refused, not floored: a floored branch is one an adjoint would differentiate silently.
Argument order is (α, β, ρ, ν) throughout helixio; a fixture stated in another order maps it explicitly.
Structs§
- Sabr
Params - The SABR parameters a smile is read at.
Enums§
- Sabr
Error - SABR inputs the formulas cannot evaluate.
- Sabr
Formula - Which expansion of the SABR implied vol is read.
Constants§
- RHO_
BOUND - The largest
|ρ|admitted: at±1the mapx(z)is singular. - SMALL_Z 🔒
- Below this
|z|the ratioz/x(z)is its Taylor series throughz³. Its truncation isO(z⁴)and the closed form’s own round-offO(ε/z); both are under 1e-12 at the switch.
Functions§
- alpha_
from_ atm - The α that reproduces
atm_volatforward: the smallest positive real root of the ATM cubic, polished by Newton on passive values, then carried into the mode by two Newton steps on the cubic with its coefficients in the mode — exact derivatives to second order (the implicit function theorem, without differentiating a root search). - atm_
cubic 🔒 - The ATM cubic
c₁α³ + c₂α² + c₃α + c₄(West 2005) whose root is the α that reproducesatm_volatforward—σ_ATM(α)multiplied through by the ATM factor. Coefficients in the mode. - check 🔒
- cubic_
at 🔒 - log_
moneyness 🔒 ln(f/k)for positivef,k, asln_1p((f − k)/k).- pow 🔒
x^efor positivex.- real_
roots 🔒 - The real roots of
a x³ + b x² + c x + d, degenerating to the quadratic and linear cases when the leading coefficients vanish. - sabr_
vol - The SABR implied vol of
strikeatforwardandexpiry_yearsunderformula. - z_
over_ 🔒x z / x(z),x(z) = ln[(√(1 − 2ρz + z²) + z − ρ)/(1 − ρ)], stable at everyz: its Taylor series near zero, the conjugate form forz < 0.