pub struct VolatilitySurface { /* private fields */ }Expand description
A volatility surface given as a grid of quoted points.
Maturities run along one axis and strikes along the other, and every cell holds the volatility quoted there. Between the grid lines the surface is bilinear: linear in maturity, linear in strike, in that order. Outside them it is held flat at the edge value — the same convention the yield curve uses, stated here for the same reason: it is an assumption, and an assumption that is written down can be argued with.
The grid is deliberately the whole model. A parametric fit — a smile function with its own coefficients — would produce a smooth surface everywhere, including where nothing was quoted, and its shape would come from the parametrisation rather than from the market. Interpolating what was actually quoted keeps the two apart.
validity bounds how far a caller may ask beyond the quoted range before the surface refuses
to answer. Flat extrapolation one strike beyond the grid is a mild assumption; ten strikes
beyond it is a fabrication, and the difference should not be silent.
Implementations§
Source§impl VolatilitySurface
impl VolatilitySurface
Sourcepub fn new(
reference: Date,
maturities: Vec<f64>,
strikes: Vec<f64>,
volatilities: Vec<Vec<f64>>,
day_count: DayCountConvention,
validity: SurfaceValidity,
) -> Result<Self, ValuationContextError>
pub fn new( reference: Date, maturities: Vec<f64>, strikes: Vec<f64>, volatilities: Vec<Vec<f64>>, day_count: DayCountConvention, validity: SurfaceValidity, ) -> Result<Self, ValuationContextError>
Builds a surface from a grid.
maturities are years from reference, strikes are prices, and volatilities is one
row per maturity. Both axes must be finite, strictly ascending and non-empty, every
volatility finite and non-negative, and the grid rectangular.
Sourcepub fn flat(
reference: Date,
volatility: f64,
day_count: DayCountConvention,
) -> Result<Self, ValuationContextError>
pub fn flat( reference: Date, volatility: f64, day_count: DayCountConvention, ) -> Result<Self, ValuationContextError>
A surface with one volatility everywhere — the compatible special case, so a caller who only has one number keeps working.
pub fn reference_date(&self) -> Date
Sourcepub fn volatility_at(
&self,
time: f64,
strike: f64,
) -> Result<f64, ValuationContextError>
pub fn volatility_at( &self, time: f64, strike: f64, ) -> Result<f64, ValuationContextError>
Volatility for a maturity in years and a strike.
Sourcepub fn volatility(
&self,
expiry: Date,
strike: f64,
) -> Result<f64, ValuationContextError>
pub fn volatility( &self, expiry: Date, strike: f64, ) -> Result<f64, ValuationContextError>
Volatility for an expiry date and a strike.
Trait Implementations§
Source§impl Clone for VolatilitySurface
impl Clone for VolatilitySurface
Source§fn clone(&self) -> VolatilitySurface
fn clone(&self) -> VolatilitySurface
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more