Enum Curve
#[non_exhaustive]pub enum Curve {
Piecewise(PiecewiseDiscount),
Step(StepForward),
Flat(FlatForward),
NelsonSiegel(NelsonSiegel),
Svensson(Svensson),
ExponentialSplines(ExponentialSplines),
FlatSpread(FlatSpread),
PiecewiseSpread(PiecewiseSpread),
RepoSpread(RepoSpread),
Shocked(Shocked),
Rebased(Rebased),
FxImplied(FxImplied),
}Expand description
A stored discount curve. Passive parameters, no AD state.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Piecewise(PiecewiseDiscount)
Dated log-discount-factor pillars, log-linear between them.
Step(StepForward)
Pillars carrying meeting and turn identity.
Flat(FlatForward)
One rate under one convention; no free parameters.
NelsonSiegel(NelsonSiegel)
A Nelson-Siegel shape: four free parameters, no pillars.
A smoother, not a repricer — it will not reproduce the quotes it was fitted to, by design. Reach for a pillar family when exactness matters.
Svensson(Svensson)
A Svensson shape: six free parameters, nesting Nelson-Siegel.
ExponentialSplines(ExponentialSplines)
An exponential-splines shape: a normalised basis of decaying
exponentials, N + 1 free parameters.
Alone among these it does not guarantee positive decreasing discount factors, so a fit of it is checked before it is returned.
FlatSpread(FlatSpread)
A constant spread, as a curve in its own right.
PiecewiseSpread(PiecewiseSpread)
A dated spread whose pillars are free parameters.
RepoSpread(RepoSpread)
A repo spread: simple spreads a desk marks, additive over a base the market declares — composed only when a repo key is resolved.
Shocked(Shocked)
A base under a named scenario perturbation.
Rebased(Rebased)
A base read forward from a later reference date.
FxImplied(FxImplied)
A foreign curve implied by FX forwards over a base funding curve.
Implementations§
§impl Curve
impl Curve
pub fn flat(
reference: NaiveDate,
rate: f64,
day_count: DayCountFraction,
) -> Result<Self, CurveError>
pub fn flat( reference: NaiveDate, rate: f64, day_count: DayCountFraction, ) -> Result<Self, CurveError>
A flat curve: one continuously compounded zero rate on day_count,
anchored at reference, its discount factor exp(−rate · t) with t
measured on day_count — the Rust spelling of Python’s
DiscountCurve.flat. FlatForward::new
takes the full convention, for simple or periodic compounding.
§Errors
As FlatForward::new: a non-finite
rate.
pub fn from_zero_rates(
reference: NaiveDate,
nodes: &[(NaiveDate, f64)],
day_count: DayCountFraction,
) -> Result<Self, CurveError>
pub fn from_zero_rates( reference: NaiveDate, nodes: &[(NaiveDate, f64)], day_count: DayCountFraction, ) -> Result<Self, CurveError>
A curve stated as continuously compounded zero rates on day_count,
read linearly in the zero rate between nodes. Each node’s discount factor is
exp(−r · t), t on day_count from reference.
A node on reference states the rate the first segment starts
from (AnchoredLinearZero); without one the first node’s rate holds
flat back to reference (LinearZero). The reading is linear in
ACT/365 fixed time, which is linear in day_count’s time for every
ACT/x count, and exact at the nodes for any count.
§Errors
CurveError::Malformed for a node before reference, dates not
strictly increasing, no node after reference,
or a non-finite rate.
pub fn with_zero_spread(
self,
spread: f64,
day_count: DayCountFraction,
) -> Result<Self, CurveError>
pub fn with_zero_spread( self, spread: f64, day_count: DayCountFraction, ) -> Result<Self, CurveError>
This curve under a flat continuously compounded zero spread on
day_count, measured from its own reference: DF(t) = DF(t)·exp(−s·τ).
A Shocked transform over a
flat curve, labelled zero_spread.
§Errors
CurveError for a non-finite spread.
pub fn with_spread(self, spread: Curve) -> Result<Self, CurveError>
pub fn with_spread(self, spread: Curve) -> Result<Self, CurveError>
This curve’s discount factors times spread’s, a Shocked
transform labelled spread. With a zero-rate curve as spread it adds
that curve’s zero rates on its day count; with_zero_spread is the flat case.
§Errors
CurveError::Malformed if spread is anchored on another date.
pub fn rebased(self, reference: NaiveDate) -> Result<Self, CurveError>
pub fn rebased(self, reference: NaiveDate) -> Result<Self, CurveError>
This curve read forward from reference: its discount factor over its
own there, a Rebased transform.
§Errors
CurveError::Malformed for a reference before this curve’s own.
pub fn node_dates(&self) -> Vec<NaiveDate>
pub fn node_dates(&self) -> Vec<NaiveDate>
Every date this curve’s forward can change at: the pillars of each dated leaf it is built from, through every transform and binary, in order. Between two consecutive nodes a curve read log-linearly carries one flat forward, which is what an integral closed-form on flat intervals — the ISDA CDS protection and accrual integrals — needs its grid to respect. Smooth families have none; a node too many costs nothing (a flat interval split in two integrates to the same value), a node missing averages two forwards.
§impl Curve
impl Curve
pub fn view<R: Scalar>(&self) -> CurveView<'_, R>
pub fn view<R: Scalar>(&self) -> CurveView<'_, R>
This curve lifted into mode R.
Recursive for a family that reads other curves: lifting one lifts its parts, borrowing throughout. For the passive mode nothing is allocated for the parameters at any depth.
pub(crate) fn view_with_slice<'a, R: Scalar>(
&'a self,
rest: &mut &'a [R],
) -> CurveView<'a, R>
pub(crate) fn view_with_slice<'a, R: Scalar>( &'a self, rest: &mut &'a [R], ) -> CurveView<'a, R>
One step of a substituted walk: each member takes its own
parameters off the front of rest, in parameter_owners order.
§impl Curve
impl Curve
pub fn parameters(&self) -> &[f64]
pub fn parameters(&self) -> &[f64]
See Family::parameters.
pub fn parts(&self) -> Vec<&Curve>
pub fn parts(&self) -> Vec<&Curve>
See Family::parts.
pub fn view_with<'a, R: Scalar>(
&'a self,
params: &'a [R],
) -> Result<CurveView<'a, R>, CurveError>
pub fn view_with<'a, R: Scalar>( &'a self, params: &'a [R], ) -> Result<CurveView<'a, R>, CurveError>
pub fn view_seeded<R: Scalar + Seedable>(
&self,
index: usize,
) -> Result<CurveView<'_, R>, CurveError>
pub fn view_seeded<R: Scalar + Seedable>( &self, index: usize, ) -> Result<CurveView<'_, R>, CurveError>
pub fn parameter_count(&self) -> usize
pub fn parameter_count(&self) -> usize
pub fn for_each_owner<'a>(&'a self, f: &mut dyn FnMut(&'a Curve))
pub fn for_each_owner<'a>(&'a self, f: &mut dyn FnMut(&'a Curve))
pub fn parameter_owners(&self) -> Vec<&Curve>
pub fn parameter_owners(&self) -> Vec<&Curve>
pub fn parameter_labels(&self) -> Vec<ParameterLabel>
pub fn parameter_labels(&self) -> Vec<ParameterLabel>
pub fn adjoint_refusal(&self) -> Option<&'static str>
pub fn adjoint_refusal(&self) -> Option<&'static str>
Trait Implementations§
§impl Family for Curve
impl Family for Curve
§fn own_refusal(&self) -> Option<&'static str>
fn own_refusal(&self) -> Option<&'static str>
Only an interpolation scheme can refuse: the two dated-pillar families ask theirs, and every other family is linear in what it stores.
§fn parameters(&self) -> &[f64]
fn parameters(&self) -> &[f64]
§fn parts(&self) -> Vec<&Curve>
fn parts(&self) -> Vec<&Curve>
§fn own_labels(&self) -> Vec<ParameterLabel>
fn own_labels(&self) -> Vec<ParameterLabel>
parameters reports them.§fn view_with<'a, R: Scalar>(
&'a self,
params: &'a [R],
) -> Result<Self::View<'a, R>, CurveError>
fn view_with<'a, R: Scalar>( &'a self, params: &'a [R], ) -> Result<Self::View<'a, R>, CurveError>
R over params, in place of its stored
ones — the whole of what arming used to be. Read more§fn view_seeded<R: Scalar + Seedable>(
&self,
index: usize,
) -> Result<Self::View<'_, R>, CurveError>
fn view_seeded<R: Scalar + Seedable>( &self, index: usize, ) -> Result<Self::View<'_, R>, CurveError>
index carrying a
unit tangent and every other a zero tangent. Read more§fn parameter_count(&self) -> usize
fn parameter_count(&self) -> usize
§fn for_each_owner<'a>(&'a self, f: &mut dyn FnMut(&'a Self))
fn for_each_owner<'a>(&'a self, f: &mut dyn FnMut(&'a Self))
parameter_owners order, without collecting
them. The lift flattens parameters through this so a market of leaves
allocates one vector, not one per curve.§fn parameter_owners(&self) -> Vec<&Self>
fn parameter_owners(&self) -> Vec<&Self>
§fn parameter_labels(&self) -> Vec<ParameterLabel>
fn parameter_labels(&self) -> Vec<ParameterLabel>
§fn adjoint_refusal(&self) -> Option<&'static str>
fn adjoint_refusal(&self) -> Option<&'static str>
§impl From<Curve> for PinnedCurve
impl From<Curve> for PinnedCurve
§impl Lift for Curve
impl Lift for Curve
§type View<'a, R: Scalar> = CurveView<'a, R>
where
Self: 'a
type View<'a, R: Scalar> = CurveView<'a, R> where Self: 'a
R, borrowing the storage for 'a.§fn view_with_slice<'a, R: Scalar>(
&'a self,
rest: &mut &'a [R],
) -> CurveView<'a, R>
fn view_with_slice<'a, R: Scalar>( &'a self, rest: &mut &'a [R], ) -> CurveView<'a, R>
rest, then its parts take theirs, in
parameter_owners order.