Skip to main content

fast-vollib icon

fast-vollib

Accelerated derivatives pricing, implied volatility, portfolio P&L, typed instruments, and Monte Carlo simulation with NumPy, PyTorch, and JAX backends.

PyPI version Python versions License: Apache 2.0 Tests Docs DOI arXiv paper

Works with NumPy, PyTorch, and JAX Follow @RaeidSaqur on X Raeid Saqur on LinkedIn

fast-vollib is an accelerated --- kernel-fused, optimized --- Python library for Black, Black-Scholes, and Black-Scholes-Merton pricing, implied volatility, Greeks, portfolio P&L, typed derivative contracts, and explicit Monte Carlo workflows. It has pluggable NumPy, PyTorch, and JAX backends and a compatibility-first functional API modeled on py_vollib_vectorized.


What's New?

v0.2.5 — Implied-volatility validation.

  • Halley uses an out-of-the-money objective and a sign-checked bracket.
  • Select a solver with solver= in functional and DataFrame implied-volatility calls.
  • Both solvers use the documented row policy and error signal. See the validation results and limits in the Jäckel guide.
  • v0.2.5 uses the Apache License 2.0.

See the v0.2.5 changelog and benchmark guide.

v0.2.4 — Listed-option P&L workflows. Build observation-backed positions and inspect their terminal payoff, current quote indications and European model value:

  • Evidence and accounting — immutable observations, revision-aware as-of snapshots, explicit option strategies and Decimal FIFO realized/unrealized P&L.
  • Terminal curves and quote marks — exact breakevens/extrema, explicit bid/ask policies, missing-data diagnostics and labelled JSON/CSV/figure exports.
  • European horizon valuation — batched repricing, explicit volatility/forward/ time policies, coherent surface-sensitivity bands and position Greeks with units.
  • Retained forecasts and terminal laws — fixed-grid sample identity and weights, explicit scenario projection and profit probability under a specified law.
  • Offline broker evidence — saved Questrade mappings with explicit fees and execution/activity cash comparisons; synthetic examples do not establish real-account reconciliation.

Quote indications are not executable spread fills. American model valuation is not added: separate European surrogate reports retain exercise/delivery caveats. Surface-sensitivity bands are not joint P&L probabilities, VaR or ES.

See the v0.2.4 changelog, Terminal P&L guide, Horizon P&L guide, and Retained Forecasts guide.

v0.2.3 — Fixed-income models and Python support. This release adds fixed-income contracts and stochastic-rate workflows alongside the existing equity APIs:

  • Bonds and discount curves — zero-coupon and fixed-rate bonds, explicit cashflows, and present values using flat, CIR, or interpolated discount curves.
  • CIR, Bates, and BCC97 — short-rate simulation, composable stochastic variance and lognormal jumps, and European-option Fourier pricing.
  • Explicit Monte Carlo discounting — initial state and constant-rate or pathwise short-rate discounting without changing the existing defaults.
  • Python compatibility — Python 3.14 support and experimental Python 3.15 release-candidate support for the default and JAX backends. PyTorch, numba, RAPIDS, and pyarrow are not included on 3.15; GPU operation is not validated.

See the v0.2.3 changelog, Fixed Income guide, and Simulation guide.

v0.2.2 — IV-surface diagnostics and models. This release extends the surface arbitrage harness into an end-to-end public model layer for producing, fitting, evaluating, and sampling implied-volatility surfaces:

  • Surface contracts and coordinates — definite surfaces, distributions, canonical surface points, explicit market state, grid materialization, and reproducible coordinate conversion.
  • Fitting and forecasting — flat, SVI/SVI-JW, SSVI, spline, PCA, Tikhonov, Kalman, persistence, and Heston implementations behind a fixed, machine-readable capability registry.
  • Evaluation and diagnostics — coverage-aware deterministic metrics, per-draw generative evaluation, static-arbitrage verification, public JSON schemas, and publication-quality diagnostic plots.
  • Heston support — QE and full-truncation simulation, two independent Fourier-pricing formulations, an implied-volatility surface, and calibration.

See the v0.2.2 changelog, Surface Models guide, and Diagnostics guide.

v0.2.0 — Processes, simulation, and instruments. This release extends the library from pricing kernels to typed contracts and Monte Carlo workflows. It is the next stable release after v0.1.8; no v0.1.9 release was cut. Three major public modules are included:

  • fast_vollib.processes provides stateless stochastic-process dynamics, beginning with exact geometric Brownian motion on regular or irregular time grids.
  • fast_vollib.simulation provides validated, backend-native scenarios and an explicit Monte Carlo engine with standard errors, antithetic sampling, and PyTorch/JAX automatic differentiation.
  • fast_vollib.instruments provides immutable contract objects, columnar option batches, market-input adapters, payoffs, serialization, and capability discovery while keeping the existing functional pricing API canonical.

See the v0.2.0 changelog, instrument guide, and simulation guide for the complete contracts and examples.

v0.1.8 — Differentiable Jäckel implied volatility. fast_vollib.jackel now ships autograd wrappers around the "Let's Be Rational" solver for PyTorch and JAX:

  • implied_volatility_autograd (PyTorch) and implied_volatility_autograd_jax (JAX custom_vjp) — the forward pass runs the full Jäckel solver (~2e-11 relative error); the backward pass applies the implicit function theorem to the discounted pricing equation (∂σ/∂price = 1/ν, ∂σ/∂θ = −(∂price/∂θ)/ν with ν = vega), giving exact gradients w.r.t. price, spot, strike, maturity, rate, and dividend yield without back-propagating through the branch-heavy Householder iterations.
  • Well-defined edge behavior — invalid domain (below-intrinsic, non-positive price / spot / strike, zero maturity) yields NaN in both forward and backward; an upstream-aware low-vega guard returns a zero gradient when the upstream cotangent is exactly zero, so 0 × NaN chain-rule poisoning cannot contaminate valid rows.
  • Training-loop guide — a new Differentiable Jäckel IV page with PyTorch IV-loss and hybrid price + IV-roundtrip examples, a JAX equivalent, and an expanded tutorial notebook.
  • Dev-environment: CUDA wheels are now selected by CPU architecture (cu130 on x86_64, cu126 on aarch64 / GH200), and an in-tree testcapi-compat shim keeps py_lets_be_rational 1.0.x importable on python-build-standalone interpreters.
import torch
from fast_vollib.jackel import implied_volatility_autograd

price = price.requires_grad_(True)
sigma = implied_volatility_autograd(price, S, K, t, r, is_call, q=q, model="black_scholes")
sigma.sum().backward()   # exact ∂σ/∂price = 1/vega via the implicit function theorem

v0.1.7 — IV-surface arbitrage evaluation harness. fast_vollib.surface is a generator-agnostic, backend-pluggable evaluator for implied-volatility surfaces:

  • IVSurface / SurfaceSequence containers — build from log-moneyness, strikes, total variance, or call prices; numpy / torch / jax arrays are preserved with dtype and device.
  • validate_surface() → ArbitrageReport — price-space checks (convexity, slope, box, calendar) and total-variance checks (∂_T w ≥ 0, Durrleman g ≥ 0) with normalized, cross-model metrics, localized violations, an interpolation-artifact vs model-arbitrage split, and a σ→C→σ' round-trip trust mask.
  • arbitrage_penalty() — a differentiable soft form of the same checks that never leaves the input tensor's namespace, so it is autograd-traceable on torch/jax and drops directly into a surface generator's training loss.
  • fast_vollib.diagnostics — six publication-quality figures (total-variance slices, Durrleman g, risk-neutral density, violation heatmap, calendar map, trust map) behind the optional [viz] extra: pip install "fast-vollib[viz]".
from fast_vollib.surface import IVSurface, validate_surface, arbitrage_penalty

surf = IVSurface.from_logmoneyness(k, T, iv)   # numpy, torch, or jax iv grid
report = surf.validate()                       # → ArbitrageReport (passed, metrics, violations)
loss = pricing_loss + arbitrage_penalty(iv, k, T, forward)  # differentiable soft constraint

See the surface harness guide and the changelog for details.


Features

  • Three pricing models — Black-76, Black-Scholes, Black-Scholes-Merton

  • Two implied-volatility solvers. Halley is the default for functional calls. Use solver="jackel" to select Jäckel's "Let's Be Rational" solver. See the Jäckel guide for validation and gradient support.

  • Full Greeks — delta, gamma, theta, rho, vega; all five in one get_all_greeks call

  • Pluggable backends — NumPy (default), PyTorch (CUDA), JAX (JIT)

  • Automatic backend selection — prefers CUDA > JAX > NumPy

  • DataFrame-native — price_dataframe works directly on a pandas.DataFrame

  • API compatibility — patch_py_vollib() and patch_py_vollib_vectorized() patch the scalar and vectorized upstream namespaces

  • Surface arbitrage harness — fast_vollib.surface scores generated IV surfaces for static arbitrage with normalized, cross-model metrics and a differentiable training penalty (guide)

  • Typed instruments — immutable vanilla, digital, Asian, barrier, lookback, and variance-swap contracts with strict serialization and columnar option batches

  • Processes and scenarios — backend-native GBM paths on regular or irregular grids, preserving NumPy, PyTorch, and JAX semantics

  • Explicit Monte Carlo — opt-in valuation with standard errors, antithetic sampling, capability discovery, and no silent analytic/Monte Carlo fallback


Listed-option P&L and retained forecasts

Listed-option entries and observation-derived Decimal FIFO snapshots support terminal intrinsic-equivalent P&L curves with exact breakevens and extrema. See the terminal P&L guide for an offline example and explicit American-exercise and physical-delivery assumptions.

Observed quote marks support explicit midpoint or per-leg close estimates, with missing-data diagnostics and separate future costs. Offline Third-party Platform (e.g., Questrade) normalization accepts saved, versioned payloads and compares execution/activity cash without adding both ledgers. Synthetic examples do not establish real-account reconciliation.

Horizon valuation adds batched European repricing, coherent surface sensitivity, labelled position Greeks and specified-law terminal profit probabilities. European proxies for American contracts retain separate types and caveats; surface-sensitivity bands are not joint P&L probabilities.

The retained forecasting guide describes generic targets, fixed-grid process/surface draws and explicit financial trajectory projection.


Install

pip install fast-vollib

Optional extras:

pip install "fast-vollib[torch]"       # PyTorch backend
pip install "fast-vollib[jax]"         # JAX backend
pip install "fast-vollib[torch,jax]"   # both backends

Development snapshots from TestPyPI

Stable releases are published from Git tags to PyPI. After v0.2.0, development snapshots from main use TestPyPI versions such as 0.2.1.devN.

pip install --pre \
  --index-url https://test.pypi.org/simple/ \
  --extra-index-url https://pypi.org/simple/ \
  fast-vollib

Use the dev TestPyPI channel only if you want nightly or dev builds only.


Quick start

import numpy as np
import fast_vollib

# Price a batch of European options
prices = fast_vollib.fast_black_scholes(
    flag=np.array(["c", "c", "p"]),
    S=100.0,
    K=np.array([95, 100, 105]),
    t=0.25,
    r=0.05,
    sigma=0.20,
    return_as="numpy",
)

# Recover implied volatility
iv = fast_vollib.fast_implied_volatility(
    price=prices,
    S=100.0,
    K=np.array([95, 100, 105]),
    t=0.25,
    r=0.05,
    flag=np.array(["c", "c", "p"]),
    return_as="numpy",
)

# All Greeks in one call (returns a pandas DataFrame)
greeks = fast_vollib.get_all_greeks(
    flag=np.array(["c", "p"]),
    S=100.0, K=100.0, t=0.25, r=0.05, sigma=0.20,
)

DataFrame helper

import pandas as pd

df = pd.DataFrame({
    "flag": ["c", "p"],
    "S": [100, 100],
    "K": [100, 100],
    "t": [0.25, 0.25],
    "r": [0.05, 0.05],
    "sigma": [0.20, 0.20],
})

result = fast_vollib.price_dataframe(
    df,
    flag_col="flag",
    underlying_price_col="S",
    strike_col="K",
    annualized_tte_col="t",
    riskfree_rate_col="r",
    sigma_col="sigma",
)
# Columns: Price, delta, gamma, theta, rho, vega

Compatibility with py_vollib_vectorized

The py_vollib_vectorized API can be kept intact in your codebase via the included monkey-patching helper.

import fast_vollib
fast_vollib.patch_py_vollib_vectorized()

# All py_vollib_vectorized imports now use fast_vollib transparently
from py_vollib_vectorized import vectorized_black_scholes

Backend selection

# Automatic (CUDA > JAX > NumPy)
fast_vollib.get_backend()        # e.g. "torch"

# Set for the session
fast_vollib.set_backend("numpy")

# Override per call
price = fast_vollib.fast_black_scholes(..., backend="jax")

backend="auto" resolution order:

  1. Explicit backend= kwarg
  2. fast_vollib.set_backend() override
  3. FAST_VOLLIB_BACKEND environment variable
  4. torch when torch.cuda.is_available()
  5. jax when installed
  6. numpy

Public API

from fast_vollib import (
    # Pricing
    fast_black,
    fast_black_scholes,
    fast_black_scholes_merton,
    # Implied volatility
    fast_implied_volatility,
    fast_implied_volatility_black,
    # Greeks (compatibility aliases)
    vectorized_delta,
    vectorized_gamma,
    vectorized_rho,
    vectorized_theta,
    vectorized_vega,
    get_all_greeks,
    # Utilities
    price_dataframe,
    patch_py_vollib,
    patch_py_vollib_vectorized,
    get_backend,
    set_backend,
)

Full documentation: raeidsaqur.github.io/fast-vollib


Development

git clone https://github.com/raeidsaqur/fast-vollib.git
cd fast-vollib

uv sync --all-groups --extra torch --extra jax   # all deps + both backends
uv run pytest               # run tests
ruff check . --fix          # lint
ruff format .               # format
uv run mkdocs serve         # local docs server → http://localhost:8000

Release model

  • Pushing a version tag like v0.2.3 triggers the stable PyPI build.
  • Pushes to main publish development snapshots to TestPyPI.
  • The package version is derived from Git tags with hatch-vcs, so version strings are no longer maintained manually in source files for each release.
  • A GitHub Release adds release notes and downloads to the same existing tag; publishing that release page is separate from the PyPI workflow.

See the release procedure for keeping the tag, package version, and GitHub Release aligned.


Contributing

Contributions are welcome. Please open an issue before sending a large pull request to discuss the change. See CONTRIBUTING.md if present, or follow the standard fork-and-PR workflow.


Citation

If you use fast-vollib in your work, please cite:

@misc{saqur2026fastvollibfastimpliedvolatility,
      title={Fast-Vollib: A Fast Implied Volatility Library for Python with PyTorch, JAX, and CUDA Fused-Kernel Backends},
      author={Raeid Saqur},
      year={2026},
      eprint={2604.27210},
      archivePrefix={arXiv},
      primaryClass={q-fin.CP},
      url={https://arxiv.org/abs/2604.27210},
}

To cite the software itself (archived on Zenodo):

@software{saqur_fast_vollib,
      author    = {Raeid Saqur},
      title     = {fast-vollib},
      year      = {2026},
      publisher = {Zenodo},
      doi       = {10.5281/zenodo.22150801},
      url       = {https://doi.org/10.5281/zenodo.22150801},
}

Machine-readable citation metadata lives in CITATION.cff, which also powers GitHub's Cite this repository button. Each tagged release is archived on Zenodo with its own DOI; the badge above resolves to the concept DOI 10.5281/zenodo.22150801, which always points at the latest version. Cite a specific version's DOI instead if you need exact reproducibility.


License

Apache License 2.0. See LICENSE.

Metadata

Release files for fast-vollib 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fast-vollib 0.2.5
File Size Uploaded Provenance Actions
fast_vollib-0.2.5.tar.gz 2.0 MB With provenance Details for fast_vollib-0.2.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fast-vollib 0.2.5
File Interpreter ABI Platform Actions
fast_vollib-0.2.5-py3-none-any.whl Python 3 none any Details for fast_vollib-0.2.5-py3-none-any.whl

Total release size: 2.6 MB

Release files / fast_vollib-0.2.5.tar.gz

Download URL fast_vollib-0.2.5.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
7260e8f06e7227859feaf02bee4f20679b83f1f780484614b9e2a8bdf7a8463c
BLAKE2b-256 checksum
How to use checksums
6205b98c2d719a4c44541f5b6fed47461dc7c3eaf61699babb2e7fb221b6fca1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / fast_vollib-0.2.5-py3-none-any.whl

Download URL fast_vollib-0.2.5-py3-none-any.whl
Size 607.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2496c6202bf4c5954662f3a06a707122e562fe3877ceb1020c6bc3dfe6e96112
BLAKE2b-256 checksum
How to use checksums
f26f132f3c3de3cddf319f34ecb56a345c17feada70e26349c1be4162ea425f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for fast-vollib 0.2.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fast_vollib-0.2.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page