Expand description
§Jaeckel
A Rust port of Peter Jäckel’s algorithms on http://www.jaeckel.org
§Let’s Be Rational
The Rust crate is based on the latest (2024) version of the C++ reference implementation The conditionally compiled features in the C++ reference implementation are not included in this crate The PJ-2024-Inverse-Normal algorithm are used to inverse the normal cumulative distribution funciton and the AS241 algorighm is omitted
§Example
use jaeckel::{black, implied_black_volatility};
// Calculate option price
let forward = 100.0;
let strike = 110.0;
let volatility = 0.2;
let time_to_expiry = 1.0;
let is_call = 1.0; // 1.0 for call, -1.0 for put
let price = black(forward, strike, volatility, time_to_expiry, is_call);
// Calculate implied volatility from price
let implied_vol = implied_black_volatility(price, forward, strike, time_to_expiry, is_call);
assert!((implied_vol - volatility).abs() < 1e-14);§Copyright
Original C++ implementation Copyright © 2013-2023 Peter Jäckel.
Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved.
Functions§
- black
- Calculate Black-Scholes option price.
- convex_
rational_ cubic_ control_ parameter_ to_ fit_ second_ derivative_ at_ left_ side - Calculate convex rational cubic control parameter to fit second derivative at left side.
- convex_
rational_ cubic_ control_ parameter_ to_ fit_ second_ derivative_ at_ right_ side - Calculate convex rational cubic control parameter to fit second derivative at right side.
- erf_
cody - Error function using Cody’s algorithm.
- erfc_
cody - Complementary error function using Cody’s algorithm.
- erfcx_
cody - Scaled complementary error function using Cody’s algorithm.
- erfinv
- Inverse error function.
- householder3_
factor - Householder’s third-order convergence factor for root finding.
- householder4_
factor - Householder’s fourth-order convergence factor for root finding.
- implied_
black_ volatility - Calculate implied volatility from Black-Scholes price.
- inverse_
norm_ cdf - Inverse cumulative normal distribution function.
- minimum_
rational_ cubic_ control_ parameter - Calculate minimum rational cubic control parameter.
- norm_
cdf - Cumulative normal distribution function.
- norm_
pdf - Standard normal probability density function.
- normalised_
black - Calculate normalised Black-Scholes price.
- normalised_
implied_ black_ volatility - Calculate implied volatility from normalised Black-Scholes price.
- normalised_
vega - Calculate normalised vega.
- normalised_
volga - Calculate normalised volga.
- rational_
cubic_ control_ parameter_ to_ fit_ second_ derivative_ at_ left_ side - Calculate control parameter to fit second derivative at left side.
- rational_
cubic_ control_ parameter_ to_ fit_ second_ derivative_ at_ right_ side - Calculate control parameter to fit second derivative at right side.
- rational_
cubic_ interpolation - Rational cubic interpolation function.
- vega
- Calculate Black-Scholes vega (price sensitivity to volatility).
- volga
- Calculate Black-Scholes volga (second derivative with respect to volatility).