Function vanilla_swap
pub(crate) fn vanilla_swap(
currency: &str,
effective: NaiveDate,
termination: NaiveDate,
fixed_rate: f64,
index: &str,
notional: f64,
pays_fixed: bool,
accrual_compounding: Option<Named<AccrualCompounding>>,
) -> PyResult<PyInstrument>Expand description
Builds a fixed-versus-floating interest-rate swap on index’s registered
conventions.
Calendar, frequency, roll, business-day convention, day counts, and payment lag are resolved from the template registry for the index — the same source the Rust surface uses, restated nowhere — so the nominally identical trade books identical cashflows from either surface. An overnight index builds an overnight swap; a term index a vanilla IBOR swap. An index the registry does not know raises, naming the registered indices.
accrual_compounding says how an overnight leg turns its daily prints into a
coupon rate: "compounded" for (Π(1 + rᵢ·τᵢ) − 1)/Στ, the SOFR and ESTR
convention, or "averaged" for Σ(rᵢ·τᵢ)/Στ, the Fed Funds one. None
takes the index’s registered template at its word, which is what a caller
booking a standard trade wants. Continuous accrual is refused: no market
quotes an overnight leg that way. A term index has no strip to accumulate,
so naming one here is refused rather than ignored.
pays_fixed defaults to False: the default swap receives fixed. The
notional is taken as signed, so a negative notional flips every flow —
the other side of the same trade — rather than being refused.