Skip to main content

CreditVolSurface

Struct CreditVolSurface 

pub struct CreditVolSurface {
    expiries: Vec<f64>,
    vols: Vec<f64>,
}
Expand description

Black vols of the forward spread by expiry: linear in total variance between quoted expiries, flat in vol beyond either end — the expiry rule a rate vol surface reads by.

Fields§

§expiries: Vec<f64>§vols: Vec<f64>

Implementations§

§

impl CreditVolSurface

pub fn new(points: &[(f64, f64)]) -> Result<Self, CreditVolError>

A surface from (expiry_years, vol) points.

§Errors

CreditVolError for no points, expiries not positive and strictly increasing, or a vol that is not finite and positive.

pub fn flat(vol: f64) -> Result<Self, CreditVolError>

One vol at every expiry, quoted at one year.

§Errors

CreditVolError::Vol for a vol that is not finite and positive.

pub fn points(&self) -> Vec<(f64, f64)>

The quoted (expiry_years, vol) points, in order.

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

This surface with every vol multiplied by factor — the relative shock a vol scenario applies.

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

This surface with each vol replaced by f(expiry_years, vol) — a vol shock by expiry. None when a vol leaves (0, ∞).

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

The quoted expiries, in years: where each parameter sits.

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

The stored vols, in expiry order: the surface’s parameters.

pub fn vol(&self, expiry_years: f64) -> f64

The vol at expiry_years.

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

The surface over a caller’s parameter vector.

§Errors

CreditVolError::ParameterCount on the wrong length.

Trait Implementations§

§

impl Clone for CreditVolSurface

§

fn clone(&self) -> CreditVolSurface

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 CreditVolSurface

§

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

Formats the value using the given formatter. Read more
§

impl PartialEq for CreditVolSurface

§

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

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.