pub struct Quote {
pub k: f64,
pub w: f64,
pub weight: f64,
}Expand description
A single market quote: a log-moneyness, an observed total implied variance, and a non-negative fitting weight.
A slice is a set of quotes sharing one maturity. The weight is any
non-negative number expressing the relative trust placed in the quote
during calibration — common choices are option vega or the inverse of the
bid-ask spread. A weight of 0.0 excludes the quote from the fit.
§Invariants
Constructed through Quote::new (checked) or Quote::new_unchecked
(caller-asserted), a Quote always satisfies w >= 0, weight >= 0, and
all three fields finite.
§Examples
use regit_svi::types::Quote;
let q = Quote::new(-0.10, 0.0432, 1.0).unwrap();
assert!((q.k + 0.10).abs() < 1e-15);
assert!((q.w - 0.0432).abs() < 1e-15);Fields§
§k: f64Log-moneyness k = ln(K / F).
w: f64Observed total implied variance w = sigma_BS^2 * T.
weight: f64Non-negative fitting weight (e.g. vega or inverse bid-ask spread).
Implementations§
Source§impl Quote
impl Quote
Sourcepub fn new(k: f64, w: f64, weight: f64) -> Result<Self, ParamError>
pub fn new(k: f64, w: f64, weight: f64) -> Result<Self, ParamError>
Creates a validated market quote.
§Errors
ParamError::NonFiniteif any field isNaNor infinite.ParamError::NegativeTotalVarianceifw < 0.ParamError::NegativeWeightifweight < 0.
§Examples
use regit_svi::types::Quote;
use regit_svi::errors::ParamError;
assert!(Quote::new(0.0, 0.04, 1.0).is_ok());
assert_eq!(
Quote::new(0.0, -0.04, 1.0),
Err(ParamError::NegativeTotalVariance { w: -0.04 }),
);Sourcepub const fn new_unchecked(k: f64, w: f64, weight: f64) -> Self
pub const fn new_unchecked(k: f64, w: f64, weight: f64) -> Self
Creates a quote without validation.
The caller asserts w >= 0, weight >= 0, and all fields finite.
Used on hot paths where the inputs are already known to be valid.
§Examples
use regit_svi::types::Quote;
let q = Quote::new_unchecked(0.0, 0.04, 1.0);
assert!((q.w - 0.04).abs() < 1e-15);Sourcepub fn implied_vol(&self, t: f64) -> Result<f64, ParamError>
pub fn implied_vol(&self, t: f64) -> Result<f64, ParamError>
Returns the Black implied volatility implied by this quote at maturity
t, i.e. sqrt(w / t).
§Errors
Returns ParamError::NonPositiveMaturity if t <= 0.
§Examples
use regit_svi::types::Quote;
let q = Quote::new(0.0, 0.04, 1.0).unwrap();
let vol = q.implied_vol(1.0).unwrap();
assert!((vol - 0.20).abs() < 1e-12);