pub trait SwaptionVolatilityStructure: VolatilityTermStructure {
Show 18 methods
// Required methods
fn volatility_impl(
&self,
option_time: Time,
swap_length: Time,
strike: Rate,
) -> QlResult<Volatility>;
fn max_swap_tenor(&self) -> Period;
// Provided methods
fn volatility_type(&self) -> VolatilityType { ... }
fn shift_impl(
&self,
_option_time: Time,
_swap_length: Time,
) -> QlResult<Real> { ... }
fn discrete_grid(&self) -> QlResult<SwaptionVolatilityGrid> { ... }
fn max_swap_length(&self) -> QlResult<Time> { ... }
fn swap_length_tenor(&self, swap_tenor: Period) -> QlResult<Time> { ... }
fn swap_length(&self, start: Date, end: Date) -> QlResult<Time> { ... }
fn check_swap_tenor(
&self,
swap_tenor: Period,
extrapolate: bool,
) -> QlResult<()> { ... }
fn check_swap_length(
&self,
swap_length: Time,
extrapolate: bool,
) -> QlResult<()> { ... }
fn volatility(
&self,
option_date: Date,
swap_length: Time,
strike: Rate,
extrapolate: bool,
) -> QlResult<Volatility> { ... }
fn volatility_time(
&self,
option_time: Time,
swap_length: Time,
strike: Rate,
extrapolate: bool,
) -> QlResult<Volatility> { ... }
fn volatility_tenors(
&self,
option_tenor: Period,
swap_tenor: Period,
strike: Rate,
extrapolate: bool,
) -> QlResult<Volatility> { ... }
fn black_variance(
&self,
option_date: Date,
swap_length: Time,
strike: Rate,
extrapolate: bool,
) -> QlResult<Real> { ... }
fn black_variance_time(
&self,
option_time: Time,
swap_length: Time,
strike: Rate,
extrapolate: bool,
) -> QlResult<Real> { ... }
fn black_variance_tenors(
&self,
option_tenor: Period,
swap_tenor: Period,
strike: Rate,
extrapolate: bool,
) -> QlResult<Real> { ... }
fn shift(
&self,
option_date: Date,
swap_length: Time,
extrapolate: bool,
) -> QlResult<Real> { ... }
fn shift_time(
&self,
option_time: Time,
swap_length: Time,
extrapolate: bool,
) -> QlResult<Real> { ... }
}Expand description
Swaption volatility structure.
Mirrors QuantLib’s SwaptionVolatilityStructure: concrete surfaces implement
volatility_impl; the provided queries run the swap,
range and strike checks and dispatch to it, deriving the Black variance as
volatility^2 * time. Volatilities are expressed on an annual basis.
Required Methods§
Sourcefn volatility_impl(
&self,
option_time: Time,
swap_length: Time,
strike: Rate,
) -> QlResult<Volatility>
fn volatility_impl( &self, option_time: Time, swap_length: Time, strike: Rate, ) -> QlResult<Volatility>
Volatility calculation hook; swap, range and strike checks have already run.
Sourcefn max_swap_tenor(&self) -> Period
fn max_swap_tenor(&self) -> Period
The largest swap tenor for which the surface can return vols.
Provided Methods§
Sourcefn volatility_type(&self) -> VolatilityType
fn volatility_type(&self) -> VolatilityType
The pricing model the quoted volatilities are expressed in.
Sourcefn shift_impl(&self, _option_time: Time, _swap_length: Time) -> QlResult<Real>
fn shift_impl(&self, _option_time: Time, _swap_length: Time) -> QlResult<Real>
Shift calculation hook. The default enforces that a shift only makes
sense for lognormal volatilities and returns 0.0.
Sourcefn discrete_grid(&self) -> QlResult<SwaptionVolatilityGrid>
fn discrete_grid(&self) -> QlResult<SwaptionVolatilityGrid>
The structure’s own discrete option/swap grid, for a consumer that needs to
read the node set (the SABR cube’s dense ATM-calibration fill). The default
returns Err: only a grid-backed structure (one built on
SwaptionVolatilityDiscrete, such as SwaptionVolatilityMatrix) can
answer. This stands in for QuantLib’s
dynamic_pointer_cast<SwaptionVolatilityDiscrete>(*atmVol_), surfacing an
Err exactly where the C++ cast would null-deref.
Sourcefn max_swap_length(&self) -> QlResult<Time>
fn max_swap_length(&self) -> QlResult<Time>
The largest swap length (in time) for which the surface can return vols.
Sourcefn swap_length_tenor(&self, swap_tenor: Period) -> QlResult<Time>
fn swap_length_tenor(&self, swap_tenor: Period) -> QlResult<Time>
Conversion between a swap tenor and its swap length in years. Only month- and year-denominated tenors are meaningful.
Sourcefn swap_length(&self, start: Date, end: Date) -> QlResult<Time>
fn swap_length(&self, start: Date, end: Date) -> QlResult<Time>
Conversion between swap start and end dates and swap length in years,
rounded to whole months as QuantLib does with ClosestRounding(0).
Sourcefn check_swap_tenor(
&self,
swap_tenor: Period,
extrapolate: bool,
) -> QlResult<()>
fn check_swap_tenor( &self, swap_tenor: Period, extrapolate: bool, ) -> QlResult<()>
Swap-tenor range check: swap_tenor must be positive and, unless
extrapolation applies, no longer than max_swap_tenor.
Sourcefn check_swap_length(
&self,
swap_length: Time,
extrapolate: bool,
) -> QlResult<()>
fn check_swap_length( &self, swap_length: Time, extrapolate: bool, ) -> QlResult<()>
Swap-length range check: swap_length must be positive and, unless
extrapolation applies, no longer than max_swap_length.
Sourcefn volatility(
&self,
option_date: Date,
swap_length: Time,
strike: Rate,
extrapolate: bool,
) -> QlResult<Volatility>
fn volatility( &self, option_date: Date, swap_length: Time, strike: Rate, extrapolate: bool, ) -> QlResult<Volatility>
Volatility for a given option date, swap length and strike rate.
Sourcefn volatility_time(
&self,
option_time: Time,
swap_length: Time,
strike: Rate,
extrapolate: bool,
) -> QlResult<Volatility>
fn volatility_time( &self, option_time: Time, swap_length: Time, strike: Rate, extrapolate: bool, ) -> QlResult<Volatility>
Volatility for a given option time, swap length and strike rate.
Sourcefn volatility_tenors(
&self,
option_tenor: Period,
swap_tenor: Period,
strike: Rate,
extrapolate: bool,
) -> QlResult<Volatility>
fn volatility_tenors( &self, option_tenor: Period, swap_tenor: Period, strike: Rate, extrapolate: bool, ) -> QlResult<Volatility>
Volatility for a given option tenor, swap tenor and strike rate.
Sourcefn black_variance(
&self,
option_date: Date,
swap_length: Time,
strike: Rate,
extrapolate: bool,
) -> QlResult<Real>
fn black_variance( &self, option_date: Date, swap_length: Time, strike: Rate, extrapolate: bool, ) -> QlResult<Real>
Black variance for a given option date, swap length and strike rate.
Sourcefn black_variance_time(
&self,
option_time: Time,
swap_length: Time,
strike: Rate,
extrapolate: bool,
) -> QlResult<Real>
fn black_variance_time( &self, option_time: Time, swap_length: Time, strike: Rate, extrapolate: bool, ) -> QlResult<Real>
Black variance for a given option time, swap length and strike rate.
Sourcefn black_variance_tenors(
&self,
option_tenor: Period,
swap_tenor: Period,
strike: Rate,
extrapolate: bool,
) -> QlResult<Real>
fn black_variance_tenors( &self, option_tenor: Period, swap_tenor: Period, strike: Rate, extrapolate: bool, ) -> QlResult<Real>
Black variance for a given option tenor, swap tenor and strike rate.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".