Skip to main content

RateVolSurface

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: StrikeAxis

Whether 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: DayCountFraction

The 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

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>

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>

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>

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>

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

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

The day count the expiry axis is measured on.

pub fn convention(&self) -> VolConvention

The quoting convention, which selects the pricing formula.

pub fn expiries(&self) -> &[f64]

The expiry pillars, in years, ascending.

pub fn tenors(&self) -> &[f64]

The tenor pillars, in years, ascending.

pub fn strikes(&self) -> Option<&[f64]>

The strike pillars, ascending, where the surface carries a smile.

pub fn is_smiled(&self) -> bool

Whether the surface carries a smile — a strike axis its reads collapse.

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

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

How many strike columns the grid holds: one where there is no smile.

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>)>

(expiry_years, tenor_years, strike) per parameter, in parameter order, with no strike where the surface carries no smile.

pub fn len(&self) -> usize

How many parameters the surface holds.

pub fn is_empty(&self) -> bool

Whether the surface holds no parameters.

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>

The surface over a caller’s parameter vector.

§Errors

RateVolError::ParameterCountMismatch on the wrong length.

Trait Implementations§

§

impl Clone for RateVolSurface

§

fn clone(&self) -> RateVolSurface

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for RateVolSurface

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl From<RateVolSurface> for RateSmile

§

fn from(surface: RateVolSurface) -> Self

Converts to this type from the input type.
§

impl PartialEq for RateVolSurface

§

fn eq(&self, other: &RateVolSurface) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl StructuralPartialEq for RateVolSurface

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.