Skip to main content

Quote

Struct Quote 

Source
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: f64

Log-moneyness k = ln(K / F).

§w: f64

Observed total implied variance w = sigma_BS^2 * T.

§weight: f64

Non-negative fitting weight (e.g. vega or inverse bid-ask spread).

Implementations§

Source§

impl Quote

Source

pub fn new(k: f64, w: f64, weight: f64) -> Result<Self, ParamError>

Creates a validated market quote.

§Errors
§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 }),
);
Source

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);
Source

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);

Trait Implementations§

Source§

impl Clone for Quote

Source§

fn clone(&self) -> Quote

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
Source§

impl Debug for Quote

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Quote

Source§

fn eq(&self, other: &Quote) -> 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.
Source§

impl Copy for Quote

Source§

impl StructuralPartialEq for Quote

Auto Trait Implementations§

§

impl Freeze for Quote

§

impl RefUnwindSafe for Quote

§

impl Send for Quote

§

impl Sync for Quote

§

impl Unpin for Quote

§

impl UnsafeUnpin for Quote

§

impl UnwindSafe for Quote

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.