Implied Vol
Overview
implied-vol
is a high-performance, pure Rust library for calculating implied volatility,
implemented based on the methods described in Peter Jäckel's seminal papers.
Usage
This crate exposes builders for computing:
- the implied Black volatility,
- the implied Normal (Bachelier) volatility,
- (undiscounted) European option prices under the Black–Scholes model,
- (undiscounted) European option prices under the Bachelier model.
Additionally, the crate provides a trait for implementing custom special functions, which can be used to customize the calculation of implied volatilities and option prices.
Add the following to your Cargo.toml
:
[]
= "2.0"
The calculations are performed via builders that allow you to handle errors.
Example
use ;
let iv_builder = builder
.option_price
.forward
.strike
.expiry
.is_call
.build.unwrap;
let iv = iv_builder..unwrap;
assert!;
More details can be found in the crate documentation.
Source References
This crate implements algorithms from two key papers by Peter Jäckel:
-
Let's Be Rational — A method for accurately and efficiently extracting Black implied volatility from option prices.
-
Implied Normal Volatility — An analytical formula for computing implied normal (Bachelier) volatility from vanilla option prices.
Both papers and related materials are available on Peter Jäckel's website.
Performance
Benchmark results, available via our GitHub Actions, compare the execution speed against FFI to Jäckel’s original reference C++ implementation. With aggressive compiler optimizations applied to both implementations, this Rust crate often outperforms the C++ FFI version.
Precision
The prices reconstructed using implied volatilities (both Black and normal) calculated from given prices exhibit relative errors less than four times the machine epsilon (f64::epsilon) compared to the original prices, as confirmed by random tests.
Cargo Feature Flags
fma
: Enables Fused Multiply-Add (FMA) instructions when supported by the target CPU, providing a slight performance boost over the default implementation.
License
This project is licensed under the MIT License.