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
impl CreditVolSurface
pub fn new(points: &[(f64, f64)]) -> Result<Self, CreditVolError>
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>
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 scaled(&self, factor: f64) -> Self
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>
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 parameters(&self) -> &[f64]
pub fn parameters(&self) -> &[f64]
The stored vols, in expiry order: the surface’s parameters.
pub fn view<R: Scalar>(&self) -> CreditVolView<'_, R>
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>
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
impl Clone for CreditVolSurface
§fn clone(&self) -> CreditVolSurface
fn clone(&self) -> CreditVolSurface
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for CreditVolSurface
impl Debug for CreditVolSurface
§impl PartialEq for CreditVolSurface
impl PartialEq for CreditVolSurface
§fn eq(&self, other: &CreditVolSurface) -> bool
fn eq(&self, other: &CreditVolSurface) -> bool
self and other values to be equal, and is used by ==.