Python library for calculating option prices, implied volatility and greeks.
Maintained. Last release 6 months ago, commits in 0 of the last 26 weeks. Weaker on commit activity.
pip install vollibvollib
vollib is a python library for calculating option prices, implied volatility and greeks. At its core is Peter Jaeckel's source code for LetsBeRational, an extremely fast and accurate algorithm for obtaining Black's implied volatility from option prices.
Building on this solid foundation, vollib provides functions to calculate option prices, implied volatility and greeks using Black, Black-Scholes, and Black-Scholes-Merton. vollib implements both analytical and numerical greeks for each of the three pricing formulae.
Input domain
Strike prices (K) must be strictly positive for the Black, Black-Scholes, and Black-Scholes-Merton pricing functions. A zero strike call has a well-defined mathematical limit, but vollib does not special-case that boundary; it preserves the domain and behavior of the underlying LetsBeRational implementation. If an application wants to support K = 0, handle that boundary before calling vollib.
This domain requirement applies equally to calls and puts:
| Strike input | Calls | Puts |
|---|---|---|
K = 0 | raises ZeroDivisionError | raises ZeroDivisionError |
K < 0 | raises ValueError | raises ValueError |
Installation
vollib 1.0.11 supports Python 3.9 through 3.13.
pip install vollib
Package history
The original vollib 0.1.x package was the Python 2.7/C-SWIG implementation. It remains available on PyPI for pinned legacy installs, but it is deprecated.
The py_vollib 1.0.x package name was introduced for the pure-Python implementation with Python 3 support. Starting with vollib 1.0.7, the canonical package name is again vollib.
Migration from py_vollib
The canonical Python package is now vollib. Existing py_vollib.* imports remain available as a compatibility namespace for this transition release, but they are deprecated. New code should import from vollib:
from vollib.black_scholes import black_scholes
Existing code like this will continue to work for now: