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: CallableBondThe reference bond, with its collateral. A bullet, not credit-tagged.
start: NaiveDateThe package’s settlement: when the dirty price is paid and the
floating leg starts. The first boundary of
float_schedule.
index: StringThe 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: DayCountFractionThe floating leg’s accrual day count.
notional: f64The package notional, in bond face.
kind: AssetSwapKindPar-par or proceeds.
buyer: boolWhether the holder is the asset-swap buyer — pays the bond’s coupons away, receives floating plus the spread.
dirty_price: f64The traded dirty price per 100.
spread: f64The struck spread, as a decimal.
floating: LegThe 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
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>
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>
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>
pub fn with_kind(self, kind: AssetSwapKind) -> Self
pub fn with_kind(self, kind: AssetSwapKind) -> Self
This package under kind.
pub fn sold(self) -> Self
pub fn sold(self) -> Self
The seller’s side.
pub fn annuity_notional(&self) -> f64
pub fn annuity_notional(&self) -> f64
The notional the floating leg runs on: the full notional under par-par, the dirty proceeds under proceeds.
§impl AssetSwap
impl AssetSwap
fn cut(&self, as_of: NaiveDate) -> NaiveDate
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
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>
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>
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>
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>
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>
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<R: Scalar> Priceable<R> for AssetSwap
impl<R: Scalar> Priceable<R> for AssetSwap
§fn npv(&self, view: &PricingView<'_, R>) -> Result<R, PricingError>
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>
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>
fn par_rate(&self, _view: &PricingView<'_, R>) -> Result<R, PricingError>
§impl PricingRiskFactors for AssetSwap
impl PricingRiskFactors for AssetSwap
§fn risk_factors(&self) -> Result<RiskFactors<'_>, PricingError>
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
impl Product for AssetSwap
§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.