Skip to main content

FutureOptionVolSurface

Struct FutureOptionVolSurface 

pub struct FutureOptionVolSurface {
    reference: NaiveDate,
    expiries: Vec<NaiveDate>,
    strikes: Vec<f64>,
    vols: Vec<f64>,
    convention: VolConvention,
    measure: DayCountFraction,
}
Expand description

A listed future’s option vol surface.

Fields§

§reference: NaiveDate§expiries: Vec<NaiveDate>

Ascending listed expiries; empty on a flat surface.

§strikes: Vec<f64>

Ascending strikes, per 100 face; empty on a flat surface.

§vols: Vec<f64>

Node vols, row-major by expiry — the free parameters.

§convention: VolConvention§measure: DayCountFraction

The day count the vols are quoted per year of.

Implementations§

§

impl FutureOptionVolSurface

pub fn new( reference: NaiveDate, expiries: Vec<NaiveDate>, strikes: Vec<f64>, rows: &[Vec<f64>], convention: VolConvention, ) -> Result<Self, RateVolError>

A surface marked on reference over ascending expiries × ascending strikes (per 100 face), one row of vols per expiry.

§Errors

RateVolError::Malformed on an empty or non-ascending axis, an expiry on or before reference, a grid that does not match the axes, a non-finite or non-positive vol, or a non-positive strike under the lognormal convention.

pub fn flat( reference: NaiveDate, vol: f64, convention: VolConvention, ) -> Result<Self, RateVolError>

One vol at every expiry and strike, marked on reference. One node, one parameter.

§Errors

RateVolError::Malformed for a non-finite or non-positive vol.

pub fn with_day_count(self, day_count: DayCountFraction) -> Self

This surface with its vols quoted per year of day_count rather than ACT/365F — a guide’s Act/360, say. The node vols are unchanged; only the time an option reads them over is.

pub fn day_count(&self) -> DayCountFraction

The day count the vols are quoted per year of.

pub fn reference(&self) -> NaiveDate

The date the surface was marked on — where its time is measured from.

pub fn convention(&self) -> VolConvention

The quoting convention: a Black-76 price vol, or a Bachelier price vol in points per year.

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

The listed expiries; empty on a flat surface.

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

The strikes, per 100 face; empty on a flat surface.

pub fn is_flat(&self) -> bool

Whether the surface is one flat vol.

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

The free parameters — every node vol, row-major by expiry.

pub fn parameter_keys(&self) -> Vec<(Option<NaiveDate>, Option<f64>)>

(expiry, strike) per parameter, in parameter order; both None on a flat surface.

pub fn len(&self) -> usize

How many parameters the surface holds.

pub fn is_empty(&self) -> bool

Whether the surface holds no parameters. Never true of a built one.

pub fn scaled(&self, factor: f64) -> Self

Every node vol multiplied by factor — a relative vol shock.

pub fn mapped(&self, f: impl Fn(f64, f64) -> f64) -> Option<Self>

Each node vol replaced by f(expiry_years, vol), the years measured from the reference date (a flat surface’s node reads at one year, as the other flat vol surfaces do); None when a node leaves (0, ∞).

pub fn view<R: Scalar>(&self) -> FutureOptionVolView<'_, 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<FutureOptionVolView<'a, R>, RateVolError>

The surface over a caller’s parameter vector.

§Errors

RateVolError::ParameterCountMismatch on the wrong length.

Trait Implementations§

§

impl Clone for FutureOptionVolSurface

§

fn clone(&self) -> FutureOptionVolSurface

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 FutureOptionVolSurface

§

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

Formats the value using the given formatter. Read more
§

impl PartialEq for FutureOptionVolSurface

§

fn eq(&self, other: &FutureOptionVolSurface) -> 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 FutureOptionVolSurface

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.