Module sabr
Expand description
SABR calibration from a grid rate smile: one slice per smiled (expiry, tenor) node, and the record each fit keeps so its parameter risk can be read back onto the quotes that built it.
Per slice. The quoted vols at the node’s strikes (absolute, or the
forward plus each spread on a spread cube) are restated in the formula’s
convention where the grid’s differs, by repricing at the slice forward.
Where the grid quotes the forward itself (a zero spread, or an absolute
strike at the forward) that quote is σ_ATM and only ρ and ν are
fitted; otherwise σ_ATM is fitted with them. Levenberg–Marquardt runs over
smooth bijections — ρ = 0.9999·tanh(x), ν = softplus(y),
σ_ATM = softplus(w) — on vega-weighted vol residuals, its Jacobian seeded
through Jet1. It starts from a three-point explicit guess read off
Hagan’s small-moneyness expansion (a quadratic in log-moneyness through the
three strikes nearest the forward, solved for ρ and ν), and restarts from a
deterministic Halton sequence until a fit is accepted or the restart budget
is spent.
The quote Jacobian is the implicit function theorem on the converged slice’s first-order condition — never a derivative of the optimiser. It keeps the residual-curvature term and the weights’ own dependence on the quotes, so it is exact off a perfect fit.
Structs§
- Fitted
Node 🔒 - One fitted cube node: its diagnostics, its parameters, its rows against the cube’s quotes, and its response to a σ_ATM held from an ATM matrix.
- Quote
Ref 🔒 - One grid quote a fit read: its node, and its strike coordinate on the grid’s own axis — none for an ATM matrix, which quotes no smile.
- SabrFit
- A fitted surface and its slices.
- Sabr
FitRecord - What a fitted SABR surface keeps of its calibration: per node, the quotes it was fitted to and the Jacobian of its parameters with respect to them.
- Sabr
Slice Fit - One fitted slice’s parameters and quality.
- Sabr
Slice Record - One node’s fit: which grid quotes its parameters depend on, and
d(σ_ATM, ρ, ν)/d(quote)for each. - Sabr
Spec - How a grid smile is fitted to SABR.
- Slice 🔒
- One slice’s market data in the formula’s convention.
Enums§
- Atm 🔒
- Where a slice’s σ_ATM comes from.
- Sabr
Calibration Error - A grid that could not be fitted.
Constants§
- BUTTERFLY_
STRIKES 🔒 - Strikes on the butterfly check grid.
- HALTON_
SEED 🔒 - Halton restarts start this far into the sequence — the conventional seed.
- RHO_
SCALE 🔒 ρ = RHO_SCALE·tanh(x)keeps ρ inside the formulas’ bound.
Functions§
- bachelier_
implied_ 🔒vol - A Bachelier vol implying the undiscounted Bachelier call
price, by bisection on its monotone vega. - calibrate_
sabr - Fits SABR to every (expiry, tenor) node of the smiled
grid, each slice at its forward —forwards[expiry][tenor], one row per grid expiry and one value per grid tenor. A slice whose grid quotes the forward itself holds σ_ATM at that quote; any other fits it with ρ and ν. - calibrate_
sabr_ with_ atm - Fits SABR on a dense ATM matrix with a sparse smile cube. σ_ATM comes from
atmat every one of its nodes; ρ and ν are fitted at the cube’s nodes with σ_ATM held at the matrix’s quote there, and read onto the matrix’s nodes bilinearly, flat beyond the cube’s edges — the surface’s own read rule. The surface lives on the matrix’s nodes; its fit record maps each node onto the matrix quotes and the cube quotes its parameters depend on. - caplet_
forwards - The caplet expiries and forwards on
marketof the cap onindexfromeffectivetotermination— the capletsstrip_caplet_volsstrips, filtered as its nodes are (one per caplet still to fix, a repeated expiry dropped), so the rows line up with the surface it strips. The forwards come one per row, the shapecalibrate_sabrreads off a one-tenor cap surface. - check_
shape 🔒 - Checks
forwardshas one row per expiry and one value per tenor. - fit_
cube 🔒 - Fits every node of the smiled
cube, σ_ATM held whereheldgives one. - radical_
inverse 🔒 - The radical inverse of
indexinbase— one Halton coordinate. - restate 🔒
- A quote in convention
fromrestated in the spec’s, by repricing a call at the slice forward — the lognormal side read at the spec’s shift — and the restatement’s slope in the quote: the ratio of the two vegas, since the price is held. - restate_
matrix 🔒 - An ATM matrix’s quotes restated in the spec’s convention at their forwards, node order, each with its restatement’s slope.
- softplus 🔒
- softplus_
inverse 🔒 - softplus_
jet 🔒 - swaption_
forwards - The forward swap rate at each (expiry, tenor): the par rate on
marketof the swaptemplatedrafts startingexpiryafter spot and runningtenor— the underlying a European swaption on that node exercises into. One row per expiry, one value per tenor: the shapecalibrate_sabrreads. - vega_of 🔒
- The undiscounted vega of a call at
volquoted inconvention— the lognormal side read atshift— in modeR.