Skip to main content

AssetSwap

Struct AssetSwap 

pub struct AssetSwap {
    pub bond: CallableBond,
    pub start: NaiveDate,
    pub index: String,
    pub float_schedule: Vec<NaiveDate>,
    pub float_day_count: DayCountFraction,
    pub notional: f64,
    pub kind: AssetSwapKind,
    pub buyer: bool,
    pub dirty_price: f64,
    pub spread: f64,
    pub floating: Leg,
}
Expand description

An asset swap package: a bullet bond, a floating leg on an index, the traded dirty price and spread, the date it settles, and the side.

Fields§

§bond: CallableBond

The reference bond, with its collateral. A bullet, not credit-tagged.

§start: NaiveDate

The package’s settlement: when the dirty price is paid and the floating leg starts. The first boundary of float_schedule.

§index: String

The index the floating leg resets against, and the projection curve it is valued on.

§float_schedule: Vec<NaiveDate>

Floating-leg boundary dates, ascending: n boundaries delimit n − 1 accrual periods, each paid on its end.

§float_day_count: DayCountFraction

The floating leg’s accrual day count.

§notional: f64

The package notional, in bond face.

§kind: AssetSwapKind

Par-par or proceeds.

§buyer: bool

Whether the holder is the asset-swap buyer — pays the bond’s coupons away, receives floating plus the spread.

§dirty_price: f64

The traded dirty price per 100.

§spread: f64

The struck spread, as a decimal.

§floating: Leg

The floating leg’s IBOR coupons on a unit notional, without the spread, compiled once from the schedule. Scaled by the convention’s notional when valued, so switching convention recompiles nothing.

Implementations§

§

impl AssetSwap

pub fn new( bond: CallableBond, start: NaiveDate, index: impl Into<String>, float_frequency: Period, notional: f64, dirty_price: f64, spread: f64, ) -> Result<Self, AssetSwapError>

A par-par package settling on start, bought at dirty_price and struck at spread, whose floating leg resets against index every float_frequency from start to the bond’s maturity.

The leg rolls backward from the maturity, so its periods end on the bond’s coupon days and any short stub comes first. Every boundary after start is adjusted by the bond’s own payment rule, and each period accrues on Act/360 and pays on its end. A bond paying on unadjusted dates therefore gives an unadjusted leg.

§Errors

AssetSwapError for a callable or credit-tagged bond, a start on or after the maturity, a non-positive notional, or non-finite terms.

pub fn from_schedule( bond: CallableBond, index: impl Into<String>, float_schedule: Vec<NaiveDate>, float_day_count: DayCountFraction, notional: f64, dirty_price: f64, spread: f64, ) -> Result<Self, AssetSwapError>

A par-par package on an explicit floating schedule and day count. The package settles on the schedule’s first date, and each period pays on its end.

§Errors

As new, plus a schedule with fewer than two dates or one that is not strictly ascending.

pub fn with_kind(self, kind: AssetSwapKind) -> Self

This package under kind.

pub fn sold(self) -> Self

The seller’s side.

pub fn sign(&self) -> f64

+1 for the buyer, −1 for the seller.

pub fn annuity_notional(&self) -> f64

The notional the floating leg runs on: the full notional under par-par, the dirty proceeds under proceeds.

pub fn proceeds(&self) -> f64

The traded dirty proceeds, dirty_price / 100 · notional, paid on start.

§

impl AssetSwap

fn cut(&self, as_of: NaiveDate) -> NaiveDate

The date the bond’s flows are cut at: the later of the package’s start and the valuation date. A flow paid on or before the start is the seller’s.

fn settles_ahead(&self, as_of: NaiveDate) -> bool

Whether the exchanges dated start are still to come. A package settling today exchanges today, so they count; once the start is past they have been paid, like every other past flow.

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

The bond’s risk-free present value: its flows paid after the package starts and after the valuation date, on the collateral curve, in the bond’s face.

§Errors

Whatever the curve reports.

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

The floating spread annuity on notional: notional · Σ τⱼ·DF(tⱼ₊₁) over the periods paid after the valuation date.

§Errors

Whatever the curve reports.

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

The floating leg on a unit notional: its index part with the notional exchanges, Σ τ·F·DF + DF(end) − DF(start), and its annuity Σ τ·DF.

On one curve, with nothing fixed, the index part telescopes to zero. It is not assumed to: a projection curve apart from the discount curve, or a reset already in the store, is what moves it.

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

Everything in the package but the spread leg, to the buyer: I − PV_bond + P_dirty·N·DF(start). Returned with the annuity on the convention’s notional, which the spread multiplies.

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

The spread that zeroes the package — −(I − PV_bond + P_dirty·N·DF(start)) / A on the convention’s notional — read off in closed form, since the package is linear in the spread. Positive for a bond trading cheap to the curve.

§Errors

PricingError::DegenerateAnnuity when no floating period survives the valuation date; otherwise whatever the curves or the fixing store report.

Trait Implementations§

§

impl Clone for AssetSwap

§

fn clone(&self) -> AssetSwap

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 AssetSwap

§

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

Formats the value using the given formatter. Read more
§

impl PartialEq for AssetSwap

§

fn eq(&self, other: &AssetSwap) -> 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 AssetSwap

§

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

To the buyer, s·A + I − PV_bond + P_dirty·N·DF(start): the spread received and the index leg against what the bond is worth over what was paid for it. Zero at the par spread; negated for the seller.

§

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

The par asset-swap spread.

§

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 AssetSwap

§

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

The bond’s collateral curve — the risk-free curve of its currency — and the index’s projection curve. A declared security spread is deliberately not composed: the spread this package quotes is the one over risk-free.

§

impl Product for AssetSwap

§

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 AssetSwap

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.