Struct RateVolSurface
pub struct RateVolSurface {
expiries: Vec<f64>,
tenors: Vec<f64>,
strikes: Option<Vec<f64>>,
strike_axis: StrikeAxis,
vols: Vec<f64>,
convention: VolConvention,
day_count: DayCountFraction,
}Expand description
A rate vol surface over (expiry_years, tenor_years), optionally carrying a
smile in absolute rate strikes.
Pillars are strictly ascending. Parameters are ordered expiry-major, then
tenor, then strike, so a surface quoted at the money — one strike, unnamed —
lays its grid out exactly as expiries.len() × tenors.len() row-major.
Off-node queries follow the module’s named interpolation rule.
Fields§
§expiries: Vec<f64>§tenors: Vec<f64>§strikes: Option<Vec<f64>>Ascending strike pillars where the surface carries a smile; None is a
surface quoted at the money, which reads flat in strike. What the
numbers mean is strike_axis.
strike_axis: StrikeAxisWhether strikes are absolute rates or spreads to the at-the-money
forward. Absolute unless a constructor says otherwise.
vols: Vec<f64>Node vols in parameter order — the free parameters.
convention: VolConvention§day_count: DayCountFractionThe day count the expiry axis is measured on: the years from valuation to an option’s fixing or expiry, for the read and for the variance. Act/365F unless the surface says otherwise.
Implementations§
§impl RateVolSurface
impl RateVolSurface
pub fn scaled(&self, factor: f64) -> Self
pub fn scaled(&self, factor: f64) -> Self
This surface with every node vol multiplied by factor — a relative
vol shock. Axes, strikes, strike axis and quoting convention carry
over, so a smile keeps its shape and a normal surface stays normal.
A positive factor keeps every node positive and finite, so this cannot fail; a caller refuses a non-positive one first.
pub fn mapped(&self, f: impl Fn(f64, f64) -> f64) -> Option<Self>
pub fn mapped(&self, f: impl Fn(f64, f64) -> f64) -> Option<Self>
This surface with each node vol replaced by f(expiry_years, vol) —
a vol shock by expiry. None when a node leaves (0, ∞). Axes,
strikes and convention carry over.
pub fn new(
expiries: Vec<f64>,
tenors: Vec<f64>,
rows: &[Vec<f64>],
convention: VolConvention,
) -> Result<Self, RateVolError>
pub fn new( expiries: Vec<f64>, tenors: Vec<f64>, rows: &[Vec<f64>], convention: VolConvention, ) -> Result<Self, RateVolError>
A surface from ascending expiries (years) × tenors (years) and one
row of vols per expiry, in tenor order.
§Errors
RateVolError::Malformed on an empty or non-ascending axis, a row
count or row length that does not match the axes, or a non-finite or
non-positive vol.
pub fn smile(
expiries: Vec<f64>,
tenor_years: f64,
strikes: Vec<f64>,
rows: &[Vec<f64>],
convention: VolConvention,
) -> Result<Self, RateVolError>
pub fn smile( expiries: Vec<f64>, tenor_years: f64, strikes: Vec<f64>, rows: &[Vec<f64>], convention: VolConvention, ) -> Result<Self, RateVolError>
A surface carrying a smile: the cap market’s quote grid of ascending
expiries (years) at one tenor_years across ascending absolute rate
strikes, with one row of vols per expiry and one entry per strike.
§Errors
RateVolError::Malformed on an empty or non-ascending axis, a row
count or row length that does not match the axes, or a non-finite or
non-positive vol.
pub fn cube(
expiries: Vec<f64>,
tenors: Vec<f64>,
strikes: Vec<f64>,
cells: &[Vec<Vec<f64>>],
convention: VolConvention,
) -> Result<Self, RateVolError>
pub fn cube( expiries: Vec<f64>, tenors: Vec<f64>, strikes: Vec<f64>, cells: &[Vec<Vec<f64>>], convention: VolConvention, ) -> Result<Self, RateVolError>
A surface over all three axes: ascending expiries (years), ascending
tenors (years) and ascending absolute rate strikes, with one vol per
triple — cells[expiry][tenor][strike].
The cap market quotes one index at a time, which is what
smile takes; this is the surface a currency needs when
two index tenors both carry a skew.
§Errors
RateVolError::Malformed on an empty or non-ascending axis, a nesting
whose lengths do not match the axes, or a non-finite or non-positive
vol.
pub fn with_day_count(self, day_count: DayCountFraction) -> Self
pub fn with_day_count(self, day_count: DayCountFraction) -> Self
This surface with its expiry axis measured on day_count: time to each fixing
or expiry is counted on it, both to read the vol and as the variance
time.
pub fn day_count(&self) -> DayCountFraction
pub fn day_count(&self) -> DayCountFraction
The day count the expiry axis is measured on.
pub fn convention(&self) -> VolConvention
pub fn convention(&self) -> VolConvention
The quoting convention, which selects the pricing formula.
pub fn strikes(&self) -> Option<&[f64]>
pub fn strikes(&self) -> Option<&[f64]>
The strike pillars, ascending, where the surface carries a smile.
pub fn is_smiled(&self) -> bool
pub fn is_smiled(&self) -> bool
Whether the surface carries a smile — a strike axis its reads collapse.
pub fn strike_axis(&self) -> StrikeAxis
pub fn strike_axis(&self) -> StrikeAxis
What the strike pillars measure: absolute rates, or spreads to the at-the-money forward.
pub fn over_the_forward(self) -> Self
pub fn over_the_forward(self) -> Self
The same cube, read at spreads to the at-the-money forward rather
than at absolute rates — as a swaption cube is quoted, its columns
resolving as strike = atm_forward + spread.
Each node holds the total vol at its own spread, not a spread over a separate at-the-money surface, so every node stays one free parameter of the risk lift.
fn strike_count(&self) -> usize
fn strike_count(&self) -> usize
How many strike columns the grid holds: one where there is no smile.
pub fn parameters(&self) -> &[f64]
pub fn parameters(&self) -> &[f64]
The free parameters — every node vol, row-major by expiry.
pub fn parameter_keys(&self) -> Vec<(f64, f64, Option<f64>)>
pub fn parameter_keys(&self) -> Vec<(f64, f64, Option<f64>)>
(expiry_years, tenor_years, strike) per parameter, in parameter order,
with no strike where the surface carries no smile.
pub fn view<R: Scalar>(&self) -> RateVolView<'_, R>
pub fn view<R: Scalar>(&self) -> RateVolView<'_, R>
The surface at mode R: the passive lift borrows, every active mode
converts.
pub fn view_with<'a, R: Scalar>(
&'a self,
params: &'a [R],
) -> Result<RateVolView<'a, R>, RateVolError>
pub fn view_with<'a, R: Scalar>( &'a self, params: &'a [R], ) -> Result<RateVolView<'a, R>, RateVolError>
The surface over a caller’s parameter vector.
§Errors
RateVolError::ParameterCountMismatch on the wrong length.
Trait Implementations§
§impl Clone for RateVolSurface
impl Clone for RateVolSurface
§fn clone(&self) -> RateVolSurface
fn clone(&self) -> RateVolSurface
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more