Function calibrate_smoothed
pub fn calibrate_smoothed(
reference: NaiveDate,
discount: Option<&Curve>,
rungs: &[Rung],
fixings: &FixingStore,
fx: &FxRates,
tolerance: Tolerance,
scheme: Interpolation,
smoothness: f64,
) -> Result<SmoothedCalibration, CalibrationError>Expand description
Fits a discount curve to a ladder globally under scheme, minimising
the rung quote residuals together with smoothness times the squared
second divided difference of the log discount factor at each interior
pillar.
The sequential solve reprices every rung exactly and lets the pillar
ordinates carry whatever the quotes imply, noise included — under
log-linear interpolation that noise is a jump in the piecewise-flat
forward at every pillar, and the penalty is exactly that jump; under a
spline the curve is already smooth between pillars and the penalty
keeps the pillars themselves from zig-zagging. This fit trades a little
repricing for less roughness, and reports both. Each rung contributes
its repriced quote less its declared quote — a par rate, a spread, a price
per unit — so the residuals are in quote units and smoothness compares a
squared rate jump against a squared quote error; a priced rung’s units are
its price’s, and the fixture is a swap ladder.
Seeded from the sequential solve, which is the smoothness = 0 answer,
and solved by Levenberg–Marquardt from the core; the rung block of the
Jacobian is the same eight-lane forward-mode block the provenance Jacobian
uses, and the penalty rows are linear in the log discount factors. The
discount argument selects the form as calibrate and
calibrate_with do.
Any scheme that reports adjoints is accepted, because the rung block is the seeded forward-mode Jacobian under that scheme; a scheme declaring an adjoint refusal is refused with its own reason, since a fit through a frozen Jacobian would converge on nothing.
§Errors
CalibrationError::SmoothingScheme for a scheme that refuses adjoints;
CalibrationError::Malformed for a negative or non-finite smoothness;
the sequential solve’s errors from the seed;
CalibrationError::FitNotConverged or
CalibrationError::SingularJacobian from the fit.