Struct Tolerance
pub struct Tolerance {
pub residual: f64,
pub step: f64,
pub max_iterations: usize,
pub max_backtracks: usize,
pub max_sweeps: usize,
}Expand description
How hard the solver tries.
Two criteria, because a residual alone is not scale-free. A residual is
in the instrument’s own money, so the pillar solve reads it against the
rung’s money_scale — the notional a CDS upfront rung
carries in money_per_quote, one for the unit-notional par rungs the
templates build — and residual is a tolerance per unit of that scale.
Even so scaled it can be asked below what the pricing arithmetic can
express, so the step criterion is the backstop: it is on the unknown
itself, a log discount factor (or hazard, or index level) of order one,
and is meaningful whatever the notional.
A pillar is solved when either holds: the residual is small against the rung’s money scale, or the Newton step has stopped moving the parameter.
Fields§
§residual: f64Residual below which a pillar is solved, per unit of the rung’s
money_scale. The default, 1e-12, leaves a
template ladder’s par quote reading back to about the quote’s own
last digit, where 1e-8 left par rates off by 1e-10 — visible in
any P&L explain that reprices the rungs.
step: f64Newton step below which the parameter is taken as converged, in log-discount-factor space.
max_iterations: usizeIterations allowed per pillar before reporting no convergence.
max_backtracks: usizeHow many times a single Newton step may be halved when the full step would make the residual worse.
The pillar solve has no bracket to fall back into, so this is its only defence against a step that lands where the objective is exponentially wrong — the failure a curve with a bending short end produces.
max_sweeps: usizeHow many full-curve sweeps the fit may take before giving up.
Separate from max_iterations, which bounds a single pillar’s Newton
solve, because under a global scheme these are different budgets: the
sweeps are the fit, and a fit needing more passes says nothing about
any one pillar needing more steps. Conflating them meant a caller who
wanted to bound the fit starved the Newton solves first.