fast-vollib¶
fast-vollib is a fast, modern Python library for Black, Black-Scholes, and Black-Scholes-Merton option pricing, implied volatility solving, and Greeks — with pluggable NumPy, PyTorch, and JAX backends.
Stable tagged releases are published to PyPI. Development snapshots from each
main commit are published to TestPyPI with VCS-derived .devN versions.
Features¶
- Three pricing models — Black-76, Black-Scholes, Black-Scholes-Merton
- Vectorized IV solver — Halley's method with bisection fallback; handles large option chains efficiently
- Machine-precision IV — Jäckel "Let's Be Rational" solver (
jackel/) with Householder(3)×3; max relative error ~10⁻¹⁴ - GPU-fused Jäckel — single-pass Triton kernel achieving 0.056 ms / 100k options on H100
- Full Greeks — delta, gamma, theta, rho, vega, and
get_all_greeksin one call - Pluggable backends — NumPy (default), PyTorch (GPU-accelerated), JAX
- DataFrame-native —
price_dataframeworks directly on pandas DataFrames - Drop-in compatibility — separate patch helpers for
py_vollibandpy_vollib_vectorized - Automatic backend selection — prefers CUDA-capable PyTorch > JAX > NumPy
- Opt-in shape-aware typing —
jaxtyping+beartypeannotations on every public entry point; zero runtime cost unless enabled, and never applied insidetorch.compile/ Triton / Numba / JAX-jit hot paths
Quick example¶
import numpy as np
import fast_vollib
# Price a batch of European calls with Black-Scholes
prices = fast_vollib.fast_black_scholes(
flag=["c", "c", "p"],
S=[100, 105, 95],
K=[100, 100, 100],
t=[0.25, 0.25, 0.25],
r=[0.05, 0.05, 0.05],
sigma=[0.20, 0.20, 0.20],
return_as="numpy",
)
# Recover implied volatility
iv = fast_vollib.fast_implied_volatility(
price=prices,
S=[100, 105, 95],
K=[100, 100, 100],
t=[0.25, 0.25, 0.25],
r=[0.05, 0.05, 0.05],
flag=["c", "c", "p"],
return_as="numpy",
)
# Compute all Greeks at once
greeks = fast_vollib.get_all_greeks(
flag=["c", "c", "p"],
S=[100, 105, 95],
K=[100, 100, 100],
t=[0.25, 0.25, 0.25],
r=[0.05, 0.05, 0.05],
sigma=[0.20, 0.20, 0.20],
)
# returns a pandas DataFrame with columns: delta, gamma, theta, rho, vega
Navigation¶
| Section | Description |
|---|---|
| Installation | Install fast-vollib with pip, uv, or conda |
| Quick Start | More complete worked examples |
| Backend Selection | How to choose between NumPy, PyTorch, and JAX |
| Jäckel IV Solver | Machine-precision IV — algorithm, API, and GPU benchmarks |
| Compatibility | Drop-in py_vollib replacement guide |
| Benchmarks | Performance numbers and how to reproduce them |
| API Reference | Complete function signatures and parameters |
| Changelog | Version history |