Skip to main content

RepoSpread

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

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>

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

The reference date.

pub fn pillar_dates(&self) -> &[NaiveDate]

The pillar dates.

pub fn parameters(&self) -> &[f64]

The free parameters — the spread at each pillar.

pub fn day_count(&self) -> DayCountFraction

The money-market day count the spread accrues on.

pub fn pillars(&self) -> Vec<(NaiveDate, f64)>

The pillars as (date, spread).

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>

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>

This spread lifted into mode 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>

One step of the seeded walk. See take_seed.

Trait Implementations§

§

impl Clone for RepoSpread

§

fn clone(&self) -> RepoSpread

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 Debug for RepoSpread

§

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

Formats the value using the given formatter. Read more
§

impl PartialEq for RepoSpread

§

fn eq(&self, other: &RepoSpread) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl StructuralPartialEq for RepoSpread

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.