Struct RepoSpread
pub struct RepoSpread {
reference_date: NaiveDate,
dates: Vec<NaiveDate>,
taus: Vec<f64>,
basis: DayCountFraction,
spreads: Vec<f64>,
}Expand description
A repo spread: simple spreads over a base, at dated pillars, whose free parameters are the spreads a desk marks.
It is additive in simple-rate space, not a factor. Over a base it reads
1/P_repo(t) = 1/P_base(t) + s(t)·τ(t), where τ is the year fraction in
the money-market basis the curve carries. That is what “GC = SOFR + 3” and
“special = GC − 220” mean on a desk: the term repo simple rate is the base’s
simple rate plus the spread. Spreads in a chain therefore add, and a
floating repo paying the base’s compounded rate plus s is at par exactly.
It holds no base. The base is the market’s declaration, and the
composition happens when a repo key is resolved — the simple overlay on the
resolved curve, the one composition that is not a product of discount
factors. Alone, as the YieldCurve every Curve
arm must be, it is the spread over a unit base: 1/(1 + s(t)·τ(t)).
Linear in the spread between pillars, flat before the first and beyond the last.
Fields§
§reference_date: NaiveDate§dates: Vec<NaiveDate>§taus: Vec<f64>Year fractions in basis — the interpolation abscissa and the accrual.
basis: DayCountFraction§spreads: Vec<f64>The free parameters: simple spreads, as decimals.
Implementations§
§impl RepoSpread
impl RepoSpread
pub fn new(
reference_date: NaiveDate,
pillars: &[(NaiveDate, f64)],
basis: DayCountFraction,
) -> Result<Self, CurveError>
pub fn new( reference_date: NaiveDate, pillars: &[(NaiveDate, f64)], basis: DayCountFraction, ) -> Result<Self, CurveError>
A repo spread from (date, spread) pillars, accruing on basis.
§Errors
CurveError::Malformed if there are no pillars or the dates do not
strictly increase from the reference date; CurveError::NonFinite if
a spread is NaN or infinite.
pub fn from_term_rates<C: YieldCurve<f64> + ?Sized>(
base: &C,
quotes: &[(NaiveDate, f64)],
basis: DayCountFraction,
) -> Result<Self, CurveError>
pub fn from_term_rates<C: YieldCurve<f64> + ?Sized>( base: &C, quotes: &[(NaiveDate, f64)], basis: DayCountFraction, ) -> Result<Self, CurveError>
The spread over base that reprices term repos quoted from its
reference date: a quote (T, r) at the simple rate r on basis is
the pillar s = r − (1/P_base(T) − 1)/τ, so that
1/P_repo(T) = 1 + r·τ. Exact, each pillar resting on its own quote. A
special over GC is the same call over the GC curve, or the difference
of the two rates at each term.
§Errors
As new, and whatever base reports for a quote’s date.
pub fn reference_date(&self) -> NaiveDate
pub fn reference_date(&self) -> NaiveDate
The reference date.
pub fn pillar_dates(&self) -> &[NaiveDate]
pub fn pillar_dates(&self) -> &[NaiveDate]
The pillar dates.
pub fn parameters(&self) -> &[f64]
pub fn parameters(&self) -> &[f64]
The free parameters — the spread at each pillar.
pub fn day_count(&self) -> DayCountFraction
pub fn day_count(&self) -> DayCountFraction
The money-market day count the spread accrues on.
pub fn spread(&self, at: NaiveDate) -> Result<f64, CurveError>
pub fn spread(&self, at: NaiveDate) -> Result<f64, CurveError>
The spread at at: linear between pillars, flat outside them.
§Errors
CurveError::BeforeReference for a date before the reference date.
pub fn moved(
&self,
to: impl Fn(NaiveDate, f64) -> f64,
) -> Result<Self, CurveError>
pub fn moved( &self, to: impl Fn(NaiveDate, f64) -> f64, ) -> Result<Self, CurveError>
This spread with each pillar’s spread replaced by to(date, spread) —
how a scenario moves a desk’s marks. The pillars and basis are kept.
§Errors
CurveError::NonFinite if a moved spread is NaN or infinite.
pub fn view<R: Scalar>(&self) -> RepoSpreadView<'_, R>
pub fn view<R: Scalar>(&self) -> RepoSpreadView<'_, R>
This spread lifted into mode R.
pub(crate) fn view_with_slice<'a, R: Scalar>(
&'a self,
rest: &mut &'a [R],
) -> RepoSpreadView<'a, R>
pub(crate) fn view_with_slice<'a, R: Scalar>( &'a self, rest: &mut &'a [R], ) -> RepoSpreadView<'a, R>
One step of a substituted walk. See
take_params.
pub(crate) fn view_seeding<R: Scalar + Seedable>(
&self,
seed: &mut Option<usize>,
) -> RepoSpreadView<'_, R>
pub(crate) fn view_seeding<R: Scalar + Seedable>( &self, seed: &mut Option<usize>, ) -> RepoSpreadView<'_, R>
One step of the seeded walk. See take_seed.
Trait Implementations§
§impl Clone for RepoSpread
impl Clone for RepoSpread
§fn clone(&self) -> RepoSpread
fn clone(&self) -> RepoSpread
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more