Skip to main content

MIN_VOLATILITY

Static MIN_VOLATILITY 

Source
pub static MIN_VOLATILITY: LazyLock<Positive>
Expand description

Minimum allowed volatility value as a Positive decimal.

Prevents numerical issues in financial calculations with near-zero volatility. Initialized once via LazyLock, like the six cells below it.

§Why the Err arm cannot fire

Each of these initialisers is a closure over nothing: its only input is a dec!(…) literal, expanded to a fixed mantissa and scale at compile time. Positive::new_decimal rejects exactly one thing, a value below the lower bound — zero without the non-zero feature, which this crate does not enable — and every literal here is strictly positive. There is no runtime value that reaches the Err arm, and no Positive constant to return in its place: positive keeps from_decimal_const crate-private, so a const alternative does not exist for values outside its own constant ladder. The alternative to aborting would be a stand-in like Positive::ZERO, which would silently make every annualisation divide by zero — worse than the abort it replaced.