Skip to main content

Tolerance

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: f64

Residual 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: f64

Newton step below which the parameter is taken as converged, in log-discount-factor space.

§max_iterations: usize

Iterations allowed per pillar before reporting no convergence.

§max_backtracks: usize

How 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: usize

How 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.

Trait Implementations§

§

impl Clone for Tolerance

§

fn clone(&self) -> Tolerance

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Copy for Tolerance

§

impl Debug for Tolerance

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Default for Tolerance

§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.