Struct FxVolSurface
pub struct FxVolSurface {
pair: CurrencyPair,
convention: DeltaConvention,
reference: NaiveDate,
expiries: Vec<NaiveDate>,
smiles: Vec<FxVolSmile>,
flat: Vec<f64>,
day_count: DayCountFraction,
}Expand description
A delta-quoted vol surface for one pair: one smile per expiry, every smile quoting the same deltas.
Fields§
§pair: CurrencyPair§convention: DeltaConvention§reference: NaiveDate§expiries: Vec<NaiveDate>§smiles: Vec<FxVolSmile>§flat: Vec<f64>Every node vol, smile by smile — the free parameters.
day_count: DayCountFractionThe day count the total variance σ²τ is measured in.
A vol is a quote per unit of time, so it cannot be read back without the measure it was quoted under — unlike a discount factor, which is a pure number at a date. ACT/365 fixed by default, which is what this surface measured before the measure could be stated, and what all four major FX markets quote.
Implementations§
§impl FxVolSurface
impl FxVolSurface
pub fn scaled(&self, factor: f64) -> Self
pub fn scaled(&self, factor: f64) -> Self
This surface with every node vol multiplied by factor — a relative
vol shock. Expiries, quotes, convention and day count carry over, so
each smile keeps its shape.
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>
pub fn mapped(&self, f: impl Fn(f64, f64) -> f64) -> Option<Self>
This surface with each node vol replaced by f(expiry_years, vol),
the expiry in years Act/365F from the surface’s reference date — a vol
shock by expiry, reaching every quote of a smile. None when a node
leaves (0, ∞). The smiles and the flat parameter list stay in step.
pub fn mapped_nodes(
&self,
f: impl Fn(f64, DeltaQuote, f64) -> f64,
) -> Option<Self>
pub fn mapped_nodes( &self, f: impl Fn(f64, DeltaQuote, f64) -> f64, ) -> Option<Self>
mapped with each node’s quote as well:
f(expiry_years, quote, vol) — a smile-shape shock reads the node’s
side of ATM from it.
pub fn new(
pair: CurrencyPair,
convention: DeltaConvention,
reference: NaiveDate,
smiles: Vec<(NaiveDate, FxVolSmile)>,
) -> Result<Self, FxVolError>
pub fn new( pair: CurrencyPair, convention: DeltaConvention, reference: NaiveDate, smiles: Vec<(NaiveDate, FxVolSmile)>, ) -> Result<Self, FxVolError>
A surface from (expiry, smile) pairs, sorted by expiry.
§Errors
FxVolError::Empty with no smiles; FxVolError::Malformed for a
duplicate expiry, one on or before the reference date, or smiles that
do not quote the same deltas.
pub fn with_day_count(self, day_count: DayCountFraction) -> Self
pub fn with_day_count(self, day_count: DayCountFraction) -> Self
This surface with its total variance measured under day_count.
The interpolation rule is untouched: linear in σ²τ between expiries
and flat in vol beyond the last is a statement about the shape of total
variance, not about how τ is counted.
pub fn day_count(&self) -> DayCountFraction
pub fn day_count(&self) -> DayCountFraction
The day count the total variance is measured in.
pub fn pair(&self) -> CurrencyPair
pub fn pair(&self) -> CurrencyPair
The pair the surface belongs to.
pub fn convention(&self) -> DeltaConvention
pub fn convention(&self) -> DeltaConvention
The delta convention the smiles are quoted under.
pub fn reference_date(&self) -> NaiveDate
pub fn reference_date(&self) -> NaiveDate
The reference date time is measured from.
pub fn quotes(&self) -> &[DeltaQuote]
pub fn quotes(&self) -> &[DeltaQuote]
The quotes every smile carries, in smile order.
pub fn smile(&self, expiry: NaiveDate) -> Option<&FxVolSmile>
pub fn smile(&self, expiry: NaiveDate) -> Option<&FxVolSmile>
The smile stored at exactly expiry, or None where the surface
holds no smile on that date — a reading of what was stored, not an
interpolation, which is what FxVolView::vol_at_strike does.
pub fn parameters(&self) -> &[f64]
pub fn parameters(&self) -> &[f64]
The free parameters — every node vol, smile by smile.
pub fn parameter_keys(&self) -> Vec<(NaiveDate, DeltaQuote)>
pub fn parameter_keys(&self) -> Vec<(NaiveDate, DeltaQuote)>
(expiry, quote) per parameter, in parameter order.
pub fn view<R: Scalar>(&self) -> FxVolView<'_, R>
pub fn view<R: Scalar>(&self) -> FxVolView<'_, 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<FxVolView<'a, R>, FxVolError>
pub fn view_with<'a, R: Scalar>( &'a self, params: &'a [R], ) -> Result<FxVolView<'a, R>, FxVolError>
The surface over a caller’s parameter vector.
§Errors
FxVolError::ParameterCountMismatch on the wrong length.
fn tau(&self, date: NaiveDate) -> f64
Trait Implementations§
§impl Clone for FxVolSurface
impl Clone for FxVolSurface
§fn clone(&self) -> FxVolSurface
fn clone(&self) -> FxVolSurface
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more