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: BondBasketThe 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: f64Package 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: DayCountFractionThe funding leg’s accrual day count.
funding_margin: f64The margin over the funding index, as a decimal.
funding_gearing: f64Gearing on the projected index; 0.0 makes the funding fixed at the
margin.
funding_collateral: CollateralSpecThe funding leg’s discounting collateral.
funding_index: Option<String>The funding leg’s projection index; None projects off the discount
curve.
pay_total_return: booltrue pays the total return and receives funding.
pay_coupons_immediately: booltrue passes bond cashflows through at their own dates; false at
the enclosing reset date.
repo_key: StringThe 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
impl BondTotalReturnSwap
pub fn new(
bond: FixedRateBond,
notional: f64,
initial_price: f64,
reset_schedule: Vec<NaiveDate>,
repo_key: impl Into<String>,
) -> Result<Self, FinancingError>
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>
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
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
pub fn with_funding_margin(self, margin: f64) -> Self
Sets the funding margin.
pub fn with_funding_gearing(self, gearing: f64) -> Self
pub fn with_funding_gearing(self, gearing: f64) -> Self
Sets the funding gearing.
pub fn with_funding_index(self, index: impl Into<String>) -> Self
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>
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
pub fn paying_total_return(self) -> Self
Pays the total return and receives funding.
pub fn paying_coupons_immediately(self) -> Self
pub fn paying_coupons_immediately(self) -> Self
Passes bond cashflows through at their own dates.
pub fn funded_notional(&self) -> f64
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
impl BondTotalReturnSwap
pub(crate) fn funding_leg(&self, as_of: NaiveDate, margin: f64) -> Leg
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>
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>
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>
pub fn funding_leg_npv<R: Scalar>( &self, view: &PricingView<'_, R>, ) -> Result<R, PricingError>
Trait Implementations§
§impl Clone for BondTotalReturnSwap
impl Clone for BondTotalReturnSwap
§fn clone(&self) -> BondTotalReturnSwap
fn clone(&self) -> BondTotalReturnSwap
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for BondTotalReturnSwap
impl Debug for BondTotalReturnSwap
§impl PartialEq for BondTotalReturnSwap
impl PartialEq for BondTotalReturnSwap
§fn eq(&self, other: &BondTotalReturnSwap) -> bool
fn eq(&self, other: &BondTotalReturnSwap) -> bool
self and other values to be equal, and is used by ==.§impl<R: Scalar> Priceable<R> for BondTotalReturnSwap
impl<R: Scalar> Priceable<R> for BondTotalReturnSwap
§fn npv(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
fn npv(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
sign · (return − funding).
§fn par_spread(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
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>
fn par_rate(&self, _view: &PricingView<'_, R>) -> Result<R, PricingError>
§impl PricingRiskFactors for BondTotalReturnSwap
impl PricingRiskFactors for BondTotalReturnSwap
§fn risk_factors(&self) -> Result<RiskFactors<'_>, PricingError>
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
impl Product for BondTotalReturnSwap
§fn currency(&self) -> Currency
fn currency(&self) -> Currency
§fn contract_dates(&self) -> Vec<(&'static str, NaiveDate)>
fn contract_dates(&self) -> Vec<(&'static str, NaiveDate)>
(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>>
fn legs(&self) -> Option<Vec<&Leg>>
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>
fn final_payment_date(&self) -> Option<NaiveDate>
None for a product no ladder is built from.§fn restruck_at_rate(&self, _rate: f64) -> Option<AnyInstrument>
fn restruck_at_rate(&self, _rate: f64) -> Option<AnyInstrument>
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>
fn restruck_at_spread(&self, _spread: f64) -> Option<AnyInstrument>
spread on its spread
leg, or None for a product that quotes none.