Skip to main content

Crate jaeckel

Crate jaeckel 

Source
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);

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).