Skip to main content

swap_dates_from_tenor

Function swap_dates_from_tenor 

pub fn swap_dates_from_tenor(
    template: &AnyTemplate,
    valuation: NaiveDate,
    tenor: ForwardTenor,
) -> Result<(NaiveDate, NaiveDate), CurveError>
Expand description

A ProductBuilder pre-loaded with the conventions of a resolved swap template value, rather than of a template named by code.

This is the form an overridden template reaches a product through. The two code-keyed entry points below resolve a template and then call this; a caller who has modified one — usd_sofr().with_payment_lag(0) — calls it directly, which nothing could do while both entry points took strings.

index_code is the projection key the floating leg declares. It is a parameter rather than something recovered here because both callers already hold it, and recovering it means a linear scan of the index registry on every swap construction.

The effective and termination dates a template’s swap takes from a ForwardTenor, anchored on valuation.

The effective date is the template’s spot date advanced by the forward start under the template’s calendar and business-day convention, as the FRA’s is. The termination is the effective date plus the tenor, unadjusted: the schedule seeds its roll from it and rolls it under the leg’s own convention, the rule cross_currency_rungs states for a rung. So "5Y" on a valuation is the swap swap_builder_on_template builds on spot and spot plus five years, and "2Y2Y" starts two years after spot and runs two more.

§Errors

CurveError::UnknownIndex if template is not a swap family.