Skip to main content

Rung

Struct Rung 

pub struct Rung {
    pub pillar: NaiveDate,
    pub instrument: AnyInstrument,
    pub quote: f64,
    pub kind: QuoteKind,
    pub tenor: Option<Period>,
    pub label: Option<String>,
    pub knot: Option<KnotKind>,
    pub awaiting_meeting: Option<(CentralBank, NaiveDate)>,
    pub solves_projection: bool,
}
Expand description

One rung of a calibration ladder: an instrument, the pillar it determines, and the kind of quote it was built at.

Fields§

§pillar: NaiveDate

The pillar date this rung solves for.

§instrument: AnyInstrument

The instrument the rung is quoted on.

§quote: f64

The quote the instrument was built at, in its own units — a par rate, a spread, an upfront, or a price.

The instrument already embeds this number, so the field is the caller’s declaration of which of the instrument’s scalars is the quote. That is not redundancy for its own sake: a par sensitivity is a derivative with respect to this scalar, so something has to name it, and no accessor on the instrument union does. It is verified at calibration, against whichever quantity kind names.

§kind: QuoteKind

Whether the quote is a par rate or a price — see QuoteKind.

§tenor: Option<Period>

The tenor the rung was quoted at, where it was built from one — the 5Y a desk’s quote sheet says, which the pillar date alone loses. It labels the rung’s column of a par ladder.

§label: Option<String>

A label for a rung quoted at no tenor — the futures contract (DEC26) or the window a step pillar covers — which labels its column of a par ladder where a tenor would.

§knot: Option<KnotKind>

The identity the rung’s pillar carries on a step curve — the meeting that decides the window it closes, or the turn it covers. None on every plain rung, whose pillar is an anonymous knot.

§awaiting_meeting: Option<(CentralBank, NaiveDate)>

A window built without a schedule that could name it: the bank and the window start, so a market pinning that bank’s schedule stamps the meeting at the pin. None on every other rung.

§solves_projection: bool

Whether the rung marks its instrument’s projection rather than the discount it would otherwise solve: an NDS, whose payments all convert by one factor, identifies its index’s forward curve and barely the offshore discount, so its strip solves the projection against the held settlement and offshore discounts. false on every other rung.

Implementations§

§

impl Rung

pub fn solving_projection(self) -> Self

This rung solving its instrument’s projection, against every discount it reads held — an NDS strip’s reading.

pub fn with_tenor(self, tenor: Period) -> Self

This rung labelled with the tenor it was quoted at.

pub fn with_label(self, label: impl Into<String>) -> Self

This rung labelled by a spelling that is not a tenor — a futures contract, a meeting window.

pub fn awaiting_meeting(self, bank: CentralBank, start: NaiveDate) -> Self

This rung marked as a window of bank opening on start that no schedule has named yet.

pub fn named_by(self, market: &MarketContext) -> Self

This rung with its meeting stamped from market’s schedule for the bank it awaits, where that schedule opens a window on its start; unchanged otherwise.

pub fn with_knot(self, knot: KnotKind) -> Self

This rung’s pillar carrying knot on the step curve the ladder solves.

pub fn column_label(&self) -> String

How a ladder names this rung’s column: its tenor, else its label, else its pillar date.

pub fn par(pillar: NaiveDate, instrument: AnyInstrument, quote: f64) -> Self

A rung whose instrument is at par: the ladder solves its pillar so the instrument is worth nothing, and quote is its par rate.

pub fn priced( pillar: NaiveDate, instrument: AnyInstrument, quote: f64, money_per_quote: f64, ) -> Self

A rung whose instrument trades at a price: the ladder solves its pillar so the instrument is worth quote × money_per_quote.

money_per_quote converts the quote’s units into the instrument’s money — face/100 for a bond quoted per 100 face. It belongs to the instrument, not to the quote, which is what lets the declared quote be checked rather than merely carried.

pub fn priced_for_settlement( pillar: NaiveDate, instrument: AnyInstrument, quote: f64, money_per_quote: f64, settlement: NaiveDate, ) -> Self

A rung whose instrument trades at a price for settlement on settlement: the ladder solves its pillar so the instrument’s value forwarded to settlement is quote × money_per_quote.

For a market that quotes T+1 or T+2 on a curve referenced today. See QuoteKind::Priced for what is compared.

pub fn spread(pillar: NaiveDate, instrument: AnyInstrument, quote: f64) -> Self

A rung quoted as a spread on its floating leg: the ladder solves its pillar so the instrument is worth nothing, exactly as for Rung::par, and quote is its par spread.

The instrument must already carry quote on the leg it is quoted on — the residual is the instrument’s own value, so a swap built at a different spread would solve its pillar to the wrong place and then fail the quote check rather than silently succeed.

pub fn upfront(pillar: NaiveDate, contract: AnyInstrument, upfront: f64) -> Self

The priced rung an upfront-quoted credit default swap is: the contract with its upfront removed, the upfront as the quote, and the contract’s notional as the money per unit quote — so the residual is the buyer’s value less what the buyer would pay, and the ladder solves the same curve a spread-quoted contract would. Takes the single-name and index contracts; any other instrument is returned unchanged as a par rung, which the ladder’s own checks then refuse by name.

The upfront is paid on the contract’s cash-settlement date, and the contract discounts it from there, so the quote is a price for that settlement: the rung compares the running contract’s value forwarded to it. Compared with its value today instead, the ladder would solve a curve on which the quoted contract itself is not worth zero, by the upfront times one less the settlement discount factor.

pub fn requoted(&self, quote: f64) -> Result<Self, CalibrationError>

This rung at another quote, its instrument re-struck so it carries it: a priced rung takes quote as its price; a par rung sets the scalar the quote is — every fixed coupon of a vanilla or overnight swap’s fixed leg, a deposit’s rate, an FRA’s struck rate, a zero-coupon swap’s fixed rate, a credit default swap’s running coupon, and a STIR future’s futures rate (its traded price 100 − 100·quote); a spread rung sets a tenor basis or cross-currency swap’s spread on its spread leg. What a scenario moving a curve’s quotes solves its ladder again from.

§Errors

CalibrationError::Malformed for a par or spread rung on any other instrument, whose quote the instrument embeds in a way this cannot re-strike.

pub fn money_scale(&self) -> f64

The rung’s own money scale: what a residual in the instrument’s money is read against, so a solve tolerance means the same thing whatever the rung’s size.

A priced rung’s money is sized by money_per_quote — a CDS upfront rung carries the contract’s full notional there, a bond face/100 — so that is its scale, floored at one for a quote already in money terms. A par or spread rung is built at whatever notional the caller chose, unit notional in every template ladder, and no accessor on the instrument union reports it, so its scale is one; a caller solving a par ladder at a real notional scales Tolerance::residual instead.

pub fn target(&self) -> f64

The value the ladder drives this rung’s instrument to: zero at par — whether the quote is a rate or a spread — and the quote in the instrument’s money for a priced rung.

pub fn value<R: Scalar>( &self, view: &PricingView<'_, R>, ) -> Result<R, CalibrationError>

The value the ladder compares with target: the instrument’s value today, or — for a priced rung quoted for a later settlement — its value on that date, in the curve under solve.

A bond’s flows between today and settlement belong to whoever holds it today, so they are dropped before forwarding rather than carried: a price for settlement buys only what is paid after it. Any other instrument is forwarded whole.

§Errors

CalibrationError if the instrument or the curve cannot be read.

Trait Implementations§

§

impl Clone for Rung

§

fn clone(&self) -> Rung

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 Rung

§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Rung

§

impl !UnwindSafe for Rung

§

impl Freeze for Rung

§

impl Send for Rung

§

impl Sync for Rung

§

impl Unpin for Rung

§

impl UnsafeUnpin for Rung

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.