Skip to content

Term structures

Yield, volatility, default and inflation term structures.

termstructures

Runtime source shim for the native itofin.termstructures submodule.

The real itofin.termstructures is a compiled submodule registered into sys.modules by the extension (see crates/itofin-py/src/lib.rs); it wins at import time, so nothing here runs. This file exists only so static type checkers resolve from itofin.termstructures import ... from termstructures.pyi without a reportMissingModuleSource warning.

Auto-generated by scripts/gen_submodule_shims.py from termstructures.pyi; do not edit or delete by hand.

YieldTermStructure

Shared base for every yield curve: discount factors, zero and forward rates.

Concrete curves subclass this and supply only their constructor; the whole query surface below is inherited.

discount

discount(t: float, extrapolate: bool = False) -> float

Return the discount factor at year-fraction t.

Parameters:

Name Type Description Default
t float

The year fraction, in the curve's own day count.

required
extrapolate bool

Whether to answer past the curve's max date.

False

Returns:

Name Type Description
float float

The discount factor.

Raises:

Type Description
ItofinError

If t is past the curve's range and neither extrapolate nor the curve's own extrapolation flag allows it.

discount_date

discount_date(date: Date, extrapolate: bool = False) -> float

Return the discount factor from date back to the reference date.

Parameters:

Name Type Description Default
date Date

The date discounted from.

required
extrapolate bool

Whether to answer past the curve's max date.

False

Returns:

Name Type Description
float float

The discount factor.

Raises:

Type Description
ItofinError

If date is past the curve's range and extrapolation is not allowed.

zero_rate

zero_rate(t: float, extrapolate: bool = False) -> float

Return the continuously-compounded zero rate at year-fraction t.

Parameters:

Name Type Description Default
t float

The year fraction, in the curve's own day count.

required
extrapolate bool

Whether to answer past the curve's max date.

False

Returns:

Name Type Description
float float

The zero rate, continuously compounded at annual frequency.

Raises:

Type Description
ItofinError

If t is past the curve's range and extrapolation is not allowed.

forward_rate

forward_rate(t1: float, t2: float, extrapolate: bool = False) -> float

Return the continuously-compounded forward rate between t1 and t2.

Parameters:

Name Type Description Default
t1 float

The start year fraction.

required
t2 float

The end year fraction.

required
extrapolate bool

Whether to answer past the curve's max date.

False

Returns:

Name Type Description
float float

The forward rate, continuously compounded at annual frequency.

Raises:

Type Description
ItofinError

If either time is past the curve's range and extrapolation is not allowed.

reference_date

reference_date() -> Date

Return the date at which the discount factor is 1.0.

Returns:

Name Type Description
Date Date

The curve's reference date.

Raises:

Type Description
ItofinError

On a curve whose reference date moves with an evaluation date that is not set.

max_date

max_date() -> Date

Return the latest date for which the curve can return values.

Returns:

Name Type Description
Date Date

The curve's maximum date.

allows_extrapolation

allows_extrapolation() -> bool

Return whether the curve answers dates and times beyond its maximum.

Returns:

Name Type Description
bool bool

True when extrapolation is enabled on the curve itself.

enable_extrapolation

enable_extrapolation() -> None

Allow extrapolation past the maximum date and time.

disable_extrapolation

disable_extrapolation() -> None

Forbid extrapolation past the maximum date and time.

BlackVolTermStructure

Shared base for every Black-volatility surface: spot and forward vol/variance.

Concrete surfaces subclass this and supply only their constructor; the whole query surface below is inherited, along with the strike domain and the extrapolation toggles.

black_vol

black_vol(t: float, strike: float, extrapolate: bool = False) -> float

Return the spot Black volatility at year-fraction t and strike.

Parameters:

Name Type Description Default
t float

The year fraction, in the surface's own day count.

required
strike float

The strike the volatility is read at.

required
extrapolate bool

Whether to answer outside the surface's grid.

False

Returns:

Name Type Description
float float

The Black volatility.

Raises:

Type Description
ItofinError

If the query falls outside the grid and extrapolation is not allowed.

black_vol_date

black_vol_date(date: Date, strike: float, extrapolate: bool = False) -> float

Return the spot Black volatility at date and strike.

Parameters:

Name Type Description Default
date Date

The expiry the volatility is read at.

required
strike float

The strike the volatility is read at.

required
extrapolate bool

Whether to answer outside the surface's grid.

False

Returns:

Name Type Description
float float

The Black volatility.

Raises:

Type Description
ItofinError

If the query falls outside the grid and extrapolation is not allowed.

black_variance

black_variance(t: float, strike: float, extrapolate: bool = False) -> float

Return the spot Black variance at year-fraction t and strike.

Parameters:

Name Type Description Default
t float

The year fraction, in the surface's own day count.

required
strike float

The strike the variance is read at.

required
extrapolate bool

Whether to answer outside the surface's grid.

False

Returns:

Name Type Description
float float

The Black variance.

Raises:

Type Description
ItofinError

If the query falls outside the grid and extrapolation is not allowed.

black_variance_date

black_variance_date(date: Date, strike: float, extrapolate: bool = False) -> float

Return the spot Black variance at date and strike.

Parameters:

Name Type Description Default
date Date

The expiry the variance is read at.

required
strike float

The strike the variance is read at.

required
extrapolate bool

Whether to answer outside the surface's grid.

False

Returns:

Name Type Description
float float

The Black variance.

Raises:

Type Description
ItofinError

If the query falls outside the grid and extrapolation is not allowed.

black_forward_vol

black_forward_vol(t1: float, t2: float, strike: float, extrapolate: bool = False) -> float

Return the forward Black volatility between year-fractions t1 and t2.

Parameters:

Name Type Description Default
t1 float

The start year fraction.

required
t2 float

The end year fraction.

required
strike float

The strike the volatility is read at.

required
extrapolate bool

Whether to answer outside the surface's grid.

False

Returns:

Name Type Description
float float

The forward Black volatility.

Raises:

Type Description
ItofinError

If the query falls outside the grid and extrapolation is not allowed.

black_forward_variance

black_forward_variance(t1: float, t2: float, strike: float, extrapolate: bool = False) -> float

Return the forward Black variance between year-fractions t1 and t2.

Parameters:

Name Type Description Default
t1 float

The start year fraction.

required
t2 float

The end year fraction.

required
strike float

The strike the variance is read at.

required
extrapolate bool

Whether to answer outside the surface's grid.

False

Returns:

Name Type Description
float float

The forward Black variance.

Raises:

Type Description
ItofinError

If the query falls outside the grid and extrapolation is not allowed.

min_strike

min_strike() -> float

Return the minimum strike for which the surface can return volatilities.

Returns:

Name Type Description
float float

The lower bound of the strike domain.

max_strike

max_strike() -> float

Return the maximum strike for which the surface can return volatilities.

Returns:

Name Type Description
float float

The upper bound of the strike domain.

max_date

max_date() -> Date

Return the latest date for which the surface can return values.

Returns:

Name Type Description
Date Date

The surface's maximum date.

allows_extrapolation

allows_extrapolation() -> bool

Return whether the surface answers dates and times beyond its maximum.

Returns:

Name Type Description
bool bool

True when extrapolation is enabled on the surface itself.

enable_extrapolation

enable_extrapolation() -> None

Allow extrapolation past the maximum date and time.

disable_extrapolation

disable_extrapolation() -> None

Forbid extrapolation past the maximum date and time.

FlatForward

FlatForward(reference_date: Date, rate: float, day_counter: DayCounter)

Bases: YieldTermStructure

A flat continuously-compounded yield curve behind a Handle.

Built at annual frequency with continuous compounding, the convention every downstream Heston and Hull-White oracle assumes.

Build the flat curve.

Parameters:

Name Type Description Default
reference_date Date

The date at which the discount factor is 1.0.

required
rate float

The flat rate, continuously compounded at annual frequency.

required
day_counter DayCounter

The day count times are measured in.

required

ZeroCurve

ZeroCurve(dates: list[Date], yields: list[float], day_counter: DayCounter, interpolation: str = 'Linear')

Bases: YieldTermStructure

A yield curve interpolating continuously-compounded zero rates between nodes.

The first date is the reference date. Finite in time: queries past the last node require enable_extrapolation() or extrapolate=True.

Build the curve over its (date, zero-rate) nodes.

Parameters:

Name Type Description Default
dates list[Date]

The node dates, the first being the reference date.

required
yields list[float]

The continuously-compounded zero rate at each node.

required
day_counter DayCounter

The day count turning dates into times.

required
interpolation str

"Linear", the shipped behaviour, or "Cubic", the Kruger cubic factory, which is non-monotonic.

'Linear'

Raises:

Type Description
ItofinError

On an unknown interpolation name, and on whatever the core rejects about the nodes.

DiscountCurve

DiscountCurve(dates: list[Date], discounts: list[float], day_counter: DayCounter, calendar: Calendar | None = None, interpolation: str = 'LogLinear')

Bases: YieldTermStructure

A yield curve interpolating discount factors between nodes.

The first date is the reference date and its discount must be 1.0. Finite in time: queries past the last node require extrapolation.

Build the curve over its (date, discount-factor) nodes.

Parameters:

Name Type Description Default
dates list[Date]

The node dates, the first being the reference date.

required
discounts list[float]

The discount factor at each node; the first must be 1.0.

required
day_counter DayCounter

The day count turning dates into times.

required
calendar Calendar | None

The curve's calendar; unlike the other two node curves this constructor accepts one.

None
interpolation str

"LogLinear", the shipped behaviour, giving piecewise-constant forwards, or "Cubic", which is non-monotonic.

'LogLinear'

Raises:

Type Description
ItofinError

On an unknown interpolation name, and on whatever the core rejects about the nodes.

ForwardCurve

ForwardCurve(dates: list[Date], forwards: list[float], day_counter: DayCounter)

Bases: YieldTermStructure

A yield curve interpolating instantaneous forward rates backward-flat.

The first date is the reference date. Finite in time. Unlike ZeroCurve and DiscountCurve this curve offers no cubic option, QuantLib-SWIG exposing its cubic curve on the zero and discount curves only.

Build the curve over its (date, forward-rate) nodes.

Parameters:

Name Type Description Default
dates list[Date]

The node dates, the first being the reference date.

required
forwards list[float]

The instantaneous forward rate at each node.

required
day_counter DayCounter

The day count turning dates into times.

required

Raises:

Type Description
ItofinError

On whatever the core rejects about the nodes.

PiecewiseYieldCurve

PiecewiseYieldCurve(reference_date: Date, helpers: list[RateHelper], day_counter: DayCounter, interpolation: str = 'LogLinear', bootstrap: str = 'iterative', additional_helpers: list[RateHelper] | None = None)

Bases: YieldTermStructure

A yield curve bootstrapped from a strip of rate helpers, one node per maturity.

Every helper is solved so it reprices its own market quote off the curve. This string-dispatch alias covers the Discount convention; the other bootstrap conventions are reached through the named Piecewise* classes, which also expose node introspection.

bootstrap selects the algorithm: "iterative" (the default) solves one node at a time, "global" solves every node at once through a Levenberg-Marquardt fit of all helper residuals. The two are exactly determined on a plain strip and agree at every pillar to about 1e-13, so "global" is a faithful superset rather than a divergent algorithm. It is offered for "LogLinear" and "Linear" only.

What the global bootstrap adds is additional_helpers: instruments handed to the curve and registered with it that contribute neither a pillar nor a residual. Their quote is inert (reading it takes a penalty term, and penalties, additional dates and additional variables from Python are deferred), so all they do is extend the curve's max_date to their own latest_relevant_date, making dates past the last pillar queryable without extrapolation.

The bootstrap is lazy: construction only rejects an empty helper list, and the solver runs on the first query, re-running after a helper-quote or evaluation-date change. A bootstrap failure therefore surfaces from the query methods, not from the constructor.

Build the curve over helpers with a fixed reference date.

Parameters:

Name Type Description Default
reference_date Date

The curve's reference date, typically the settlement date the caller computed.

required
helpers list[RateHelper]

The bootstrap instruments; any RateHelper subclass is accepted.

required
day_counter DayCounter

The day count turning dates into times.

required
interpolation str

"LogLinear", "Linear" or "Cubic". Cubic is a global interpolator, so its bootstrap runs the multi-pass convergence loop instead of a single pass.

'LogLinear'
bootstrap str

"iterative" (the default) or "global". "global" supports "LogLinear" and "Linear" only.

'iterative'
additional_helpers list[RateHelper] | None

Instruments the global bootstrap registers without giving them a pillar or a residual. They only extend the curve's max_date to their latest_relevant_date; "iterative" rejects them.

None

Raises:

Type Description
ItofinError

On an empty helper list, on an unknown interpolation or bootstrap name, on additional helpers under "iterative", and on "Cubic" under "global".

PiecewiseLogLinearDiscount

PiecewiseLogLinearDiscount(reference_date: Date, helpers: list[RateHelper], day_counter: DayCounter)

Bases: YieldTermStructure

A curve bootstrapped in discount-factor space with log-linear interpolation.

The verbatim QuantLib-SWIG name for the blessed (Discount, LogLinear) combination. Unlike the PiecewiseYieldCurve alias, the named class retains the concrete curve so it can expose the node introspection the erased handle discards. data() are discount factors, so data()[0] is the reference node's 1.0.

Build the curve over helpers with a fixed reference date.

Parameters:

Name Type Description Default
reference_date Date

The curve's reference date.

required
helpers list[RateHelper]

The bootstrap instruments; any RateHelper subclass is accepted.

required
day_counter DayCounter

The day count turning dates into times.

required

Raises:

Type Description
ItofinError

On an empty helper list.

dates

dates() -> list[Date]

Return the bootstrapped node dates, triggering the lazy bootstrap.

Returns:

Type Description
list[Date]

list[Date]: One date per helper maturity, plus the reference node.

Raises:

Type Description
ItofinError

On a bootstrap failure.

data

data() -> list[float]

Return the bootstrapped node values, triggering the lazy bootstrap.

Returns:

Type Description
list[float]

list[float]: The discount factors, the first being 1.0.

Raises:

Type Description
ItofinError

On a bootstrap failure.

PiecewiseLinearZero

PiecewiseLinearZero(reference_date: Date, helpers: list[RateHelper], day_counter: DayCounter)

Bases: YieldTermStructure

A curve bootstrapped in zero-rate space with linear interpolation.

The verbatim QuantLib-SWIG name for the blessed (ZeroYield, Linear) combination. data() are continuously-compounded zero rates, so data()[0] mirrors the first solved pillar's rate rather than a 1.0 discount.

Build the curve over helpers with a fixed reference date.

Parameters:

Name Type Description Default
reference_date Date

The curve's reference date.

required
helpers list[RateHelper]

The bootstrap instruments.

required
day_counter DayCounter

The day count turning dates into times.

required

Raises:

Type Description
ItofinError

On an empty helper list.

dates

dates() -> list[Date]

Return the bootstrapped node dates, triggering the lazy bootstrap.

Returns:

Type Description
list[Date]

list[Date]: One date per helper maturity, plus the reference node.

Raises:

Type Description
ItofinError

On a bootstrap failure.

data

data() -> list[float]

Return the bootstrapped node values, triggering the lazy bootstrap.

Returns:

Type Description
list[float]

list[float]: The zero rates at the nodes.

Raises:

Type Description
ItofinError

On a bootstrap failure.

PiecewiseCubicZero

PiecewiseCubicZero(reference_date: Date, helpers: list[RateHelper], day_counter: DayCounter)

Bases: YieldTermStructure

A curve bootstrapped in zero-rate space with Kruger cubic interpolation.

The QuantLib-SWIG name for the (ZeroYield, Cubic) combination. Cubic is a global interpolator, so the bootstrap runs the multi-pass convergence loop instead of a single pass. data() are continuously-compounded zero rates, so data()[0] mirrors the first solved pillar's rate rather than a 1.0 discount.

Build the curve over helpers with a fixed reference date.

Parameters:

Name Type Description Default
reference_date Date

The curve's reference date.

required
helpers list[RateHelper]

The bootstrap instruments.

required
day_counter DayCounter

The day count turning dates into times.

required

Raises:

Type Description
ItofinError

On an empty helper list.

dates

dates() -> list[Date]

Return the bootstrapped node dates, triggering the lazy bootstrap.

Returns:

Type Description
list[Date]

list[Date]: One date per helper maturity, plus the reference node.

Raises:

Type Description
ItofinError

On a bootstrap failure.

data

data() -> list[float]

Return the bootstrapped node values, triggering the lazy bootstrap.

Returns:

Type Description
list[float]

list[float]: The zero rates at the nodes.

Raises:

Type Description
ItofinError

On a bootstrap failure.

PiecewiseLinearForward

PiecewiseLinearForward(reference_date: Date, helpers: list[RateHelper], day_counter: DayCounter)

Bases: YieldTermStructure

A curve bootstrapped in instantaneous forward-rate space, interpolating linearly.

The verbatim QuantLib-SWIG name for the blessed (ForwardRate, Linear) combination. data() are instantaneous forward rates.

Build the curve over helpers with a fixed reference date.

Parameters:

Name Type Description Default
reference_date Date

The curve's reference date.

required
helpers list[RateHelper]

The bootstrap instruments.

required
day_counter DayCounter

The day count turning dates into times.

required

Raises:

Type Description
ItofinError

On an empty helper list.

dates

dates() -> list[Date]

Return the bootstrapped node dates, triggering the lazy bootstrap.

Returns:

Type Description
list[Date]

list[Date]: One date per helper maturity, plus the reference node.

Raises:

Type Description
ItofinError

On a bootstrap failure.

data

data() -> list[float]

Return the bootstrapped node values, triggering the lazy bootstrap.

Returns:

Type Description
list[float]

list[float]: The instantaneous forward rates at the nodes.

Raises:

Type Description
ItofinError

On a bootstrap failure.

PiecewiseConvexMonotoneForward

PiecewiseConvexMonotoneForward(reference_date: Date, helpers: list[RateHelper], day_counter: DayCounter, bootstrap: str = 'iterative')

Bases: YieldTermStructure

A curve bootstrapped in forward-rate space with convex-monotone interpolation.

The QuantLib-SWIG name for the (ForwardRate, ConvexMonotone) combination, built with QuantLib's defaults (quadraticity 0.3, monotonicity 0.7, forced positive). ConvexMonotone is a global interpolator that reads the solved nodes as discrete forwards, so the bootstrap runs the multi-pass convergence loop. data() are instantaneous forward rates; the interpolation ignores node [0], which only mirrors the first solved pillar.

Build the curve over helpers with a fixed reference date.

Parameters:

Name Type Description Default
reference_date Date

The curve's reference date.

required
helpers list[RateHelper]

The bootstrap instruments.

required
day_counter DayCounter

The day count turning dates into times.

required
bootstrap str

"iterative", the shipped behaviour, solving one node at a time, or "local", least-squares-fitting a trailing window of nodes at each step so the non-local interpolation keeps a localised risk profile. The two reprice every pillar (the local solve to its own tolerance, about 1e-7 on the oracle strip) and diverge between them.

'iterative'

Raises:

Type Description
ItofinError

On an empty helper list, and on an unknown bootstrap name.

dates

dates() -> list[Date]

Return the bootstrapped node dates, triggering the lazy bootstrap.

Returns:

Type Description
list[Date]

list[Date]: One date per helper maturity, plus the reference node.

Raises:

Type Description
ItofinError

On a bootstrap failure.

data

data() -> list[float]

Return the bootstrapped node values, triggering the lazy bootstrap.

Returns:

Type Description
list[float]

list[float]: The instantaneous forward rates at the nodes.

Raises:

Type Description
ItofinError

On a bootstrap failure.

PiecewiseFlatForward

PiecewiseFlatForward(reference_date: Date, helpers: list[RateHelper], day_counter: DayCounter)

Bases: YieldTermStructure

A curve bootstrapped in forward-rate space, interpolating backward-flat.

The verbatim QuantLib-SWIG name for the blessed (ForwardRate, BackwardFlat) combination. Piecewise-constant instantaneous forwards make it numerically identical to PiecewiseLogLinearDiscount under every query; only data(), forward rates against discount factors, tells the two apart.

Build the curve over helpers with a fixed reference date.

Parameters:

Name Type Description Default
reference_date Date

The curve's reference date.

required
helpers list[RateHelper]

The bootstrap instruments.

required
day_counter DayCounter

The day count turning dates into times.

required

Raises:

Type Description
ItofinError

On an empty helper list.

dates

dates() -> list[Date]

Return the bootstrapped node dates, triggering the lazy bootstrap.

Returns:

Type Description
list[Date]

list[Date]: One date per helper maturity, plus the reference node.

Raises:

Type Description
ItofinError

On a bootstrap failure.

data

data() -> list[float]

Return the bootstrapped node values, triggering the lazy bootstrap.

Returns:

Type Description
list[float]

list[float]: The instantaneous forward rates at the nodes.

Raises:

Type Description
ItofinError

On a bootstrap failure.

BlackConstantVol

BlackConstantVol(reference_date: Date, volatility: float, day_counter: DayCounter, calendar: Calendar | None = None)

Bases: BlackVolTermStructure

A flat Black volatility, constant in strike and time.

Unbounded in both time and strike, so queries never need extrapolation enabled.

Build the flat surface.

Parameters:

Name Type Description Default
reference_date Date

The date times are measured from.

required
volatility float

The single volatility answered everywhere.

required
day_counter DayCounter

The day count turning dates into times.

required
calendar Calendar | None

The surface's calendar, if any.

None

BlackVolTimeExtrapolation

How a variance curve extrapolates past its last node.

UseInterpolator is accepted at construction but raises ItofinError on any extrapolating query: the interpolation layer cannot be evaluated past its last node, and the core errors rather than silently substituting another rule.

BlackVarianceCurve

BlackVarianceCurve(reference_date: Date, dates: list[Date], black_vol_curve: list[float], day_counter: DayCounter, force_monotone_variance: bool, time_extrapolation: BlackVolTimeExtrapolation = ...)

Bases: BlackVolTermStructure

A term structure of Black volatility with no strike dimension.

Interpolates linearly on variance. Finite in time: the last date is the maximum, so queries past it require enable_extrapolation(), and time_extrapolation picks the rule applied there. The interpolation itself stays linear; only the extrapolation axis is exposed.

Build the variance curve over its (date, volatility) nodes.

Parameters:

Name Type Description Default
reference_date Date

The date times are measured from.

required
dates list[Date]

The node dates.

required
black_vol_curve list[float]

The Black volatility at each node.

required
day_counter DayCounter

The day count turning dates into times.

required
force_monotone_variance bool

Whether to require the implied variance to increase across the nodes.

required
time_extrapolation BlackVolTimeExtrapolation

The rule applied past the last node; defaults to FlatVolatility, the C++ default. Selecting UseInterpolator constructs fine and answers in-range queries, then errors on an extrapolating one.

...

Raises:

Type Description
ItofinError

On whatever the core rejects about the nodes, a non-monotone variance under force_monotone_variance included.

BlackVarianceSurface

BlackVarianceSurface(reference_date: Date, dates: list[Date], strikes: list[float], black_vol_matrix: list[list[float]], day_counter: DayCounter, calendar: Calendar | None = None)

Bases: BlackVolTermStructure

A Black volatility surface in strike and expiry, interpolating bilinearly.

Finite in both time and strike, so out-of-grid queries require enable_extrapolation().

Build the surface over its strike-by-expiry grid.

Parameters:

Name Type Description Default
reference_date Date

The date times are measured from.

required
dates list[Date]

The expiry grid, one per matrix column.

required
strikes list[float]

The strike grid, one per matrix row.

required
black_vol_matrix list[list[float]]

The volatilities, one row per strike and one column per date.

required
day_counter DayCounter

The day count turning dates into times.

required
calendar Calendar | None

The surface's calendar, if any.

None

Raises:

Type Description
ItofinError

On an empty or ragged matrix, and on whatever the core rejects about the grid dimensions.

RateHelper

Shared base for every bootstrap helper: implied/market quotes and dates.

A rate helper wraps a market quote plus the schedule of a single instrument; a piecewise curve is bootstrapped so every helper reprices its own quote. Concrete helpers subclass this and supply only their constructor.

implied_quote

implied_quote() -> float

Return the quote implied by the curve the helper is linked to.

Returns:

Name Type Description
float float

The curve-implied quote.

Raises:

Type Description
ItofinError

With no curve set, the pre-bootstrap state, there being nothing to imply from.

quote_error

quote_error() -> float

Return the bootstrap root: market quote minus implied quote.

Returns:

Name Type Description
float float

The residual the solver drives to zero.

Raises:

Type Description
ItofinError

On the same condition implied_quote reports.

quote_value

quote_value() -> float

Return the current value of the market quote the helper fits.

Reads back through the retained quote handle, so a set_value on the SimpleQuote passed to the constructor is observed here: the same-object wiring the laziness contract relies on.

Returns:

Name Type Description
float float

The market quote's current value.

maturity_date

maturity_date() -> Date

Return the instrument's maturity date.

Returns:

Name Type Description
Date Date

The maturity.

pillar_date

pillar_date() -> Date

Return the date the curve node this helper sets sits at.

Returns:

Name Type Description
Date Date

The pillar date.

earliest_date

earliest_date() -> Date

Return the earliest date the helper needs curve data at.

Returns:

Name Type Description
Date Date

The earliest relevant date.

latest_date

latest_date() -> Date

Return the latest date the helper needs curve data at.

Returns:

Name Type Description
Date Date

The latest date, equal to the pillar date.

latest_relevant_date

latest_relevant_date() -> Date

Return the latest date whose data the helper is relevant for.

Returns:

Name Type Description
Date Date

The latest relevant date.

DepositRateHelper

DepositRateHelper(quote: SimpleQuote, index: IborIndex)

Bases: RateHelper

A helper fitting a deposit rate.

Build the helper over a live quote.

Parameters:

Name Type Description Default
quote SimpleQuote

The deposit rate; the caller keeps it, and mutating it later invalidates the bootstrap.

required
index IborIndex

The index supplying the deposit's schedule.

required

from_rate staticmethod

from_rate(rate: float, index: IborIndex) -> DepositRateHelper

Build the helper over a fixed rate.

Parameters:

Name Type Description Default
rate float

The deposit rate, wrapped in an internal quote the caller cannot later mutate.

required
index IborIndex

The index supplying the deposit's schedule.

required

Returns:

Name Type Description
DepositRateHelper DepositRateHelper

The helper fitting that rate.

SwapRateHelper

SwapRateHelper(quote: SimpleQuote, tenor: Period, calendar: Calendar, fixed_frequency: Frequency, fixed_convention: BusinessDayConvention, fixed_day_count: DayCounter, ibor_index: IborIndex)

Bases: RateHelper

A helper fitting a par swap rate (spot-starting, no spread).

The spot-starting form the curve-consistency oracle builds: no spread, no forward start, no exogenous discounting curve, and the default pillar.

Build the helper over the schedule of a spot-starting swap.

Parameters:

Name Type Description Default
quote SimpleQuote

The par swap rate the helper fits.

required
tenor Period

The length of the swap.

required
calendar Calendar

The calendar the schedule rolls on.

required
fixed_frequency Frequency

The fixed leg's payment frequency.

required
fixed_convention BusinessDayConvention

The fixed leg's roll.

required
fixed_day_count DayCounter

The fixed leg's day count.

required
ibor_index IborIndex

The index the floating leg fixes off.

required

FuturesType

The date convention an interest-rate future settles on.

Imm and Custom are fully usable from Python. Asx validates and prices against an explicitly supplied ASX start date, but the ASX date navigators (the analogues of itofin.time.is_imm_date / next_imm_date) are deferred, so there is no helper to derive the next ASX date from Python yet.

FuturesRateHelper

FuturesRateHelper(price: SimpleQuote, ibor_start_date: Date, length_in_months: int, calendar: Calendar, convention: BusinessDayConvention, end_of_month: bool, day_counter: DayCounter, conv_adj: SimpleQuote | None, futures_type: FuturesType)

Bases: RateHelper

A helper fitting an exchange-traded interest-rate future's quoted price.

Unlike the deposit and swap helpers the window is absolute: it is computed once from the supplied dates and never rebuilt on an evaluation-date change. The convexity adjustment is usually absent; pass conv_adj=None to leave it empty, which reports a zero adjustment.

Build the helper over a length-in-months window off the start date.

Parameters:

Name Type Description Default
price SimpleQuote

The future's quoted price.

required
ibor_start_date Date

The window's start.

required
length_in_months int

The months the start is advanced by to reach maturity.

required
calendar Calendar

The calendar the maturity rolls on.

required
convention BusinessDayConvention

The roll applied to the maturity.

required
end_of_month bool

Whether the maturity roll keeps to month ends.

required
day_counter DayCounter

The day count the year fraction uses.

required
conv_adj SimpleQuote | None

The convexity quote, or None for an empty, zero adjustment.

required
futures_type FuturesType

The date convention the future settles on.

required

Raises:

Type Description
ItofinError

If an Imm or Asx start is not a valid date of that convention.

from_end_date staticmethod

from_end_date(price: SimpleQuote, ibor_start_date: Date, ibor_end_date: Date | None, day_counter: DayCounter, conv_adj: SimpleQuote | None, futures_type: FuturesType) -> FuturesRateHelper

Build the helper over an explicit window.

Parameters:

Name Type Description Default
price SimpleQuote

The future's quoted price.

required
ibor_start_date Date

The window's start.

required
ibor_end_date Date | None

The window's end, which must be past the start; None puts the maturity three IMM/ASX periods past the start.

required
day_counter DayCounter

The day count the year fraction uses.

required
conv_adj SimpleQuote | None

The convexity quote, or None for an empty, zero adjustment.

required
futures_type FuturesType

The date convention the future settles on.

required

Returns:

Name Type Description
FuturesRateHelper FuturesRateHelper

The helper over that window.

Raises:

Type Description
ItofinError

On a Custom helper with no end date - a divergence from C++, which builds a null-maturity helper instead - and on a start that is not a valid date of the chosen convention.

from_index staticmethod

from_index(price: SimpleQuote, ibor_start_date: Date, index: IborIndex, conv_adj: SimpleQuote | None, futures_type: FuturesType) -> FuturesRateHelper

Build the helper with a window following the index's conventions.

The maturity is the start advanced by the index tenor on the index's fixing calendar, and the year fraction uses the index day counter.

Parameters:

Name Type Description Default
price SimpleQuote

The future's quoted price.

required
ibor_start_date Date

The window's start.

required
index IborIndex

The index supplying the conventions.

required
conv_adj SimpleQuote | None

The convexity quote, or None for an empty, zero adjustment.

required
futures_type FuturesType

The date convention the future settles on.

required

Returns:

Name Type Description
FuturesRateHelper FuturesRateHelper

The helper over that window.

Raises:

Type Description
ItofinError

If the start is not a valid date of the chosen convention.

convexity_adjustment

convexity_adjustment() -> float

Return the convexity adjustment applied to the forward.

Returns:

Name Type Description
float float

The convexity quote's value, or zero when none was supplied.

Pillar

The date the curve node a helper fits sits at.

MaturityDate and LastRelevantDate (the default) are the two schedule-derived choices. Pillar.CustomDate is deferred in the core (#343), so its omission here is deliberate, not an oversight.

FraRateHelper

FraRateHelper(quote: SimpleQuote, period_to_start: Period, index: IborIndex, use_indexed_coupon: bool = True, pillar: Pillar = ...)

Bases: RateHelper

A helper fitting a forward-rate-agreement rate over the window starting period_to_start after spot and spanning the index tenor. use_indexed_coupon (default True) selects the indexed implied-quote mode; False is the par simple forward. from_dates fixes the window at construction (it does not shift on an evaluation-date change).

Build the helper over the window period_to_start past spot.

Parameters:

Name Type Description Default
quote SimpleQuote

The FRA rate; the caller keeps it, so a later set_value re-drives the bootstrap.

required
period_to_start Period

How long after spot the window starts.

required
index IborIndex

The index whose tenor the window spans.

required
use_indexed_coupon bool

True selects the indexed implied-quote mode, the index fixing forecast off the curve; False is the par simple forward over the raw window.

True
pillar Pillar

The date the curve node sits at; defaults to LastRelevantDate.

...

from_rate staticmethod

from_rate(rate: float, period_to_start: Period, index: IborIndex, use_indexed_coupon: bool = True, pillar: Pillar = ...) -> FraRateHelper

Build the helper over a fixed rate.

Parameters:

Name Type Description Default
rate float

The FRA rate, wrapped in an internal quote the caller cannot later mutate.

required
period_to_start Period

How long after spot the window starts.

required
index IborIndex

The index whose tenor the window spans.

required
use_indexed_coupon bool

The implied-quote mode; see init.

True
pillar Pillar

The date the curve node sits at.

...

Returns:

Name Type Description
FraRateHelper FraRateHelper

The helper fitting that rate.

from_months staticmethod

from_months(quote: SimpleQuote, months_to_start: int, index: IborIndex, use_indexed_coupon: bool = True, pillar: Pillar = ...) -> FraRateHelper

Build the helper with a start given in months after spot.

Parameters:

Name Type Description Default
quote SimpleQuote

The FRA rate the helper fits.

required
months_to_start int

How many months after spot the window starts.

required
index IborIndex

The index whose tenor the window spans.

required
use_indexed_coupon bool

The implied-quote mode; see init.

True
pillar Pillar

The date the curve node sits at.

...

Returns:

Name Type Description
FraRateHelper FraRateHelper

The helper over that window.

from_dates staticmethod

from_dates(quote: SimpleQuote, start_date: Date, end_date: Date, index: IborIndex, use_indexed_coupon: bool = True, pillar: Pillar = ...) -> FraRateHelper

Build the helper over an explicit window.

The schedule is fixed at construction and does not shift when the evaluation date changes.

Parameters:

Name Type Description Default
quote SimpleQuote

The FRA rate the helper fits.

required
start_date Date

The window's start.

required
end_date Date

The window's end.

required
index IborIndex

The index the forward is read off.

required
use_indexed_coupon bool

The implied-quote mode; see init.

True
pillar Pillar

The date the curve node sits at.

...

Returns:

Name Type Description
FraRateHelper FraRateHelper

The helper over that window.

RateAveraging

How an overnight coupon combines its daily fixings.

Simple is the arithmetic average; Compound (daily compounding) is the coupon default the OIS conventions use.

OISRateHelper

OISRateHelper(settlement_days: int, tenor: Period, quote: SimpleQuote, overnight_index: OvernightIndex, payment_lag: int, payment_convention: BusinessDayConvention, payment_frequency: Frequency, forward_start: Period, settings: Settings, discounting_curve: YieldTermStructure | None = None, overnight_spread: SimpleQuote | None = None, pillar: Pillar = ..., averaging_method: RateAveraging = ...)

Bases: RateHelper

A helper fitting an overnight-indexed swap rate (spot-starting, floating off an overnight index).

The required knobs come first so settings can sit among them; the four optional knobs trail with defaults. discounting_curve=None discounts off the bootstrapping curve; overnight_spread=None is an empty (zero) spread. The deferred core knobs past averaging_method (telescopic value dates, lookback, lockout, observation shift, custom pillar, per-leg calendars) take benign defaults.

Build the helper over the schedule of a spot-starting OIS.

Parameters:

Name Type Description Default
settlement_days int

The days after the evaluation date the swap starts.

required
tenor Period

The length of the swap.

required
quote SimpleQuote

The OIS rate; the caller keeps it, so a later set_value re-drives the bootstrap.

required
overnight_index OvernightIndex

The index the floating leg compounds.

required
payment_lag int

The days between accrual end and payment.

required
payment_convention BusinessDayConvention

The roll applied to the payment dates.

required
payment_frequency Frequency

The payment frequency.

required
forward_start Period

How long after spot the swap starts.

required
settings Settings

The explicit settings supplying the evaluation date and the stored fixings.

required
discounting_curve YieldTermStructure | None

The curve the flows discount on; None discounts off the bootstrapping curve.

None
overnight_spread SimpleQuote | None

The spread over the index; None leaves it empty, so zero. The caller keeps it, and mutating it re-drives the bootstrap.

None
pillar Pillar

The date the curve node sits at; defaults to LastRelevantDate.

...
averaging_method RateAveraging

How the daily fixings combine; defaults to Compound.

...

BondPriceType

The price convention a bond helper fits.

Clean is the quoted price with the accrued interest stripped out; Dirty is the full settlement price. The two differ by exactly the bond's accrued amount at settlement, so the choice moves the bootstrapped curve for any bond settling mid-coupon and is a no-op for one settling on a coupon date.

FixedRateBondHelper

FixedRateBondHelper(price: SimpleQuote, settlement_days: int, face_amount: float, schedule: Schedule, coupons: list[float], day_counter: DayCounter, payment_convention: BusinessDayConvention, redemption: float, price_type: BondPriceType, settings: Settings, issue_date: Date | None = None)

Bases: RateHelper

A helper fitting the quoted price of a fixed-coupon bond it builds itself.

Unlike the schedule-derived helpers this one is a fixed-date helper: its bond and its dates are built once and do not shift when the evaluation date moves. The pillar is the bond's last cash-flow date, which rolls past the maturity whenever the final payment is date-adjusted, so read pillar_date() rather than assuming the maturity.

The constructor is contained: it takes eleven of the core's sixteen arguments and defaults the rest. Those defaults are deferrals, not oversights:

  • The four ex-coupon knobs (period, calendar, convention, end-of-month) take the no-ex-coupon defaults the core oracle passes: no period, a null calendar, Unadjusted, and False. An ex-coupon bond is not constructible from Python yet.
  • payment_calendar is defaulted to None, so the schedule's own calendar rolls the payment dates, again as the core oracle does. A bond paying on a calendar other than its schedule's is not constructible from Python yet.
  • The generic BondHelper, over an arbitrary pre-built bond, is not faced at all: it needs a bond-instrument facade, which does not exist.
  • Schedule takes no end_of_month knob, so an end-of-month bond schedule is not constructible from Python yet.

issue_date is the one core argument moved out of position: it is optional, so it trails the required price_type and settings.

Build the helper over a fixed-coupon bond assembled from the schedule.

Parameters:

Name Type Description Default
price SimpleQuote

The bond's quoted price, read as clean or dirty per price_type. The caller keeps it, so a later set_value re-drives the bootstrap.

required
settlement_days int

The days between the evaluation date and the bond's settlement date.

required
face_amount float

The notional the coupons accrue on.

required
schedule Schedule

The coupon schedule; its calendar also rolls the payment dates.

required
coupons list[float]

The coupon rates, one per period or a single rate applied to every period.

required
day_counter DayCounter

The day count the coupons accrue under.

required
payment_convention BusinessDayConvention

The roll applied to the payment dates.

required
redemption float

The redemption amount, per 100 of face.

required
price_type BondPriceType

Whether price is a clean or a dirty quote.

required
settings Settings

The explicit settings supplying the evaluation date.

required
issue_date Date | None

The bond's issue date; None leaves it unset.

None

Raises:

Type Description
ItofinError

On whatever the core rejects about the bond, and when the evaluation date is unset, since the helper resolves the bond's next cash-flow date off it.

SwaptionVolatilityStructure

Shared base for every swaption volatility surface: volatility, Black variance and lognormal shift, addressed by option and swap tenor.

volatility

volatility(option_tenor: Period, swap_tenor: Period, strike: float, extrapolate: bool = False) -> float

Return the volatility for an option tenor, swap tenor and strike.

Parameters:

Name Type Description Default
option_tenor Period

The option's tenor, resolved against the surface's reference date and calendar.

required
swap_tenor Period

The underlying swap's tenor.

required
strike float

The strike the volatility is read at.

required
extrapolate bool

Whether to answer outside the surface's grid.

False

Returns:

Name Type Description
float float

The volatility, in whichever type the surface quotes.

Raises:

Type Description
ItofinError

If the query falls outside the grid and extrapolation is not allowed.

black_variance

black_variance(option_tenor: Period, swap_tenor: Period, strike: float, extrapolate: bool = False) -> float

Return the Black variance, the squared volatility times option time.

Parameters:

Name Type Description Default
option_tenor Period

The option's tenor.

required
swap_tenor Period

The underlying swap's tenor.

required
strike float

The strike the variance is read at.

required
extrapolate bool

Whether to answer outside the surface's grid.

False

Returns:

Name Type Description
float float

The Black variance.

Raises:

Type Description
ItofinError

If the query falls outside the grid and extrapolation is not allowed.

shift

shift(option_date: Date, swap_length: float, extrapolate: bool = False) -> float

Return the lognormal shift, in the date form.

Taken in the date form because the core trait has no tenor overload for the shift, unlike the volatility and variance queries above.

Parameters:

Name Type Description Default
option_date Date

The option date the shift is read at.

required
swap_length float

The underlying swap's length, in years.

required
extrapolate bool

Whether to answer outside the surface's grid.

False

Returns:

Name Type Description
float float

The lognormal shift.

Raises:

Type Description
ItofinError

On a normal-volatility surface, where a shift has no meaning, and on an out-of-grid query without extrapolation.

reference_date

reference_date() -> Date

Return the date every option time is measured from.

Pinned at construction on the fixed-reference surfaces; derived from the Settings evaluation date (settlement days on the calendar) on the moving ones, so it follows a later set_evaluation_date.

Returns:

Name Type Description
Date Date

The surface's reference date.

Raises:

Type Description
ItofinError

On a moving surface whose Settings has no evaluation date set.

VolatilityType

Whether a surface quotes shifted-lognormal (Black) or normal (Bachelier) volatilities. A mismatch with the engine's formula surfaces at pricing time.

ConstantSwaptionVolatility

ConstantSwaptionVolatility(reference_date: Date, calendar: Calendar, business_day_convention: BusinessDayConvention, volatility: float, day_counter: DayCounter, volatility_type: VolatilityType, shift: float = 0.0)

Bases: SwaptionVolatilityStructure

A single volatility with no option-time, swap-length or strike dependence.

The constructor and with_quote pin the reference date, so every query's option time runs from reference_date rather than the evaluation date. The moving and moving_with_quote forms float the reference date off the Settings evaluation date instead (#627).

Build the surface at a fixed volatility.

Parameters:

Name Type Description Default
reference_date Date

The date every query's option time runs from.

required
calendar Calendar

The calendar option tenors resolve on.

required
business_day_convention BusinessDayConvention

The roll applied when resolving a tenor to a date.

required
volatility float

The single volatility answered everywhere, wrapped in an internal quote the caller cannot later mutate.

required
day_counter DayCounter

The day count option times are measured in.

required
volatility_type VolatilityType

Whether the quote is shifted-lognormal or normal.

required
shift float

The lognormal shift.

0.0

with_quote staticmethod

with_quote(reference_date: Date, calendar: Calendar, business_day_convention: BusinessDayConvention, volatility: SimpleQuote, day_counter: DayCounter, volatility_type: VolatilityType, shift: float = 0.0) -> ConstantSwaptionVolatility

Build the surface reading its volatility from a live quote.

Parameters:

Name Type Description Default
reference_date Date

The date every query's option time runs from.

required
calendar Calendar

The calendar option tenors resolve on.

required
business_day_convention BusinessDayConvention

The roll applied when resolving a tenor to a date.

required
volatility SimpleQuote

The volatility; a later set_value notifies the surface's observers.

required
day_counter DayCounter

The day count option times are measured in.

required
volatility_type VolatilityType

Whether the quote is shifted-lognormal or normal.

required
shift float

The lognormal shift.

0.0

Returns:

Name Type Description
ConstantSwaptionVolatility ConstantSwaptionVolatility

The surface over that quote.

moving staticmethod

moving(settlement_days: int, calendar: Calendar, business_day_convention: BusinessDayConvention, volatility: float, day_counter: DayCounter, volatility_type: VolatilityType, settings: Settings, shift: float = 0.0) -> ConstantSwaptionVolatility

Build the surface with a reference date floating off the evaluation date.

The reference date is the evaluation date advanced by settlement_days business days on calendar, so it follows a later set_evaluation_date.

Parameters:

Name Type Description Default
settlement_days int

Business days between the evaluation date and the reference date.

required
calendar Calendar

The calendar the reference date is derived on and option tenors resolve on.

required
business_day_convention BusinessDayConvention

The roll applied when resolving a tenor to a date.

required
volatility float

The single volatility answered everywhere, wrapped in an internal quote the caller cannot later mutate.

required
day_counter DayCounter

The day count option times are measured in.

required
volatility_type VolatilityType

Whether the quote is shifted-lognormal or normal.

required
settings Settings

The evaluation context the reference date floats off.

required
shift float

The lognormal shift.

0.0

Returns:

Name Type Description
ConstantSwaptionVolatility ConstantSwaptionVolatility

The moving surface.

moving_with_quote staticmethod

moving_with_quote(settlement_days: int, calendar: Calendar, business_day_convention: BusinessDayConvention, volatility: SimpleQuote, day_counter: DayCounter, volatility_type: VolatilityType, settings: Settings, shift: float = 0.0) -> ConstantSwaptionVolatility

Build the moving surface reading its volatility from a live quote.

Parameters:

Name Type Description Default
settlement_days int

Business days between the evaluation date and the reference date.

required
calendar Calendar

The calendar the reference date is derived on and option tenors resolve on.

required
business_day_convention BusinessDayConvention

The roll applied when resolving a tenor to a date.

required
volatility SimpleQuote

The volatility; a later set_value notifies the surface's observers.

required
day_counter DayCounter

The day count option times are measured in.

required
volatility_type VolatilityType

Whether the quote is shifted-lognormal or normal.

required
settings Settings

The evaluation context the reference date floats off.

required
shift float

The lognormal shift.

0.0

Returns:

Name Type Description
ConstantSwaptionVolatility ConstantSwaptionVolatility

The moving surface over that quote.

SwaptionVolatilityMatrix

SwaptionVolatilityMatrix(reference_date: Date, calendar: Calendar, business_day_convention: BusinessDayConvention, option_tenors: list[Period], swap_tenors: list[Period], volatilities: list[list[float]], day_counter: DayCounter, volatility_type: VolatilityType, shifts: list[list[float]] | None = None, flat_extrapolation: bool = False)

Bases: SwaptionVolatilityStructure

An at-the-money volatility grid, bilinear over an option-tenor x swap-tenor lattice.

Every grid is a row per option tenor and a column per swap tenor; shifts, when given, must match that shape, and None means all-zero shifts. The grid is at the money, so a query's strike is range-checked and then ignored. flat_extrapolation clamps a query past the grid to the nearest edge or corner vol instead of extending the boundary surface.

Build the grid on a pinned reference date over fixed volatilities.

Every query's option time runs from reference_date rather than from the evaluation date.

Parameters:

Name Type Description Default
reference_date Date

The date option times run from.

required
calendar Calendar

The calendar option tenors resolve on.

required
business_day_convention BusinessDayConvention

The roll applied when resolving a tenor to a date.

required
option_tenors list[Period]

The option axis, one per grid row.

required
swap_tenors list[Period]

The swap axis, one per grid column.

required
volatilities list[list[float]]

The at-the-money volatilities, one row per option tenor.

required
day_counter DayCounter

The day count option times are measured in.

required
volatility_type VolatilityType

Whether the grid is shifted-lognormal or normal.

required
shifts list[list[float]] | None

The lognormal shifts in the same shape as volatilities; None means all-zero shifts.

None
flat_extrapolation bool

Whether a query past the grid clamps to the nearest edge or corner vol instead of extending the boundary surface.

False

Raises:

Type Description
ItofinError

On an empty or ragged grid, a shifts grid that does not match the volatilities shape, and on whatever the core rejects about the axes.

moving staticmethod

moving(calendar: Calendar, business_day_convention: BusinessDayConvention, option_tenors: list[Period], swap_tenors: list[Period], volatilities: list[list[SimpleQuote]], day_counter: DayCounter, volatility_type: VolatilityType, settings: Settings, shifts: list[list[float]] | None = None, flat_extrapolation: bool = False) -> SwaptionVolatilityMatrix

Build a grid whose reference date floats off the evaluation date.

The reference date sits at zero settlement days from the evaluation date, and each node is read from the caller's quote.

Parameters:

Name Type Description Default
calendar Calendar

The calendar option tenors resolve on.

required
business_day_convention BusinessDayConvention

The roll applied when resolving a tenor to a date.

required
option_tenors list[Period]

The option axis, one per grid row.

required
swap_tenors list[Period]

The swap axis, one per grid column.

required
volatilities list[list[SimpleQuote]]

The at-the-money volatility quotes; a later set_value on any of them rebuilds the interpolation and notifies the grid's observers.

required
day_counter DayCounter

The day count option times are measured in.

required
volatility_type VolatilityType

Whether the grid is shifted-lognormal or normal.

required
settings Settings

The explicit settings supplying the evaluation date the reference date floats off.

required
shifts list[list[float]] | None

The lognormal shifts in the same shape as volatilities; None means all-zero shifts.

None
flat_extrapolation bool

Whether a query past the grid clamps to the nearest edge or corner vol.

False

Returns:

Name Type Description
SwaptionVolatilityMatrix SwaptionVolatilityMatrix

The moving grid.

Raises:

Type Description
ItofinError

On an empty or ragged grid, a mismatched shifts shape, and on whatever the core rejects about the axes.

InterpolatedSwaptionVolatilityCube

InterpolatedSwaptionVolatilityCube(atm_vol: SwaptionVolatilityStructure, option_tenors: list[Period], swap_tenors: list[Period], strike_spreads: list[float], vol_spreads: list[list[SimpleQuote]], swap_index_base: SwapIndex, short_swap_index_base: SwapIndex, settings: Settings, vega_weighted_smile_fit: bool = False)

Bases: SwaptionVolatilityStructure

A smile cube adding bilinearly-interpolated volatility spreads to an at-the-money surface.

The inherited volatility query now takes a real strike: the cube reads the at-the-money forward off its base swap indexes, the at-the-money volatility off atm_vol, and adds the spread interpolated at strike - atm_strike.

vol_spreads is row-major over the (option tenor, swap tenor) nodes: row i * len(swap_tenors) + j is the smile at (option_tenors[i], swap_tenors[j]), holding one quote per entry of strike_spreads. A later set_value on any of those quotes rebuilds the per-strike interpolators.

Build the cube over an at-the-money surface and its vol spreads.

Parameters:

Name Type Description Default
atm_vol SwaptionVolatilityStructure

The at-the-money surface the spreads are added to.

required
option_tenors list[Period]

The option axis of the node grid.

required
swap_tenors list[Period]

The swap axis of the node grid.

required
strike_spreads list[float]

The moneyness offsets each smile is quoted at.

required
vol_spreads list[list[SimpleQuote]]

The spread quotes, row-major over the nodes with one quote per strike spread; a later set_value rebuilds the per-strike interpolators.

required
swap_index_base SwapIndex

The long base swap index.

required
short_swap_index_base SwapIndex

The short base swap index, whose tenor must not exceed the long one's.

required
settings Settings

The explicit settings supplying the evaluation date and the stored fixings.

required
vega_weighted_smile_fit bool

Whether the smile fit is vega-weighted.

False

Raises:

Type Description
ItofinError

On an empty or ragged vol_spreads grid, on a row count that is not one per node or a row length that is not one per strike spread, and on whatever the core rejects.

atm_strike_from_tenor

atm_strike_from_tenor(option_tenor: Period, swap_tenor: Period) -> float

Return the at-the-money strike for an option tenor and swap tenor.

The fixing of whichever base swap index the swap tenor selects, off the option date the tenor resolves to against the cube's reference date and calendar. It lives on the concrete cube rather than the inherited base because it belongs to the cube framework, not the volatility structure.

Parameters:

Name Type Description Default
option_tenor Period

The option's tenor.

required
swap_tenor Period

The underlying swap's tenor, which selects the base index.

required

Returns:

Name Type Description
float float

The at-the-money strike a query is centred on.

Raises:

Type Description
ItofinError

On whatever the selected index's fixing reports, an unset evaluation date or an unlinked forwarding curve included.

SabrSmileSection

SabrSmileSection(exercise_time: float, forward: float, alpha: float, beta: float, nu: float, rho: float, shift: float = 0.0, volatility_type: VolatilityType = ...)

One option expiry's volatility smile, read off the closed-form Hagan SABR formula at fixed parameters.

There is no calibration here: the four parameters are inputs. A fitted smile is what SabrSwaptionVolatilityCube serves; this class is for querying a smile whose parameters are already known.

Build the smile at a given exercise time and forward.

Only the exercise-time form is wrapped; the date-anchored one differs from it only in computing that time from a reference date and a day counter, which a caller can do with DayCounter.year_fraction.

Parameters:

Name Type Description Default
exercise_time float

The option's exercise time, in years.

required
forward float

The forward the smile is centred on.

required
alpha float

The SABR alpha, which must be positive.

required
beta float

The SABR beta, which must lie in [0, 1].

required
nu float

The SABR nu, which must be non-negative.

required
rho float

The SABR rho, whose square must be below 1.

required
shift float

The lognormal shift; a non-zero shift is deferred and refused.

0.0
volatility_type VolatilityType

The quoting convention; Normal is deferred and refused.

...

Raises:

Type Description
ItofinError

On a non-zero shift or a Normal volatility_type, both deferred to #586; on a non-positive shifted forward; and on SABR parameters outside their admissible ranges.

exercise_time property

exercise_time: float

The exercise time the smile was built for.

Returns:

Name Type Description
float float

The exercise time, in years.

atm_level property

atm_level: float

The at-the-money level.

Returns:

Name Type Description
float float

The forward the smile is centred on.

alpha property

alpha: float

The SABR alpha parameter.

Returns:

Name Type Description
float float

The alpha the smile was built with.

beta property

beta: float

The SABR beta parameter.

Returns:

Name Type Description
float float

The beta the smile was built with.

nu property

nu: float

The SABR nu parameter.

Returns:

Name Type Description
float float

The nu the smile was built with.

rho property

rho: float

The SABR rho parameter.

Returns:

Name Type Description
float float

The rho the smile was built with.

volatility

volatility(strike: float) -> float

Return the volatility at strike.

Parameters:

Name Type Description Default
strike float

The strike; strikes below the shifted domain floor are clamped to it rather than rejected, as the core does.

required

Returns:

Name Type Description
float float

The Hagan SABR volatility.

Raises:

Type Description
ItofinError

On whatever the closed-form evaluation rejects.

variance

variance(strike: float) -> float

Return the Black variance at strike.

Parameters:

Name Type Description Default
strike float

The strike the variance is read at.

required

Returns:

Name Type Description
float float

The squared volatility times the exercise time.

Raises:

Type Description
ItofinError

On whatever the closed-form evaluation rejects.

SabrSwaptionVolatilityCube

SabrSwaptionVolatilityCube(atm_vol: SwaptionVolatilityStructure, option_tenors: list[Period], swap_tenors: list[Period], strike_spreads: list[float], vol_spreads: list[list[SimpleQuote]], swap_index_base: SwapIndex, short_swap_index_base: SwapIndex, parameters_guess: list[list[SimpleQuote]], is_parameter_fixed: list[bool], is_atm_calibrated: bool, settings: Settings, vega_weighted_smile_fit: bool = False, use_max_error: bool = False, max_guesses: int = 50, cutoff_strike: float = 0.0001)

Bases: SwaptionVolatilityStructure

A smile cube whose every node is a SABR smile fitted to the at-the-money volatility plus the market vol spreads.

The inherited volatility query takes a real strike and answers off the fitted smile rather than an interpolated spread. Construction is where the work happens: every node is calibrated by Levenberg-Marquardt, and with is_atm_calibrated a second dense pass re-anchors the fitted smiles on the at-the-money surface.

vol_spreads and parameters_guess are both row-major over the (option tenor, swap tenor) nodes: row i * len(swap_tenors) + j is the node at (option_tenors[i], swap_tenors[j]). A vol_spreads row holds one quote per entry of strike_spreads; a parameters_guess row holds the four SABR starting values [alpha, beta, nu, rho]. is_parameter_fixed pins a parameter at its guess across every node, in that same order.

The end criteria, maximum error tolerance, optimisation method and accepted error are left at the core's C++ defaults. Backward-flat interpolation (core #606) is not exposed, and the optimisation method is always Levenberg-Marquardt, since a trait object does not cross FFI. ZABR and the generic XABR cube are a separate core track (#597), and the section- recalibration API is unported in the core: re-fit by bumping the guess or vol-spread quotes.

Build the cube, calibrating every node on construction.

The end criteria, the maximum error tolerance, the optimisation method and the accepted error are left at the core's C++ defaults.

Parameters:

Name Type Description Default
atm_vol SwaptionVolatilityStructure

The at-the-money surface the fitted smiles are anchored on.

required
option_tenors list[Period]

The option axis of the node grid.

required
swap_tenors list[Period]

The swap axis of the node grid.

required
strike_spreads list[float]

The moneyness offsets each smile is quoted at.

required
vol_spreads list[list[SimpleQuote]]

The spread quotes, row-major over the nodes with one quote per strike spread.

required
swap_index_base SwapIndex

The long base swap index.

required
short_swap_index_base SwapIndex

The short base swap index.

required
parameters_guess list[list[SimpleQuote]]

The SABR starting values, row-major over the nodes, each row holding alpha, beta, nu and rho in that order.

required
is_parameter_fixed list[bool]

Which of the four parameters are pinned at their guess across every node, in that same order.

required
is_atm_calibrated bool

Whether a second dense pass re-anchors the fitted smiles on the at-the-money surface.

required
settings Settings

The explicit settings supplying the evaluation date and the stored fixings.

required
vega_weighted_smile_fit bool

Whether the smile fit is vega-weighted.

False
use_max_error bool

Whether the fit is judged on the maximum error rather than the aggregate one.

False
max_guesses int

How many starting guesses a node may try.

50
cutoff_strike float

The strike floor the fit is evaluated above.

0.0001

Raises:

Type Description
ItofinError

On an empty or ragged vol_spreads or parameters_guess grid, on a row count that is not one per node, on an is_parameter_fixed list that is not four entries long, on a normal at-the-money surface, which needs the deferred normal SABR formula, and on a calibration failure.

atm_strike_from_tenor

atm_strike_from_tenor(option_tenor: Period, swap_tenor: Period) -> float

Return the at-the-money strike for an option tenor and swap tenor.

The fixing of whichever base swap index the swap tenor selects, and the strike the fitted smile is centred on, so it is what a caller needs to place a query at a given moneyness.

Parameters:

Name Type Description Default
option_tenor Period

The option's tenor.

required
swap_tenor Period

The underlying swap's tenor, which selects the base index.

required

Returns:

Name Type Description
float float

The at-the-money strike.

Raises:

Type Description
ItofinError

On whatever the selected index's fixing reports, an unset evaluation date or an unlinked forwarding curve included.

OptionletVolatilityStructure

Shared base for every caplet/floorlet volatility surface: volatility, Black variance and the lognormal displacement.

A single option axis, unlike the swaption surfaces: a query takes one option tenor (or date) and a strike.

volatility

volatility(option_tenor: Period, strike: float, extrapolate: bool = False) -> float

Return the caplet volatility for an option tenor and strike.

Parameters:

Name Type Description Default
option_tenor Period

The option's tenor, resolved against the surface's reference date and calendar.

required
strike float

The strike the volatility is read at.

required
extrapolate bool

Whether to answer outside the surface's grid.

False

Returns:

Name Type Description
float float

The caplet volatility.

Raises:

Type Description
ItofinError

If the query falls outside the grid and extrapolation is not allowed.

volatility_date

volatility_date(option_date: Date, strike: float, extrapolate: bool = False) -> float

Return the caplet volatility for an option date and strike.

The date form the optionlet stripper and the cap/floor engine use, both addressing the surface by a coupon's fixing date.

Parameters:

Name Type Description Default
option_date Date

The option date the volatility is read at.

required
strike float

The strike the volatility is read at.

required
extrapolate bool

Whether to answer outside the surface's grid.

False

Returns:

Name Type Description
float float

The caplet volatility.

Raises:

Type Description
ItofinError

If the query falls outside the grid and extrapolation is not allowed.

black_variance

black_variance(option_tenor: Period, strike: float, extrapolate: bool = False) -> float

Return the Black variance, the squared volatility times option time.

Parameters:

Name Type Description Default
option_tenor Period

The option's tenor.

required
strike float

The strike the variance is read at.

required
extrapolate bool

Whether to answer outside the surface's grid.

False

Returns:

Name Type Description
float float

The Black variance.

Raises:

Type Description
ItofinError

If the query falls outside the grid and extrapolation is not allowed.

allows_extrapolation

allows_extrapolation() -> bool

Return whether the surface answers dates and times beyond its maximum.

Returns:

Name Type Description
bool bool

True when extrapolation is enabled on the surface itself.

enable_extrapolation

enable_extrapolation() -> None

Allow extrapolation past the maximum date and time.

A stripped surface ends at its last optionlet fixing, so a cap whose own last caplet fixes there queries the boundary.

disable_extrapolation

disable_extrapolation() -> None

Forbid extrapolation past the maximum date and time.

displacement

displacement() -> float

Return the lognormal shift applied to forwards and strikes.

This is what BlackCapFloorEngine checks a caller-supplied displacement against, so it is the number to read before pinning one on the engine.

Returns:

Name Type Description
float float

The shift; zero for the unshifted lognormal and the normal model.

reference_date

reference_date() -> Date

Return the date every option time is measured from.

Pinned at construction on the fixed-reference surfaces; derived from the Settings evaluation date (settlement days on the calendar) on the moving ones, so it follows a later set_evaluation_date.

Returns:

Name Type Description
Date Date

The surface's reference date.

Raises:

Type Description
ItofinError

On a moving surface whose Settings has no evaluation date set.

ConstantOptionletVolatility

ConstantOptionletVolatility(reference_date: Date, calendar: Calendar, business_day_convention: BusinessDayConvention, volatility: float, day_counter: DayCounter, volatility_type: VolatilityType, displacement: float = 0.0)

Bases: OptionletVolatilityStructure

A single caplet volatility with no option-time or strike dependence.

The constructor and with_quote pin the reference date, so every query's option time runs from reference_date rather than the evaluation date. The moving and moving_with_quote forms float the reference date off the Settings evaluation date instead (#627).

Build the surface at a fixed volatility.

Parameters:

Name Type Description Default
reference_date Date

The date every query's option time runs from.

required
calendar Calendar

The calendar option tenors resolve on.

required
business_day_convention BusinessDayConvention

The roll applied when resolving a tenor to a date.

required
volatility float

The single volatility answered everywhere, wrapped in an internal quote the caller cannot later mutate.

required
day_counter DayCounter

The day count option times are measured in.

required
volatility_type VolatilityType

Whether the quote is shifted-lognormal or normal.

required
displacement float

The lognormal shift applied to forwards and strikes.

0.0

with_quote staticmethod

with_quote(reference_date: Date, calendar: Calendar, business_day_convention: BusinessDayConvention, volatility: SimpleQuote, day_counter: DayCounter, volatility_type: VolatilityType, displacement: float = 0.0) -> ConstantOptionletVolatility

Build the surface reading its volatility from a live quote.

Parameters:

Name Type Description Default
reference_date Date

The date every query's option time runs from.

required
calendar Calendar

The calendar option tenors resolve on.

required
business_day_convention BusinessDayConvention

The roll applied when resolving a tenor to a date.

required
volatility SimpleQuote

The volatility; a later set_value notifies the surface's observers.

required
day_counter DayCounter

The day count option times are measured in.

required
volatility_type VolatilityType

Whether the quote is shifted-lognormal or normal.

required
displacement float

The lognormal shift applied to forwards and strikes.

0.0

Returns:

Name Type Description
ConstantOptionletVolatility ConstantOptionletVolatility

The surface over that quote.

moving staticmethod

moving(settlement_days: int, calendar: Calendar, business_day_convention: BusinessDayConvention, volatility: float, day_counter: DayCounter, volatility_type: VolatilityType, settings: Settings, displacement: float = 0.0) -> ConstantOptionletVolatility

Build the surface with a reference date floating off the evaluation date.

The reference date is the evaluation date advanced by settlement_days business days on calendar, so it follows a later set_evaluation_date.

Parameters:

Name Type Description Default
settlement_days int

Business days between the evaluation date and the reference date.

required
calendar Calendar

The calendar the reference date is derived on and option tenors resolve on.

required
business_day_convention BusinessDayConvention

The roll applied when resolving a tenor to a date.

required
volatility float

The single volatility answered everywhere, wrapped in an internal quote the caller cannot later mutate.

required
day_counter DayCounter

The day count option times are measured in.

required
volatility_type VolatilityType

Whether the quote is shifted-lognormal or normal.

required
settings Settings

The evaluation context the reference date floats off.

required
displacement float

The lognormal shift applied to forwards and strikes.

0.0

Returns:

Name Type Description
ConstantOptionletVolatility ConstantOptionletVolatility

The moving surface.

moving_with_quote staticmethod

moving_with_quote(settlement_days: int, calendar: Calendar, business_day_convention: BusinessDayConvention, volatility: SimpleQuote, day_counter: DayCounter, volatility_type: VolatilityType, settings: Settings, displacement: float = 0.0) -> ConstantOptionletVolatility

Build the moving surface reading its volatility from a live quote.

Parameters:

Name Type Description Default
settlement_days int

Business days between the evaluation date and the reference date.

required
calendar Calendar

The calendar the reference date is derived on and option tenors resolve on.

required
business_day_convention BusinessDayConvention

The roll applied when resolving a tenor to a date.

required
volatility SimpleQuote

The volatility; a later set_value notifies the surface's observers.

required
day_counter DayCounter

The day count option times are measured in.

required
volatility_type VolatilityType

Whether the quote is shifted-lognormal or normal.

required
settings Settings

The evaluation context the reference date floats off.

required
displacement float

The lognormal shift applied to forwards and strikes.

0.0

Returns:

Name Type Description
ConstantOptionletVolatility ConstantOptionletVolatility

The moving surface over that quote.

CapFloorTermVolSurface

CapFloorTermVolSurface(reference_date: Date, calendar: Calendar, business_day_convention: BusinessDayConvention, option_tenors: list[Period], strikes: list[float], volatilities: list[list[float]], day_counter: DayCounter)

The market cap/floor TERM-volatility surface, bicubic over an option-tenor x strike grid.

This is the flat volatility of a WHOLE cap by cap length, which is how the market quotes caps, not the volatility of the individual caplets it decomposes into: it is the optionlet stripper's input, and it is not an OptionletVolatilityStructure.

volatilities is a row per option tenor and a column per strike; both axes must be strictly increasing.

All four constructors are exposed. init and with_quotes pin the reference date, so every query's option time runs from reference_date rather than the evaluation date. moving and moving_with_quotes float it settlement_days off the evaluation date, and are what the optionlet stripping pipeline runs on: StrippedOptionletAdapter reads its settlement days back off this surface, and a pinned-reference surface has none.

Build the surface on a pinned reference date over fixed volatilities.

Every query's option time runs from reference_date, not from the evaluation date, and no later mutation can reach the grid.

Parameters:

Name Type Description Default
reference_date Date

The date option times run from.

required
calendar Calendar

The calendar cap tenors resolve on.

required
business_day_convention BusinessDayConvention

The roll applied when resolving a tenor to a date.

required
option_tenors list[Period]

The cap-length axis, one per grid row; strictly increasing.

required
strikes list[float]

The strike axis, one per grid column; strictly increasing.

required
volatilities list[list[float]]

The flat cap volatilities, one row per option tenor.

required
day_counter DayCounter

The day count option times are measured in.

required

Raises:

Type Description
ItofinError

On an empty or ragged grid, on a grid whose shape does not match the tenors and strikes, and on a non-increasing tenor or strike axis.

with_quotes staticmethod

with_quotes(reference_date: Date, calendar: Calendar, business_day_convention: BusinessDayConvention, option_tenors: list[Period], strikes: list[float], volatilities: list[list[SimpleQuote]], day_counter: DayCounter) -> CapFloorTermVolSurface

Build the pinned-reference surface over live quotes.

Parameters:

Name Type Description Default
reference_date Date

The date option times run from.

required
calendar Calendar

The calendar cap tenors resolve on.

required
business_day_convention BusinessDayConvention

The roll applied when resolving a tenor to a date.

required
option_tenors list[Period]

The cap-length axis, strictly increasing.

required
strikes list[float]

The strike axis, strictly increasing.

required
volatilities list[list[SimpleQuote]]

The volatility quotes, one row per option tenor; a later set_value rebuilds the interpolation and notifies the surface's observers.

required
day_counter DayCounter

The day count option times are measured in.

required

Returns:

Name Type Description
CapFloorTermVolSurface CapFloorTermVolSurface

The surface over those quotes.

Raises:

Type Description
ItofinError

On the same conditions init reports.

moving staticmethod

moving(settlement_days: int, calendar: Calendar, business_day_convention: BusinessDayConvention, option_tenors: list[Period], strikes: list[float], volatilities: list[list[float]], day_counter: DayCounter, settings: Settings) -> CapFloorTermVolSurface

Build a surface whose reference date floats off the evaluation date.

This is the form the optionlet stripping pipeline needs: unlike the pinned-reference constructors, it carries the settlement days StrippedOptionletAdapter reads back off the stripper.

Parameters:

Name Type Description Default
settlement_days int

The business days the reference date sits past the evaluation date.

required
calendar Calendar

The calendar cap tenors resolve on.

required
business_day_convention BusinessDayConvention

The roll applied when resolving a tenor to a date.

required
option_tenors list[Period]

The cap-length axis, strictly increasing.

required
strikes list[float]

The strike axis, strictly increasing.

required
volatilities list[list[float]]

The flat cap volatilities, one row per option tenor.

required
day_counter DayCounter

The day count option times are measured in.

required
settings Settings

The explicit settings supplying the evaluation date the reference date floats off.

required

Returns:

Name Type Description
CapFloorTermVolSurface CapFloorTermVolSurface

The floating-reference surface.

Raises:

Type Description
ItofinError

On the same conditions init reports.

moving_with_quotes staticmethod

moving_with_quotes(settlement_days: int, calendar: Calendar, business_day_convention: BusinessDayConvention, option_tenors: list[Period], strikes: list[float], volatilities: list[list[SimpleQuote]], day_counter: DayCounter, settings: Settings) -> CapFloorTermVolSurface

Build the floating-reference surface over live quotes.

Parameters:

Name Type Description Default
settlement_days int

The business days the reference date sits past the evaluation date.

required
calendar Calendar

The calendar cap tenors resolve on.

required
business_day_convention BusinessDayConvention

The roll applied when resolving a tenor to a date.

required
option_tenors list[Period]

The cap-length axis, strictly increasing.

required
strikes list[float]

The strike axis, strictly increasing.

required
volatilities list[list[SimpleQuote]]

The volatility quotes, one row per option tenor.

required
day_counter DayCounter

The day count option times are measured in.

required
settings Settings

The explicit settings supplying the evaluation date the reference date floats off.

required

Returns:

Name Type Description
CapFloorTermVolSurface CapFloorTermVolSurface

The floating-reference surface over those quotes.

Raises:

Type Description
ItofinError

On the same conditions init reports.

volatility

volatility(option_tenor: Period, strike: float, extrapolate: bool = False) -> float

Return the flat cap volatility for a cap tenor and strike.

The tenor form resolves against the surface's own calendar and business-day convention, so it is the one to reach for unless a date is already in hand.

Parameters:

Name Type Description Default
option_tenor Period

The cap's length.

required
strike float

The strike the volatility is read at.

required
extrapolate bool

Whether to answer outside the surface's grid.

False

Returns:

Name Type Description
float float

The flat cap volatility.

Raises:

Type Description
ItofinError

If the query falls outside the grid and extrapolation is not allowed.

volatility_date

volatility_date(end_date: Date, strike: float, extrapolate: bool = False) -> float

Return the flat cap volatility for a cap end date and strike.

Parameters:

Name Type Description Default
end_date Date

The cap's end date.

required
strike float

The strike the volatility is read at.

required
extrapolate bool

Whether to answer outside the surface's grid.

False

Returns:

Name Type Description
float float

The flat cap volatility.

Raises:

Type Description
ItofinError

If the query falls outside the grid and extrapolation is not allowed.

volatility_time

volatility_time(length: float, strike: float, extrapolate: bool = False) -> float

Return the flat cap volatility for a cap end time and strike.

Parameters:

Name Type Description Default
length float

A year fraction off the reference date, in the surface's own day count.

required
strike float

The strike the volatility is read at.

required
extrapolate bool

Whether to answer outside the surface's grid.

False

Returns:

Name Type Description
float float

The flat cap volatility.

Raises:

Type Description
ItofinError

If the query falls outside the grid and extrapolation is not allowed.

OptionletStripper1

OptionletStripper1(term_vol_surface: CapFloorTermVolSurface, ibor_index: IborIndex, volatility_type: VolatilityType, accuracy: float = 1e-06, max_iter: int = 100, displacement: float = 0.0, discount: YieldTermStructure | None = None, optionlet_frequency: Period | None = None)

Bootstraps caplet volatilities out of a market cap/floor term-volatility surface.

Not itself a volatility surface: it produces a grid of caplet volatilities that StrippedOptionletAdapter interpolates into one. Stripping is lazy and cached, and re-runs only when a surface quote or the index changes.

term_vol_surface must come from CapFloorTermVolSurface.moving or moving_with_quotes; a pinned-reference surface carries no settlement days and fails the adapter. VolatilityType.Normal is deferred (#440/#577) and fails at the strip, not at construction.

Build the stripper over a term-volatility surface and an index.

It prices a cap at each of its own lengths off term_vol_surface, differences consecutive prices into a single caplet price, and inverts that for the caplet's implied volatility.

Parameters:

Name Type Description Default
term_vol_surface CapFloorTermVolSurface

The market term volatilities; it must be one of the moving forms, a pinned-reference surface carrying no settlement days.

required
ibor_index IborIndex

The index the caplets fix off.

required
volatility_type VolatilityType

The quoting convention; Normal is deferred and fails at the strip, not here.

required
accuracy float

The tolerance of the implied-volatility solve.

1e-06
max_iter int

The iteration cap of that solve.

100
displacement float

The lognormal shift applied to forwards and strikes.

0.0
discount YieldTermStructure | None

The curve the caps are priced on; None falls back to the index's own forwarding curve.

None
optionlet_frequency Period | None

The caplet step; None uses the index tenor.

None

Raises:

Type Description
ItofinError

On whatever the core rejects about the surface, the index or the solve parameters.

switch_strike

switch_strike() -> float

Return the floating switch strike, the mean at-the-money caplet rate.

It decides whether each strike is stripped out of caps or out of floors. The first call triggers the strip.

Returns:

Name Type Description
float float

The switch strike.

Raises:

Type Description
ItofinError

On a stripping failure, which a Normal volatility_type always is.

atm_optionlet_rates

atm_optionlet_rates() -> list[float]

Return the at-the-money forward rate of each caplet.

Returns:

Type Description
list[float]

list[float]: One rate per maturity.

Raises:

Type Description
ItofinError

On a stripping failure.

StrippedOptionletAdapter

StrippedOptionletAdapter(stripper: OptionletStripper1, settings: Settings)

Bases: OptionletVolatilityStructure

Serves a stripper's caplet volatility grid as an OptionletVolatilityStructure: linear in strike within each maturity, then linear across maturities.

This closes the cap/floor volatility loop - a BlackCapFloorEngine on this surface reprices the caps the term volatilities were quoted on. The reference date floats off the evaluation date carried by settings, advanced by the term-volatility surface's settlement days. The surface ends at the last caplet fixing, so pricing a cap that reaches it wants enable_extrapolation().

Build the interpolated surface over a stripper.

It strips eagerly: the constructor reads the caplet strikes and fixing dates to snapshot its strike domain and maximum date.

Parameters:

Name Type Description Default
stripper OptionletStripper1

The stripper whose caplet grid is served.

required
settings Settings

The explicit settings supplying the evaluation date the reference date floats off.

required

Raises:

Type Description
ItofinError

On a stripper whose term-volatility surface carries no settlement days, which is every pinned-reference surface, and on a stripping failure.

DefaultProbabilityTermStructure

Shared base for every credit curve: survival and default probabilities, the default density and the hazard rate, each in a year-fraction and a date form.

survival_probability

survival_probability(t: float, extrapolate: bool = False) -> float

Return the survival probability from the reference date to year-fraction t.

Parameters:

Name Type Description Default
t float

The year fraction, in the curve's own day count.

required
extrapolate bool

Whether to answer past the curve's max date.

False

Returns:

Name Type Description
float float

The probability of surviving to t.

Raises:

Type Description
ItofinError

If t is past the curve's range and extrapolation is not allowed.

survival_probability_date

survival_probability_date(date: Date, extrapolate: bool = False) -> float

Return the survival probability from the reference date to date.

Parameters:

Name Type Description Default
date Date

The date survived to.

required
extrapolate bool

Whether to answer past the curve's max date.

False

Returns:

Name Type Description
float float

The survival probability.

Raises:

Type Description
ItofinError

If date is past the curve's range and extrapolation is not allowed.

default_probability

default_probability(t: float, extrapolate: bool = False) -> float

Return the default probability from the reference date to year-fraction t.

Parameters:

Name Type Description Default
t float

The year fraction, in the curve's own day count.

required
extrapolate bool

Whether to answer past the curve's max date.

False

Returns:

Name Type Description
float float

The probability of defaulting by t.

Raises:

Type Description
ItofinError

If t is past the curve's range and extrapolation is not allowed.

default_probability_date

default_probability_date(date: Date, extrapolate: bool = False) -> float

Return the default probability from the reference date to date.

Parameters:

Name Type Description Default
date Date

The date defaulted by.

required
extrapolate bool

Whether to answer past the curve's max date.

False

Returns:

Name Type Description
float float

The default probability.

Raises:

Type Description
ItofinError

If date is past the curve's range and extrapolation is not allowed.

default_density

default_density(t: float, extrapolate: bool = False) -> float

Return the default density at year-fraction t.

Parameters:

Name Type Description Default
t float

The year fraction, in the curve's own day count.

required
extrapolate bool

Whether to answer past the curve's max date.

False

Returns:

Name Type Description
float float

The default density.

Raises:

Type Description
ItofinError

If t is past the curve's range and extrapolation is not allowed.

default_density_date

default_density_date(date: Date, extrapolate: bool = False) -> float

Return the default density at date.

Parameters:

Name Type Description Default
date Date

The date the density is read at.

required
extrapolate bool

Whether to answer past the curve's max date.

False

Returns:

Name Type Description
float float

The default density.

Raises:

Type Description
ItofinError

If date is past the curve's range and extrapolation is not allowed.

hazard_rate

hazard_rate(t: float, extrapolate: bool = False) -> float

Return the hazard rate at year-fraction t.

Parameters:

Name Type Description Default
t float

The year fraction, in the curve's own day count.

required
extrapolate bool

Whether to answer past the curve's max date.

False

Returns:

Name Type Description
float float

The hazard rate, at annual frequency and continuous compounding.

Raises:

Type Description
ItofinError

If t is past the curve's range and extrapolation is not allowed.

hazard_rate_date

hazard_rate_date(date: Date, extrapolate: bool = False) -> float

Return the hazard rate at date.

Parameters:

Name Type Description Default
date Date

The date the rate is read at.

required
extrapolate bool

Whether to answer past the curve's max date.

False

Returns:

Name Type Description
float float

The hazard rate, at annual frequency and continuous compounding.

Raises:

Type Description
ItofinError

If date is past the curve's range and extrapolation is not allowed.

FlatHazardRate

FlatHazardRate(reference_date: Date, hazard_rate: SimpleQuote, day_counter: DayCounter)

Bases: DefaultProbabilityTermStructure

A credit curve quoting one hazard rate for every maturity, whose survival probability is the closed form exp(-h t).

The quote-backed forms retain the caller's SimpleQuote, so a later set_value moves the curve; the rate-backed forms wrap the value in a fresh, un-retained quote. The moving forms fix the reference date settlement_days business days past the evaluation date carried by settings.

Build a curve reading its hazard rate live, on a pinned reference date.

Parameters:

Name Type Description Default
reference_date Date

The date times are measured from.

required
hazard_rate SimpleQuote

The hazard rate; the caller keeps it, so a later set_value moves the curve.

required
day_counter DayCounter

The day count turning dates into times.

required

with_rate staticmethod

with_rate(reference_date: Date, rate: float, day_counter: DayCounter) -> FlatHazardRate

Build a curve at a fixed rate, on a pinned reference date.

Parameters:

Name Type Description Default
reference_date Date

The date times are measured from.

required
rate float

The hazard rate, wrapped in a fresh, un-retained quote.

required
day_counter DayCounter

The day count turning dates into times.

required

Returns:

Name Type Description
FlatHazardRate FlatHazardRate

The curve at that rate.

moving staticmethod

moving(settlement_days: int, calendar: Calendar, hazard_rate: SimpleQuote, day_counter: DayCounter, settings: Settings) -> FlatHazardRate

Build a curve reading its hazard rate live, on a floating reference date.

The reference date sits settlement_days business days past the evaluation date, so a query made before settings carries one raises rather than falling back to a system clock.

Parameters:

Name Type Description Default
settlement_days int

The business days the reference date sits past the evaluation date.

required
calendar Calendar

The calendar those days are counted on.

required
hazard_rate SimpleQuote

The hazard rate; the caller keeps it, so a later set_value moves the curve.

required
day_counter DayCounter

The day count turning dates into times.

required
settings Settings

The explicit settings supplying the evaluation date.

required

Returns:

Name Type Description
FlatHazardRate FlatHazardRate

The moving curve.

moving_with_rate staticmethod

moving_with_rate(settlement_days: int, calendar: Calendar, rate: float, day_counter: DayCounter, settings: Settings) -> FlatHazardRate

Build a curve at a fixed rate, on a floating reference date.

As moving(), a query made before settings carries an evaluation date raises rather than falling back to a system clock.

Parameters:

Name Type Description Default
settlement_days int

The business days the reference date sits past the evaluation date.

required
calendar Calendar

The calendar those days are counted on.

required
rate float

The hazard rate, wrapped in a fresh, un-retained quote.

required
day_counter DayCounter

The day count turning dates into times.

required
settings Settings

The explicit settings supplying the evaluation date.

required

Returns:

Name Type Description
FlatHazardRate FlatHazardRate

The moving curve at that rate.

InterpolatedHazardRateCurve

InterpolatedHazardRateCurve(dates: list[Date], hazard_rates: list[float], day_counter: DayCounter)

Bases: DefaultProbabilityTermStructure

A credit curve built from (date, hazard-rate) nodes, interpolating backward-flat.

The first date is the reference date. Backward-flat reads the right-hand node on every segment, so the hazard rate is a right-continuous step function and the survival probability is exp(-integral) over those steps. Finite in time: queries past the last node need extrapolate=True, which continues at the last node's rate.

Build the curve over its (date, hazard-rate) nodes.

Backward-flat is pinned at the boundary: it is the only interpolator the credit side wires, so no interpolation argument is offered.

Parameters:

Name Type Description Default
dates list[Date]

The node dates, the first being the reference date.

required
hazard_rates list[float]

The hazard rate at each node.

required
day_counter DayCounter

The day count turning dates into times.

required

Raises:

Type Description
ItofinError

On too few dates, a dates and hazard_rates count mismatch, a negative hazard rate, or unsorted dates.

dates

dates() -> list[Date]

Return the node dates.

Returns:

Type Description
list[Date]

list[Date]: The nodes, the first of which is the reference date.

hazard_rates

hazard_rates() -> list[float]

Return the node hazard rates.

Returns:

Type Description
list[float]

list[float]: The rate at each node.

nodes

nodes() -> list[tuple[Date, float]]

Return the curve's nodes as pairs.

Returns:

Type Description
list[tuple[Date, float]]

list[tuple[Date, float]]: One (date, hazard rate) pair per node.

DefaultProbabilityHelper

Shared base for every credit bootstrap helper.

A credit helper fits a default-probability curve rather than a yield curve, so it is a separate hierarchy from RateHelper. It exposes the two dates the bootstrap places a curve node by.

pillar_date

pillar_date() -> Date

Return the date the curve node this helper sets sits at.

Returns:

Name Type Description
Date Date

The pillar date.

latest_date

latest_date() -> Date

Return the latest date the helper needs curve data at.

Returns:

Name Type Description
Date Date

The latest date, equal to the pillar date.

SpreadCdsHelper

SpreadCdsHelper(running_spread: SimpleQuote, tenor: Period, settlement_days: int, calendar: Calendar, frequency: Frequency, payment_convention: BusinessDayConvention, rule: DateGeneration, day_counter: DayCounter, recovery_rate: float, discount_curve: YieldTermStructure, settings: Settings)

Bases: DefaultProbabilityHelper

Bootstrap helper fitting a CDS quoted as a running spread.

The helper rebuilds its schedule and its contract off the evaluation date held by settings, so it tracks that date rather than freezing a maturity at construction. It retains the caller's quote, so a later set_value re-drives the bootstrap, and it observes the discount curve.

Build the helper on the C++ default CDS terms.

Parameters:

Name Type Description Default
running_spread SimpleQuote

The quoted spread the helper fits.

required
tenor Period

The length of the contract.

required
settlement_days int

The days between the evaluation date and the contract's start.

required
calendar Calendar

The calendar the schedule rolls on.

required
frequency Frequency

The premium payment frequency.

required
payment_convention BusinessDayConvention

The roll applied to the payment dates.

required
rule DateGeneration

The schedule generation rule.

required
day_counter DayCounter

The day count the premium accrues on.

required
recovery_rate float

The recovery assumed on default.

required
discount_curve YieldTermStructure

The curve the flows discount on; the helper observes it.

required
settings Settings

The explicit settings supplying the evaluation date the schedule is rebuilt off.

required

Raises:

Type Description
ItofinError

Under the three post-Big-Bang rules OldCDS, CDS and CDS2015, whose maturity is rolled by the CDS maturity rule: it refuses a tenor it cannot roll, or one it rolls to a contract that has already matured, rather than building a schedule that ends on the wrong date.

PiecewiseDefaultCurve

PiecewiseDefaultCurve(reference_date: Date, helpers: list[DefaultProbabilityHelper], day_counter: DayCounter)

Bases: DefaultProbabilityTermStructure

A credit curve bootstrapped from CDS helpers, solving one hazard-rate node per helper maturity (PiecewiseDefaultCurve).

Lazy: the bootstrap runs on the first read, so the helpers' Settings flags and evaluation date must be in place before that read, not merely before the constructor. A helper quote moving invalidates the cache.

Build the curve over helpers with a fixed reference date.

Parameters:

Name Type Description Default
reference_date Date

The curve's reference date.

required
helpers list[DefaultProbabilityHelper]

The bootstrap instruments; any subclass is accepted.

required
day_counter DayCounter

The day count turning dates into times.

required

Raises:

Type Description
ItofinError

On an empty helper list.

calculate

calculate() -> None

Run the bootstrap if the cache is stale.

Calling it explicitly makes a solver failure surface here rather than inside a later query.

Raises:

Type Description
ItofinError

On a bootstrap failure.

times

times() -> list[float]

Return the node times, triggering the bootstrap.

Returns:

Type Description
list[float]

list[float]: The nodes in the curve's own day count.

Raises:

Type Description
ItofinError

On a bootstrap failure.

dates

dates() -> list[Date]

Return the node dates, triggering the bootstrap.

Returns:

Type Description
list[Date]

list[Date]: The nodes, the first of which is the reference date.

Raises:

Type Description
ItofinError

On a bootstrap failure.

data

data() -> list[float]

Return the solved node hazard rates, triggering the bootstrap.

Returns:

Type Description
list[float]

list[float]: The rate solved at each node.

Raises:

Type Description
ItofinError

On a bootstrap failure.

nodes

nodes() -> list[tuple[Date, float]]

Return the solved nodes as pairs, triggering the bootstrap.

Returns:

Type Description
list[tuple[Date, float]]

list[tuple[Date, float]]: One (date, hazard rate) pair per node.

Raises:

Type Description
ItofinError

On a bootstrap failure.

MultiplicativePriceSeasonality

MultiplicativePriceSeasonality(seasonality_base_date: Date, frequency: Frequency, seasonality_factors: list[float])

The seasonal correction a price index carries, whose factors multiply the index level itself.

The factors are given in whole multiples of the count the frequency dictates - twelve for Frequency.Monthly - and are reused as long as needed, so twelve of them are stationary and twenty-four repeat every two years. They are not applied raw: the factor at the queried date is normalized against the one at a reference date, which for a zero rate is the curve's own base date, so the correction is the identity there.

Install it with ZeroInflationTermStructure.set_seasonality. Only the date-taking rate query folds the correction in; the year-fraction one cannot, a time not naming the date the factors are a function of.

Build the correction from a factor set anchored on a base date.

Parameters:

Name Type Description Default
seasonality_base_date Date

The date the factor set is anchored on.

required
frequency Frequency

The frequency the factors step at.

required
seasonality_factors list[float]

The factors, in order from the base date.

required

Raises:

Type Description
ItofinError

On a frequency outside semiannual-through-daily, Frequency.Annual among them; on an empty factor set; and on a factor count that is not a whole multiple of the frequency.

seasonality_base_date

seasonality_base_date() -> Date

Return the date the factor set is anchored on.

Returns:

Name Type Description
Date Date

The seasonality base date.

frequency

frequency() -> Frequency

Return the frequency the factors step at.

Returns:

Name Type Description
Frequency Frequency

The stepping frequency.

seasonality_factors

seasonality_factors() -> list[float]

Return the factors, in order from the seasonality base date.

Returns:

Type Description
list[float]

list[float]: The factor set as given.

seasonality_factor

seasonality_factor(to: Date) -> float

Return the raw factor covering to, before any normalization.

This is not the correction the curve applies, which is normalized against a reference date. The offset from the seasonality base date is counted in whole factor periods and wrapped modulo the factor count, so a set shorter than the span repeats and dates before the anchor wrap backwards.

Parameters:

Name Type Description Default
to Date

The date the factor is read at.

required

Returns:

Name Type Description
float float

The raw seasonality factor.

Raises:

Type Description
ItofinError

On a year-based factor period, which cannot express seasonality.

ZeroInflationTermStructure

Shared base for every zero-coupon inflation curve: the zero-coupon inflation rate in a year-fraction and a date form, the base date, the fixing frequency and the seasonality correction the curve carries.

The two rate reads are not interchangeable. zero_rate_date snaps its date to the start of the inflation period containing it, because a fixing applies to a whole period; zero_rate takes a year-fraction already measured under the curve's own day counter and quantizes nothing. Only the first folds in any seasonality.

zero_rate

zero_rate(t: float, extrapolate: bool = False) -> float

Return the zero-coupon inflation rate at year-fraction t.

Quoted on the yearly compounding zero-coupon swaps assume. Nothing here accounts for observation lags or period interpolation: the caller manages those.

Parameters:

Name Type Description Default
t float

The year fraction, measured with the curve's own day counter; it is negative for the base period.

required
extrapolate bool

Whether to answer past the curve's range.

False

Returns:

Name Type Description
float float

The zero-coupon inflation rate.

Raises:

Type Description
ItofinError

If t is past the curve's range and extrapolation is not allowed.

zero_rate_date

zero_rate_date(date: Date, extrapolate: bool = False) -> float

Return the zero-coupon inflation rate for the period containing date.

The date is quantized to that period's first day before both the range check and the time conversion, so every day inside one period reads the same rate. This is the only form that folds in seasonality.

Parameters:

Name Type Description Default
date Date

The date the rate is read at.

required
extrapolate bool

Whether to answer past the curve's range.

False

Returns:

Name Type Description
float float

The zero-coupon inflation rate for that period.

Raises:

Type Description
ItofinError

If the period is past the curve's range and extrapolation is not allowed.

base_date

base_date() -> Date

Return the base date, the last date for which the fixing is known.

Returns:

Name Type Description
Date Date

The base date; it precedes the reference date, so its year fraction is negative.

frequency

frequency() -> Frequency

Return the frequency of the inflation fixings the curve is built on.

Returns:

Name Type Description
Frequency Frequency

The fixing frequency.

set_seasonality

set_seasonality(seasonality: MultiplicativePriceSeasonality | None) -> None

Install seasonality on the curve, replacing whatever it carried.

A curve that caches anything derived from the correction - every bootstrapped one does - is invalidated here, so the next read re-solves against the new correction.

Parameters:

Name Type Description Default
seasonality MultiplicativePriceSeasonality | None

The correction to install; None clears it.

required

Raises:

Type Description
ItofinError

From the consistency gate, which a multi-year factor set fails, that comparison being a documented core deferral (#807). The store happens before the gate runs, as C++'s does, so a rejected correction is left installed and unannounced: clear it with None before reading the curve again.

has_seasonality

has_seasonality() -> bool

Return whether the curve carries a seasonality correction.

Returns:

Name Type Description
bool bool

True also for a correction left installed by a set_seasonality that raised.

InterpolatedZeroInflationCurve

InterpolatedZeroInflationCurve(reference_date: Date, dates: list[Date], rates: list[float], frequency: Frequency, day_counter: DayCounter)

Bases: ZeroInflationTermStructure

A zero-coupon inflation curve built from (date, zero-rate) nodes, interpolating linearly in zero-rate space.

The first date is the base date rather than the reference date, which is passed separately and normally follows it; node times are measured from the reference date, so the first one is negative.

Build the curve through the rates quoted at dates.

Linear is pinned at the boundary: it is the interpolator the C++ zero inflation curve typedef fixes, so no interpolation argument is offered.

Parameters:

Name Type Description Default
reference_date Date

The curve's reference date, given separately and normally following the base date.

required
dates list[Date]

The node dates, the first being the base date.

required
rates list[float]

The zero rate at each node.

required
frequency Frequency

The frequency of the inflation fixings.

required
day_counter DayCounter

The day count turning dates into times.

required

Raises:

Type Description
ItofinError

On fewer than two dates, a dates and rates count mismatch, a rate at or below -100 per cent from the second node on, or unsorted dates.

times

times() -> list[float]

Return the node times, measured from the reference date.

Returns:

Type Description
list[float]

list[float]: The node times; the first is negative whenever the base date precedes the reference date.

dates

dates() -> list[Date]

Return the node dates.

Returns:

Type Description
list[Date]

list[Date]: The nodes, the first of which is the base date.

nodes

nodes() -> list[tuple[Date, float]]

Return the curve's nodes as pairs.

Returns:

Type Description
list[tuple[Date, float]]

list[tuple[Date, float]]: One (date, zero rate) pair per node.

ZeroInflationHelper

Shared base for every zero-inflation bootstrap helper: the two dates the bootstrap places a curve node by.

Concrete helpers such as ZeroCouponInflationSwapHelper subclass this and supply only their constructor.

pillar_date

pillar_date() -> Date

Return the date the curve node this helper sets sits at.

Returns:

Name Type Description
Date Date

The pillar date.

latest_date

latest_date() -> Date

Return the latest date the helper needs curve data at.

Returns:

Name Type Description
Date Date

The latest date, equal to the pillar date.

ZeroCouponInflationSwapHelper

ZeroCouponInflationSwapHelper(quote: SimpleQuote, swap_obs_lag: Period, maturity: Date, calendar: Calendar, payment_convention: BusinessDayConvention, day_counter: DayCounter, index: ZeroInflationIndex, observation_interpolation: CpiInterpolationType, settings: Settings, pillar: Pillar = ...)

Bases: ZeroInflationHelper

The bootstrap helper fitting a zero-coupon inflation swap quoted as a rate.

The helper prices a unit-notional, zero-strike swap of its own and reports that contract's fair rate; the bootstrap drives the quoted rate less that fair rate to zero. The swap starts at the evaluation date, so that date must be set before this constructor runs, not merely before the bootstrap.

It prices through a copy of index linked to a handle of its own, so the caller's index need not be linked to any curve.

pillar picks which of the two nodes an interpolated swap straddles the helper fits; a flat swap reads a single fixing and ignores it.

Build the helper on a swap maturing at maturity.

It needs no nominal curve, building itself a flat zero-rate one, because both legs pay on the same adjusted maturity and their discount factors cancel out of the fair rate.

Parameters:

Name Type Description Default
quote SimpleQuote

The quoted swap rate; the caller keeps it, so a later set_value re-drives the bootstrap.

required
swap_obs_lag Period

How far back the maturity fixing is observed.

required
maturity Date

The swap's maturity.

required
calendar Calendar

The calendar the payment rolls on.

required
payment_convention BusinessDayConvention

The roll applied to the payment date.

required
day_counter DayCounter

The day count the fixed amount accrues on.

required
index ZeroInflationIndex

The index observed; the helper prices through a copy linked to a handle of its own, so the caller's index need not be linked to any curve.

required
observation_interpolation CpiInterpolationType

How the observed fixing is interpolated.

required
settings Settings

The explicit settings supplying the evaluation date the swap starts at, which must be set before this constructor runs.

required
pillar Pillar

Which of the two nodes an interpolated swap straddles the helper fits; a flat swap reads a single fixing and ignores it.

...

Raises:

Type Description
ItofinError

On an observation lag the index cannot observe through, and under Linear interpolation on one that leaves less than a whole index period over the index's availability lag.

inflation_fixing_date

inflation_fixing_date() -> Date

Return the maturity observation date on the helper's own swap.

Read off the cached contract's indexed flow, so it reports the date the helper actually prices at rather than one recomputed here. It is not pillar_date, which is the first day of the period containing it, that quantization being the helper's rounding and not the contract's.

Returns:

Name Type Description
Date Date

The maturity less the observation lag, unsnapped.

Raises:

Type Description
ItofinError

If the cached swap carries the error that stopped it being built, notably an evaluation date that was never set.

PiecewiseZeroInflationCurve

PiecewiseZeroInflationCurve(reference_date: Date, base_date: Date, frequency: Frequency, day_counter: DayCounter, helpers: list[ZeroInflationHelper])

Bases: ZeroInflationTermStructure

A zero-coupon inflation curve bootstrapped from inflation helpers, solving one zero-rate node per helper fixing period.

Node zero sits on base_date, not on reference_date, so times()[0] is negative - the one structural difference from every other piecewise curve.

Lazy: the bootstrap runs on the first read, so the evaluation date must be in place before that read as well as before the helpers were built. A helper quote moving invalidates the cache.

Build the curve over helpers, registering on them without solving.

Parameters:

Name Type Description Default
reference_date Date

The curve's reference date.

required
base_date Date

The last date for which a fixing is known, where node zero sits.

required
frequency Frequency

The frequency of the inflation fixings.

required
day_counter DayCounter

The day count turning dates into times.

required
helpers list[ZeroInflationHelper]

The bootstrap instruments.

required

Raises:

Type Description
ItofinError

On an empty helper list.

calculate

calculate() -> None

Run the bootstrap if the cache is stale.

Calling it explicitly makes a solver failure surface here rather than inside a later query.

Raises:

Type Description
ItofinError

On a bootstrap failure.

times

times() -> list[float]

Return the node times, triggering the bootstrap.

Returns:

Type Description
list[float]

list[float]: The nodes measured from the reference date; the first is negative, node zero sitting on the base date.

Raises:

Type Description
ItofinError

On a bootstrap failure.

dates

dates() -> list[Date]

Return the node dates, triggering the bootstrap.

Returns:

Type Description
list[Date]

list[Date]: The nodes, the first of which is the base date.

Raises:

Type Description
ItofinError

On a bootstrap failure.

nodes

nodes() -> list[tuple[Date, float]]

Return the solved nodes as pairs, triggering the bootstrap.

Returns:

Type Description
list[tuple[Date, float]]

list[tuple[Date, float]]: One (date, zero rate) pair per node.

Raises:

Type Description
ItofinError

On a bootstrap failure.

YoYInflationTermStructure

Shared base for every year-on-year inflation curve: the year-on-year rate in a year-fraction and a date form, the base date, the base rate, the fixing frequency and the seasonality correction the curve carries.

The two rate reads are not interchangeable. yoy_rate_date snaps its date to the start of the inflation period containing it and is the only one that folds in any seasonality; yoy_rate takes a year-fraction already measured under the curve's own day counter and quantizes nothing. Neither is the year-on-year swap rate, which comes from the instrument.

base_rate is answered here where the zero base defers it: a year-on-year curve carries the rate observed over the period ending on its base date.

yoy_rate

yoy_rate(t: float, extrapolate: bool = False) -> float

Return the year-on-year inflation rate at year-fraction t.

Parameters:

Name Type Description Default
t float

The year fraction, measured with the curve's own day counter; it is negative for the base period.

required
extrapolate bool

Whether to answer past the curve's range.

False

Returns:

Name Type Description
float float

The year-on-year rate, which is not the year-on-year swap rate: that comes from the instrument.

Raises:

Type Description
ItofinError

If t is past the curve's range and extrapolation is not allowed.

yoy_rate_date

yoy_rate_date(date: Date, extrapolate: bool = False) -> float

Return the year-on-year rate for the inflation period containing date.

The date is quantized to that period's first day before both the range check and the time conversion. Any seasonality correction is folded in last, at the original date rather than the period start, as C++ does on this path.

Parameters:

Name Type Description Default
date Date

The date the rate is read at.

required
extrapolate bool

Whether to answer past the curve's range.

False

Returns:

Name Type Description
float float

The year-on-year rate for that period.

Raises:

Type Description
ItofinError

If the period is past the curve's range and extrapolation is not allowed.

base_date

base_date() -> Date

Return the base date, the last date for which the fixing is known.

Returns:

Name Type Description
Date Date

The base date; it precedes the reference date, so its year fraction is negative.

base_rate

base_rate() -> float

Return the rate observed over the period ending on the base date.

Returns:

Name Type Description
float float

The base rate, which node zero is seeded with and keeps.

Raises:

Type Description
ItofinError

On a curve that carries no base rate.

frequency

frequency() -> Frequency

Return the frequency of the inflation fixings the curve is built on.

Returns:

Name Type Description
Frequency Frequency

The fixing frequency.

set_seasonality

set_seasonality(seasonality: MultiplicativePriceSeasonality | None) -> None

Install seasonality on the curve, replacing whatever it carried.

Parameters:

Name Type Description Default
seasonality MultiplicativePriceSeasonality | None

The correction to install; None clears it.

required

Raises:

Type Description
ItofinError

From the consistency gate, which leaves a rejected correction installed as C++ does; see the zero-curve base for the full account.

has_seasonality

has_seasonality() -> bool

Return whether the curve carries a seasonality correction.

Returns:

Name Type Description
bool bool

True also for a correction left installed by a set_seasonality that raised.

InterpolatedYoYInflationCurve

InterpolatedYoYInflationCurve(reference_date: Date, dates: list[Date], rates: list[float], frequency: Frequency, day_counter: DayCounter)

Bases: YoYInflationTermStructure

A year-on-year inflation curve built from (date, year-on-year rate) nodes, interpolating linearly in rate space.

The first date is the base date rather than the reference date, which is passed separately and normally follows it; the first rate is the base rate the curve publishes, and node times are measured from the reference date, so the first one is negative.

Build the curve through the rates quoted at dates.

Parameters:

Name Type Description Default
reference_date Date

The curve's reference date, given separately and normally following the base date.

required
dates list[Date]

The node dates, the first being the base date.

required
rates list[float]

The year-on-year rate at each node; the first is the base rate the curve publishes.

required
frequency Frequency

The frequency of the inflation fixings.

required
day_counter DayCounter

The day count turning dates into times.

required

Raises:

Type Description
ItofinError

On fewer than two dates, a dates and rates count mismatch, or a rate at or below -100 per cent from the second node on; the base rate is left unconstrained.

times

times() -> list[float]

Return the node times, measured from the reference date.

Returns:

Type Description
list[float]

list[float]: The node times; the first is negative whenever the base date precedes the reference date.

dates

dates() -> list[Date]

Return the node dates.

Returns:

Type Description
list[Date]

list[Date]: The nodes, the first of which is the base date.

nodes

nodes() -> list[tuple[Date, float]]

Return the curve's nodes as pairs.

Returns:

Type Description
list[tuple[Date, float]]

list[tuple[Date, float]]: One (date, year-on-year rate) pair per node.

YoYInflationHelper

Shared base for every year-on-year bootstrap helper: the two dates the bootstrap places a curve node by.

Concrete helpers such as YearOnYearInflationSwapHelper subclass this and supply only their constructor.

pillar_date

pillar_date() -> Date

Return the date the curve node this helper sets sits at.

Returns:

Name Type Description
Date Date

The pillar date.

latest_date

latest_date() -> Date

Return the latest date the helper needs curve data at.

Returns:

Name Type Description
Date Date

The latest date, equal to the pillar date.

YearOnYearInflationSwapHelper

YearOnYearInflationSwapHelper(quote: SimpleQuote, swap_obs_lag: Period, maturity: Date, calendar: Calendar, payment_convention: BusinessDayConvention, day_counter: DayCounter, index: YoYInflationIndex, interpolation: CpiInterpolationType, nominal_term_structure: YieldTermStructure, settings: Settings, pillar: Pillar = ...)

Bases: YoYInflationHelper

The bootstrap helper fitting a year-on-year inflation swap quoted as a rate.

The helper prices a unit-notional, zero-strike swap of its own and reports that contract's fair rate; the bootstrap drives the quoted rate less that fair rate to zero. Unlike its zero-coupon twin it does need a nominal curve: the year-on-year legs pay on a schedule of dates rather than one, so their discount factors do not cancel.

The swap starts at the evaluation date, so that date must be set before this constructor runs, not merely before the bootstrap. It prices through a copy of index linked to a handle of its own, so the caller's index need not be linked to any curve.

pillar is accepted for signature parity but never read: it only ever discriminates on the interpolated path, which is refused.

Build the helper on a swap maturing at maturity.

Parameters:

Name Type Description Default
quote SimpleQuote

The quoted swap rate; the caller keeps it, so a later set_value re-drives the bootstrap.

required
swap_obs_lag Period

How far back each coupon's fixings are observed.

required
maturity Date

The swap's maturity.

required
calendar Calendar

The calendar the payments roll on.

required
payment_convention BusinessDayConvention

The roll applied to the payment dates.

required
day_counter DayCounter

The day count the legs accrue on.

required
index YoYInflationIndex

The index observed; the helper prices through a copy linked to a handle of its own, so the caller's index need not be linked to any curve.

required
interpolation CpiInterpolationType

How the observed fixings are interpolated.

required
nominal_term_structure YieldTermStructure

The discount curve, which this helper does need: its legs pay on a schedule of dates rather than one, so their discount factors do not cancel.

required
settings Settings

The explicit settings supplying the evaluation date the swap starts at, which must be set before this constructor runs.

required
pillar Pillar

Accepted for signature parity but never read; it only ever discriminates on the interpolated path.

...

Raises:

Type Description
ItofinError

On Linear interpolation, which the core refuses outright pending the interpolated branch (#847), and on an observation lag the helper's own swap legs cannot be built under.

PiecewiseYoYInflationCurve

PiecewiseYoYInflationCurve(reference_date: Date, base_date: Date, base_yoy_rate: float, frequency: Frequency, day_counter: DayCounter, helpers: list[YoYInflationHelper])

Bases: YoYInflationTermStructure

A year-on-year inflation curve bootstrapped from year-on-year helpers, solving one rate node per helper fixing period.

Node zero sits on base_date at base_yoy_rate and is kept rather than solved, so times()[0] is negative. Each helper's observed fixing period marks a later segment boundary.

Lazy: the bootstrap runs on the first read, so the evaluation date must be in place before that read as well as before the helpers were built. A helper quote moving invalidates the cache.

Build the curve over helpers, registering on them without solving.

Parameters:

Name Type Description Default
reference_date Date

The curve's reference date.

required
base_date Date

The last date for which a fixing is known, where node zero sits.

required
base_yoy_rate float

The rate node zero is seeded with and keeps, rather than solved for.

required
frequency Frequency

The frequency of the inflation fixings.

required
day_counter DayCounter

The day count turning dates into times.

required
helpers list[YoYInflationHelper]

The bootstrap instruments.

required

Raises:

Type Description
ItofinError

On an empty helper list.

calculate

calculate() -> None

Run the bootstrap if the cache is stale.

Calling it explicitly makes a solver failure surface here rather than inside a later query.

Raises:

Type Description
ItofinError

On a bootstrap failure.

times

times() -> list[float]

Return the node times, triggering the bootstrap.

Returns:

Type Description
list[float]

list[float]: The nodes measured from the reference date; the first is negative, node zero sitting on the base date.

Raises:

Type Description
ItofinError

On a bootstrap failure.

dates

dates() -> list[Date]

Return the node dates, triggering the bootstrap.

Returns:

Type Description
list[Date]

list[Date]: The nodes, the first of which is the base date.

Raises:

Type Description
ItofinError

On a bootstrap failure.

nodes

nodes() -> list[tuple[Date, float]]

Return the solved nodes as pairs, triggering the bootstrap.

Returns:

Type Description
list[tuple[Date, float]]

list[tuple[Date, float]]: One (date, year-on-year rate) pair per node.

Raises:

Type Description
ItofinError

On a bootstrap failure.

ConstantYoYOptionletVolatility

ConstantYoYOptionletVolatility(volatility: float, settlement_days: int, calendar: Calendar, business_day_convention: BusinessDayConvention, day_counter: DayCounter, observation_lag: Period, frequency: Frequency, index_is_interpolated: bool, min_strike: float, max_strike: float, settings: Settings)

One year-on-year optionlet volatility for every strike and every date.

The reference date moves with the evaluation date carried by settings, settlement_days business days on from it, so that date must be set before anything is priced off the surface.

min_strike and max_strike bound the strike domain a query is answered over; C++ defaults them to -1.0 and 100.0 and the port carries no default arguments, so both are passed here too.

Both constructors are bound: init takes a value, with_quote a live quote. The whole stripped/interpolated hierarchy is deferred (#874).

Build a flat surface at a fixed volatility.

Nothing is resolved here: the reference date, the base date and the strike range are all read at query time, so an unset evaluation date surfaces then rather than now.

Parameters:

Name Type Description Default
volatility float

The single volatility answered everywhere.

required
settlement_days int

The business days the reference date sits past the evaluation date.

required
calendar Calendar

The calendar those days are counted on.

required
business_day_convention BusinessDayConvention

The roll applied when resolving a date.

required
day_counter DayCounter

The day count times are measured in.

required
observation_lag Period

The lag the surface itself observes inflation with.

required
frequency Frequency

How often the observed index publishes.

required
index_is_interpolated bool

Whether the observed index interpolates between publications.

required
min_strike float

The lower bound of the strike domain; C++ defaults it to -1.0 and the port carries no default arguments.

required
max_strike float

The upper bound of the strike domain; C++ defaults it to 100.0.

required
settings Settings

The explicit settings supplying the evaluation date the reference date moves with.

required

with_quote staticmethod

with_quote(volatility: SimpleQuote, settlement_days: int, calendar: Calendar, business_day_convention: BusinessDayConvention, day_counter: DayCounter, observation_lag: Period, frequency: Frequency, index_is_interpolated: bool, min_strike: float, max_strike: float, settings: Settings) -> ConstantYoYOptionletVolatility

Build a flat surface reading its volatility from a live quote.

The quote is retained rather than read once, so a later set_value on it notifies the surface's observers and anything priced off the surface reprices at the new level. Otherwise as init, which the arguments after the first mirror exactly.

Parameters:

Name Type Description Default
volatility SimpleQuote

The volatility answered everywhere.

required
settlement_days int

The business days the reference date sits past the evaluation date.

required
calendar Calendar

The calendar those days are counted on.

required
business_day_convention BusinessDayConvention

The roll applied when resolving a date.

required
day_counter DayCounter

The day count times are measured in.

required
observation_lag Period

The lag the surface itself observes inflation with.

required
frequency Frequency

How often the observed index publishes.

required
index_is_interpolated bool

Whether the observed index interpolates between publications.

required
min_strike float

The lower bound of the strike domain.

required
max_strike float

The upper bound of the strike domain.

required
settings Settings

The explicit settings supplying the evaluation date the reference date moves with.

required

Returns:

Name Type Description
ConstantYoYOptionletVolatility ConstantYoYOptionletVolatility

The surface over that quote.

observation_lag

observation_lag() -> Period

Return the lag the surface itself observes inflation with.

Returns:

Name Type Description
Period Period

The observation lag, which is what to pass as obs_lag for the surface's own.

frequency

frequency() -> Frequency

Return how often the observed index publishes.

Returns:

Name Type Description
Frequency Frequency

The publication frequency.

index_is_interpolated

index_is_interpolated() -> bool

Return whether the observed index interpolates between publications.

Returns:

Name Type Description
bool bool

True when the index interpolates.

base_date

base_date() -> Date

Return the date the surface measures its variance from.

The reference date pulled back by the surface's own observation lag, snapped to the start of the publication period unless the index is interpolated.

Returns:

Name Type Description
Date Date

The base date.

Raises:

Type Description
ItofinError

On an unset evaluation date, and on a frequency admitting no publication period.

volatility

volatility(date: Date, strike: float, obs_lag: Period) -> float

Return the volatility for an exercise on date struck at strike.

Parameters:

Name Type Description Default
date Date

The exercise date.

required
strike float

The strike the volatility is read at.

required
obs_lag Period

How far back inflation is observed; the lag is explicit rather than defaulted, because C++ substitutes the surface's own for a sentinel period and the port has no sentinel to carry. Pass observation_lag() for that behaviour.

required

Returns:

Name Type Description
float float

The optionlet volatility.

Raises:

Type Description
ItofinError

On an observed date before base_date(), and on a strike outside the surface's strike domain.

total_variance

total_variance(date: Date, strike: float, obs_lag: Period) -> float

Return the total integrated variance for an exercise on date.

The figure that scales time out of the optionlet formulae without committing to the distribution reading it.

Parameters:

Name Type Description Default
date Date

The exercise date.

required
strike float

The strike the variance is read at.

required
obs_lag Period

How far back inflation is observed.

required

Returns:

Name Type Description
float float

The total integrated variance.

Raises:

Type Description
ItofinError

On the same conditions volatility() reports.

YoYCapFloorTermPriceSurface

YoYCapFloorTermPriceSurface(fixing_days: int, yy_lag: Period, yoy_index: YoYInflationIndex, interpolation: CpiInterpolationType, nominal_term_structure: YieldTermStructure, day_counter: DayCounter, calendar: Calendar, business_day_convention: BusinessDayConvention, c_strikes: list[float], f_strikes: list[float], cf_maturities: list[Period], c_price: list[list[float]], f_price: list[list[float]], settings: Settings)

The quoted year-on-year cap/floor price grid, bicubic-interpolated over strike and maturity with a cubic ATM swap rate curve through the cap/floor intersections.

Construction only validates and stores the quotes; the calculations - the cap/floor intersection and the year-on-year bootstrap over its ATM swap rates - run on the first read and are cached. The reference date moves with the evaluation date carried by settings, which must be set before construction.

A price alone does not say cap or floor without the ATM level, and ATM prices are generally inaccurate, coming from extrapolation and intersection: the quoted grid is the data, the ATM curve a derived read.

Build the surface over quoted cap and floor prices.

Parameters:

Name Type Description Default
fixing_days int

The fixing days of the quoted instruments.

required
yy_lag Period

The observation lag of the quoted instruments.

required
yoy_index YoYInflationIndex

The year-on-year index the surface is quoted on.

required
interpolation CpiInterpolationType

How an observation interpolates between the index fixings bracketing it.

required
nominal_term_structure YieldTermStructure

The nominal discount curve the derived year-on-year bootstrap prices against.

required
day_counter DayCounter

The day count times are measured in.

required
calendar Calendar

The calendar maturities resolve on.

required
business_day_convention BusinessDayConvention

The roll applied when resolving a date.

required
c_strikes list[float]

The quoted cap strikes, one per cap grid row; strictly increasing.

required
f_strikes list[float]

The quoted floor strikes, one per floor grid row; strictly increasing.

required
cf_maturities list[Period]

The quoted maturities, one per grid column; shared by both grids.

required
c_price list[list[float]]

The cap prices, one row per cap strike and one column per maturity.

required
f_price list[list[float]]

The floor prices, one row per floor strike and one column per maturity.

required
settings Settings

The explicit settings supplying the evaluation date the reference date moves with.

required

Raises:

Type Description
ItofinError

On an empty or ragged price grid, on grid dimensions that do not match the strikes and maturities, on a non-increasing axis, and on a cap/floor strike union that overlaps the wrong way round.

cap_price

cap_price(date: Date, strike: float) -> float

Return the interpolated cap price at date struck at strike.

A pure surface lookup with the spline's extrapolation enabled, as in C++.

Parameters:

Name Type Description Default
date Date

The maturity the price is read at.

required
strike float

The strike the price is read at.

required

Returns:

Name Type Description
float float

The interpolated cap price.

Raises:

Type Description
ItofinError

On an unset evaluation date, and on whatever stops the first-read calculations: a failed intersection solve, an intersection outside its arbitrage bounds past the extrapolation horizon, or a bootstrap that cannot reprice its helpers.

floor_price

floor_price(date: Date, strike: float) -> float

Return the interpolated floor price at date struck at strike.

Parameters:

Name Type Description Default
date Date

The maturity the price is read at.

required
strike float

The strike the price is read at.

required

Returns:

Name Type Description
float float

The interpolated floor price.

Raises:

Type Description
ItofinError

On the same conditions cap_price() reports.

atm_yoy_swap_rate

atm_yoy_swap_rate(date: Date, extrapolate: bool = True) -> float

Return the ATM year-on-year swap rate at date.

Read off the cubic curve through the cap/floor intersections.

Parameters:

Name Type Description Default
date Date

The maturity the rate is read at.

required
extrapolate bool

Whether to answer outside the quoted maturities; defaults True as in C++.

True

Returns:

Name Type Description
float float

The ATM year-on-year swap rate.

Raises:

Type Description
ItofinError

On the same conditions cap_price() reports, and on a date outside the quoted maturities when extrapolate is False.

strikes

strikes() -> list[float]

Return the cap/floor strike union.

Every floor strike, then the cap strikes above them.

Returns:

Type Description
list[float]

list[float]: The strike union, strictly increasing.

maturities

maturities() -> list[Period]

Return the quoted maturities, one per grid column.

Returns:

Type Description
list[Period]

list[Period]: The maturities.

KInterpolatedYoYOptionletVolatilitySurface

KInterpolatedYoYOptionletVolatilitySurface(settlement_days: int, calendar: Calendar, business_day_convention: BusinessDayConvention, day_counter: DayCounter, observation_lag: Period, cap_floor_prices: YoYCapFloorTermPriceSurface, index: YoYInflationIndex, nominal_term_structure: YieldTermStructure, slope: float, settings: Settings)

The year-on-year optionlet volatility surface stripped out of a quoted YoYCapFloorTermPriceSurface, interpolating linearly across the quoted strikes of each date's slice.

The stripping pipeline is built inside the constructor rather than passed in: the stripper reprices each optionlet through an engine whose volatility link it relinks every solver iteration, so engine and stripper must share one relinkable handle that starts empty. The constructor therefore takes the index and nominal curve the engine needs and wires the handle itself; a caller-supplied engine would silently strip against nothing.

Construction runs the stripping, so it is fallible and the evaluation date carried by settings must be set first. The pricer is pinned to the unit-displaced lognormal model.

Strip cap_floor_prices into an optionlet volatility surface.

Parameters:

Name Type Description Default
settlement_days int

Days from the evaluation date to the surface's reference date.

required
calendar Calendar

The calendar the reference date resolves on.

required
business_day_convention BusinessDayConvention

The roll applied when resolving a date.

required
day_counter DayCounter

The day count times are measured in.

required
observation_lag Period

The lag the surface observes inflation with, normally the price surface's own.

required
cap_floor_prices YoYCapFloorTermPriceSurface

The quoted cap/floor price grid to strip.

required
index YoYInflationIndex

The year-on-year index the internal engine forecasts off; it must be linked to a year-on-year curve, which is the index's own rather than the price surface's bootstrapped one.

required
nominal_term_structure YieldTermStructure

The nominal discount curve the internal engine discounts on.

required
slope float

The assumed proportional change per year of the unobserved initial caplet volatility, which the stripper extends each strike's first observable volatility back with.

required
settings Settings

The explicit settings supplying the evaluation date; it must match the one behind index and cap_floor_prices.

required

Raises:

Type Description
ItofinError

On whatever stops the stripping: an unset evaluation date, an unlinked index, or a solve that cannot bracket an optionlet volatility.

d_slice

d_slice(date: Date) -> tuple[list[float], list[float]]

Return the stripped (strikes, volatilities) profile at date.

C++'s Dslice: one volatility per strike of the price surface's cap/floor union.

Parameters:

Name Type Description Default
date Date

The date the slice is stripped at.

required

Returns:

Type Description
tuple[list[float], list[float]]

tuple[list[float], list[float]]: The quoted strike union and the volatility stripped at each strike.

Raises:

Type Description
ItofinError

On a date the stripper cannot price a slice at.

base_date

base_date() -> Date

Return the date the surface measures its variance from.

The reference date pulled back by the surface's own observation lag, snapped to the start of the publication period.

Returns:

Name Type Description
Date Date

The base date.

Raises:

Type Description
ItofinError

On an unset evaluation date, and on a frequency admitting no publication period.

volatility

volatility(date: Date, strike: float) -> float

Return the volatility for an exercise on date struck at strike.

Observes inflation the surface's own observation lag back, C++'s default-lag behaviour: the slice at the observed date interpolated across its strikes.

Parameters:

Name Type Description Default
date Date

The exercise date.

required
strike float

The strike the volatility is read at.

required

Returns:

Name Type Description
float float

The optionlet volatility.

Raises:

Type Description
ItofinError

On an observed date before base_date(), and on a strike outside the surface's strike domain.

min_strike

min_strike() -> float

Return the lowest quoted strike of the cap/floor union.

Returns:

Name Type Description
float float

The lowest strike the surface answers for.

max_strike

max_strike() -> float

Return the highest quoted strike of the cap/floor union.

Returns:

Name Type Description
float float

The highest strike the surface answers for.

max_date

max_date() -> Date

Return the last date the surface answers for.

The reference date advanced by the price surface's last quoted maturity.

Returns:

Name Type Description
Date Date

The last queryable date.