pub struct ImpliedBlackVolatility { /* private fields */ }Expand description
Builder-backed container that represents the inputs required to compute the implied Black volatility for an undiscounted European option.
Use the generated ImpliedBlackVolatility::builder() to construct this
type. The builder performs input validation when you call .build().
Or use .build_unchecked() to skip validation.
Fields:
forward: forward price of the underlying (F). Must be finite and> 0.strike: strike price (K). Must be finite and> 0.expiry: time to expiry (T). Must be finite and>= 0.is_call:truefor a call option,falsefor a put option.option_price: observed undiscounted option price (P). Must be finite and>= 0.
This struct is consumed by calculate::<SpFn>() which performs the numerical
inversion BS(F, K, T, σ) = P to find the implied volatility σ.
Implementations§
Source§impl ImpliedBlackVolatility
impl ImpliedBlackVolatility
Sourcepub const fn builder() -> ImpliedBlackVolatilityBuilder
pub const fn builder() -> ImpliedBlackVolatilityBuilder
Create an instance of ImpliedBlackVolatility using the builder syntax
Source§impl ImpliedBlackVolatility
impl ImpliedBlackVolatility
Sourcepub fn calculate<SpFn: SpecialFn>(&self) -> Option<f64>
pub fn calculate<SpFn: SpecialFn>(&self) -> Option<f64>
Compute the implied Black volatility σ for the stored inputs.
Returns:
Some(σ)if an implied volatility consistent withBS(F, K, T, σ) = Pexists, and the numerical routine converges to a finite value.Noneif the givenoption_priceis outside the attainable range for the supplied model parameters.
§Type parameter
SpFn: SpecialFn— implementation of theSpecialFntrait used for internal special-function computations. UseDefaultSpecialFnfor the crate-provided default behavior, or supply your own implementation to change numerical characteristics.
§Examples
use implied_vol::{DefaultSpecialFn, ImpliedBlackVolatility};
let iv = ImpliedBlackVolatility::builder()
.option_price(10.0)
.forward(100.0)
.strike(100.0)
.expiry(1.0)
.is_call(true)
.build().unwrap();
let sigma = iv.calculate::<DefaultSpecialFn>().unwrap();
assert!(sigma.is_finite());Auto Trait Implementations§
impl Freeze for ImpliedBlackVolatility
impl RefUnwindSafe for ImpliedBlackVolatility
impl Send for ImpliedBlackVolatility
impl Sync for ImpliedBlackVolatility
impl Unpin for ImpliedBlackVolatility
impl UnwindSafe for ImpliedBlackVolatility
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