#[non_exhaustive]pub struct SolverConfig {
pub nr_max_iterations: u32,
pub price_tolerance: f64,
pub iv_tolerance: f64,
pub vega_floor: f64,
pub iv_min: f64,
pub iv_max: f64,
pub brent_max_iterations: u32,
pub near_expiry_cutoff_hours: f64,
}Expand description
Configuration for the implied-volatility solver.
Construct via SolverConfig::default for sensible defaults, or via
SolverConfig::builder for selective overrides:
use black_76::SolverConfig;
let cfg = SolverConfig::builder()
.iv_min(0.001)
.iv_max(10.0)
.price_tolerance(1e-10)
.build();
assert_eq!(cfg.iv_max, 10.0);New fields may be added in future minor versions.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.nr_max_iterations: u32Maximum Newton-Raphson iterations before switching to Brent.
price_tolerance: f64Price residual reported by the solver, and the secondary price sanity
threshold for the bracket-collapse path. Convergence itself is decided
in volatility space (see iv_tolerance).
iv_tolerance: f64Volatility-space convergence tolerance. The solver converges when the
Newton step (or the Brent bracket width) in sigma falls below this
value. Deciding convergence in sigma-space behaves the same whether the
forward is 1.0 or 100_000.0, unlike an absolute price tolerance.
vega_floor: f64Minimum vega to continue Newton-Raphson iterations. Below this, the
solver falls back to Brent’s method to avoid the explosive Newton step
(price - target) / vega as vega -> 0 (deep OTM, near expiry).
iv_min: f64Minimum allowed IV (annualized). The solver clamps every NR step to
[iv_min, iv_max]. Default 0.01 (1%).
iv_max: f64Maximum allowed IV (annualized). Default 5.0 (500%).
brent_max_iterations: u32Maximum Brent’s-method iterations.
near_expiry_cutoff_hours: f64Near-expiry cutoff in hours. Below this, the solver bypasses NR/Brent
and returns iv = NaN, converged = false,
status = SolverStatus::NearExpiryIntrinsic; price the option
intrinsically yourself rather than implying a volatility.
Implementations§
Source§impl SolverConfig
impl SolverConfig
Sourcepub fn builder() -> SolverConfigBuilder
pub fn builder() -> SolverConfigBuilder
Returns a fresh builder seeded with the default config.
Trait Implementations§
Source§impl Clone for SolverConfig
impl Clone for SolverConfig
Source§fn clone(&self) -> SolverConfig
fn clone(&self) -> SolverConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SolverConfig
impl Debug for SolverConfig
Source§impl Default for SolverConfig
impl Default for SolverConfig
Source§impl<'de> Deserialize<'de> for SolverConfigwhere
SolverConfig: Default,
impl<'de> Deserialize<'de> for SolverConfigwhere
SolverConfig: Default,
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>,
Source§impl PartialEq for SolverConfig
impl PartialEq for SolverConfig
Source§fn eq(&self, other: &SolverConfig) -> bool
fn eq(&self, other: &SolverConfig) -> bool
self and other values to be equal, and is used by ==.