#[non_exhaustive]pub struct IvQuery {
pub market_price: f64,
pub f: f64,
pub k: f64,
pub t: f64,
pub r: f64,
pub is_call: bool,
}Expand description
A market quote to invert for implied volatility: the observed
market_price plus the option’s f, k, t, r, and is_call.
use black_76::{IvQuery, SolverConfig, call_price};
let market = call_price(100.0, 100.0, 1.0, 0.20, 0.0);
let result = IvQuery::new(market, 100.0, 100.0, 1.0, 0.0, true)
.solve(&SolverConfig::default());
assert!(result.converged);
assert!((result.iv - 0.20).abs() < 1e-6);New fields may be added in future minor versions.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.market_price: f64Observed option market price.
f: f64Forward / futures price.
k: f64Strike.
t: f64Time to expiry, in years.
r: f64Risk-free rate (annualized, continuously compounded).
is_call: booltrue for a call quote, false for a put.
Implementations§
Source§impl IvQuery
impl IvQuery
Sourcepub const fn new(
market_price: f64,
f: f64,
k: f64,
t: f64,
r: f64,
is_call: bool,
) -> Self
pub const fn new( market_price: f64, f: f64, k: f64, t: f64, r: f64, is_call: bool, ) -> Self
Construct a quote from market price, forward, strike, time, rate, flag.
Sourcepub fn solve(&self, config: &SolverConfig) -> SolverResult
pub fn solve(&self, config: &SolverConfig) -> SolverResult
Solve for implied volatility. Like solve_iv, this returns a
SolverResult: check converged before consuming iv (it is
NaN on every non-converged path).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for IvQuery
impl<'de> Deserialize<'de> for IvQuery
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for IvQuery
impl StructuralPartialEq for IvQuery
Auto Trait Implementations§
impl Freeze for IvQuery
impl RefUnwindSafe for IvQuery
impl Send for IvQuery
impl Sync for IvQuery
impl Unpin for IvQuery
impl UnsafeUnpin for IvQuery
impl UnwindSafe for IvQuery
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more