Skip to main content

BondTotalReturnSwap

Struct BondTotalReturnSwap 

pub struct BondTotalReturnSwap {
Show 14 fields pub basket: BondBasket, pub notional: f64, pub reset_schedule: Vec<NaiveDate>, pub funding_day_count: DayCountFraction, pub funding_margin: f64, pub funding_gearing: f64, pub funding_collateral: CollateralSpec, pub funding_index: Option<String>, pub pay_total_return: bool, pub pay_coupons_immediately: bool, pub repo_key: String, pub repo_keys: Vec<String>, pub issuers: Vec<CreditCurveId>, pub funding_notional: Option<f64>,
}
Expand description

A bond total return swap: the reference bond’s total return against a floating funding leg, single-currency.

Fields§

§basket: BondBasket

The underlying: a basket of bonds, replicated from its constituents, each with its weight and its contractual starting clean price. A single-bond swap is the basket of one.

§notional: f64

Package notional in bond face.

§reset_schedule: Vec<NaiveDate>

Reset boundaries, ascending: n+1 boundaries make n reset periods, and the funding leg’s schedule.

§funding_day_count: DayCountFraction

The funding leg’s accrual day count.

§funding_margin: f64

The margin over the funding index, as a decimal.

§funding_gearing: f64

Gearing on the projected index; 0.0 makes the funding fixed at the margin.

§funding_collateral: CollateralSpec

The funding leg’s discounting collateral.

§funding_index: Option<String>

The funding leg’s projection index; None projects off the discount curve.

§pay_total_return: bool

true pays the total return and receives funding.

§pay_coupons_immediately: bool

true passes bond cashflows through at their own dates; false at the enclosing reset date.

§repo_key: String

The repo curve the package is financed on: every constituent that names no curve of its own is carried here.

§repo_keys: Vec<String>

The repo curve each constituent is carried on, in basket order — its own where it names one, the package’s otherwise. Derived at construction; the seam borrows it as the swap’s repo basket.

§issuers: Vec<CreditCurveId>

The issuer of each constituent whose bond is credit-tagged, in basket order, tagged constituents only. Derived at construction; the seam borrows it as the swap’s credit basket, and the return leg reads the resolved curves back in the same order.

§funding_notional: Option<f64>

The funding leg’s notional where the contract states one: the financed cash. None derives it as notional·initial_price/100.

Implementations§

§

impl BondTotalReturnSwap

pub fn new( bond: FixedRateBond, notional: f64, initial_price: f64, reset_schedule: Vec<NaiveDate>, repo_key: impl Into<String>, ) -> Result<Self, FinancingError>

A total-return receiver with Act/360 floating funding on the bond currency’s cash collateral, zero margin, unit gearing, coupons passed through at the reset date.

§Errors

FinancingError::MalformedResets for fewer than two or non-ascending boundaries.

pub fn on_basket( basket: BondBasket, notional: f64, reset_schedule: Vec<NaiveDate>, repo_key: impl Into<String>, ) -> Result<Self, FinancingError>

A total-return receiver on a basket, with the same defaults as new: Act/360 floating funding on the basket currency’s cash collateral, zero margin, unit gearing, coupons passed through at the reset date.

§Errors

FinancingError::MalformedResets for fewer than two or non-ascending boundaries.

pub fn with_funding_notional(self, notional: f64) -> Self

Sets the funding leg’s notional, in place of the one the initial price implies.

pub fn with_funding_margin(self, margin: f64) -> Self

Sets the funding margin.

pub fn with_funding_gearing(self, gearing: f64) -> Self

Sets the funding gearing.

pub fn with_funding_index(self, index: impl Into<String>) -> Self

Sets the funding projection index.

pub fn with_funding_collateral( self, collateral: CollateralSpec, ) -> Result<Self, FinancingError>

Sets the funding collateral. Single-currency only: the collateral’s currency must be the bond’s.

§Errors

FinancingError::MixedCurrencies for a composite swap.

pub fn paying_total_return(self) -> Self

Pays the total return and receives funding.

pub fn paying_coupons_immediately(self) -> Self

Passes bond cashflows through at their own dates.

pub fn sign(&self) -> f64

+1 for the receiver of the total return, −1 for the payer.

pub fn funded_notional(&self) -> f64

The financed cash notional — what the funding leg accrues on: the one the contract states, or notional·initial_price/100.

§

impl BondTotalReturnSwap

pub(crate) fn funding_leg(&self, as_of: NaiveDate, margin: f64) -> Leg

The funding leg at margin, compiled against the valuation date.

A named index resets at each period’s start and reads its print for a reset already past, or dated today once it has printed; a leg projected off the discount curve names no index, so nothing could have printed and every period projects. The zero-gearing fixed-funding shape is the same leg with the margin as its whole rate.

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

The return leg: per reset period the price return on forward clean prices carried on the repo curve (the first period anchored on the contractual initial price), paid at the period end, plus the bond’s cashflows falling in the window — at their own dates or the period end — all discounted on the funding curve, matured flows excluded.

Each constituent is carried on its own curve where the market holds the one it names, and on the package repo curve otherwise — the cascade the repo basket resolves optionally for, one tier deep. The package curve itself is required.

§Errors

PricingError::UnsupportedForProduct if the view carries no repo curve; otherwise whatever the curves report.

pub(crate) fn funding_curve<'v, R: Scalar>( &self, view: &'v PricingView<'_, R>, ) -> Result<OneCurve<'v, R>, PricingError>

The curve the funding leg projects off: the one its funding index names, or the view’s first projection where the leg is a fixed one and names none.

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

The funding leg at its struck margin.

§Errors

Whatever the curves and fixings report.

Trait Implementations§

§

impl Clone for BondTotalReturnSwap

§

fn clone(&self) -> BondTotalReturnSwap

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 BondTotalReturnSwap

§

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

Formats the value using the given formatter. Read more
§

impl PartialEq for BondTotalReturnSwap

§

fn eq(&self, other: &BondTotalReturnSwap) -> 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<R: Scalar> Priceable<R> for BondTotalReturnSwap

§

fn npv(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>

sign · (return − funding).

§

fn par_spread(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>

The fair margin: the swap’s par measure is its funding margin.

§

fn par_rate(&self, _view: &PricingView<'_, R>) -> Result<R, PricingError>

The par rate — the fixed rate at which the product is worth nothing. Read more
§

impl PricingRiskFactors for BondTotalReturnSwap

§

fn risk_factors(&self) -> Result<RiskFactors<'_>, PricingError>

Discounts on the funding collateral (the bond’s currency, by construction), carries on the package repo curve with each constituent’s own carry curve declared as the repo basket, and projects the funding index when one is named.

§

impl Product for BondTotalReturnSwap

§

fn currency(&self) -> Currency

The currency the product pays in. An FX product values in its quote currency; a book converts.
§

fn contract_dates(&self) -> Vec<(&'static str, NaiveDate)>

The contract dates the product resolved to, as (name, date) pairs — exactly the dates its stated constructor takes, so a product built through a derived form can be read back and rebuilt through the stated one. Empty for a product with no stated form. No default: every product states which it is — see AnyInstrument::contract_dates.
§

fn legs(&self) -> Option<Vec<&Leg>>

The legs the product itself holds, in a declared order, or None for a product that holds none — see AnyInstrument::legs. No default: every product states which it is.
§

fn final_payment_date(&self) -> Option<NaiveDate>

The date of the product’s final payment, where a calibration rung can be built on it; None for a product no ladder is built from.
§

fn restruck_at_rate(&self, _rate: f64) -> Option<AnyInstrument>

This product re-struck at the par rate rate — the scalar a par calibration rung on it is quoted in — or None for a product that carries no such scalar. What a quote scenario moves a rung to.
§

fn restruck_at_spread(&self, _spread: f64) -> Option<AnyInstrument>

This product re-struck at the basis spread spread on its spread leg, or None for a product that quotes none.
§

impl StructuralPartialEq for BondTotalReturnSwap

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.