Gammon Capital Announces Updates to Vollib

Posted by Larry Richards on 20 Apr, 2017


Several new enhancements are now available in vollib and lets_be_rational, a collection of open source libraries for option pricing, implied volatility and greeks calculations, based on algorithms published by Peter Jaeckel in his paper, "Let's Be Rational". vollib and lets_be_rational are open source projects hosted by Gammon Capital on GitHub.

What's New

The initial release lets_be_rational for Python was simply a SWIG wrapper around Peter Jaeckel's C source code. The objective was to make these algorithms available to Python programmers, irrespective of operating system. Since lets_be_rational is limited in scope to Black76, we built vollib on top of lets_be_rational to provide the same speed and precision for Black, Black-Scholes and Black-Scholes-Merton, including calculation of the option Greeks.

Because lets_be_rational and vollib supported only Python 2 we have had many requests to support Python 3. We have done this by introducing py_lets_be_rational and py_vollib. These support both Python 2 and 3.

In addition, we are in the process of releasing Java and Javascript versions to the public as well. As you might expect, these are named j_lets_be_rational / j_vollib and js_lets_be_rational / js_vollib.

Execution Speed

The figure below shows a comparison of execution speeds of each version, benchmarked by calling the function black.implied volatility().


It should come as no surprise that pure Python variants execute more slowly than the original C wrapped in Python. To mitigate this speed penalty, we introduced optional support for "Numba". Numba is a tool which enables "array-oriented and math-heavy Python code to be just-in-time compiled to native machine instructions." We have observed a fourfold speed increase by using Numba.

All of the new pure Python variants can be easily installed on any operating system whether Numba is present or not. As of this time, the procedure for installing Numba can be tricky, and differs from one operating system to the next. We decided therefore to leave it up to each user whether and how to install Numba.

Reference Implementations

xx_vollib variants include a reference implementation which does not depend on the magic of lets_be_rational. Instead, they use conventional binary search techniques for computing implied volatility. These reference implementations are intended only for sanity checking, but they also provide a benchmark against which to compare the speed of the lets_be_rational functions.

In the above chart, we can see that even the slowest implementations of lets_be_rational are roughly two orders of magnitude faster than ordinary Newton-Raphson, with the fastest implementations approaching four orders of magnitude speed increase. More specifically, in our benchmark tests, calculating one million implied volatility points took 5525 seconds using the ordinary Newton-Raphson method in Python, whereas for the original lets_be_rational the same took 2.54 seconds, while js_lets_be_rational finished in 1.14 seconds.

For more information and API documentation visit the Vollib website at

All variants of vollib and lets_be_rational are provided under the MIT License.