We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil1
A multithreaded Python package for computing option implied volatilities.
Migration in progress.
Includes a demo script2 that performs a comparison of execution speed for the iterative computation of Black and Bachelier implied volatility using Halley's and Newton's methods. The script compares the time taken to solve the Black and Bachelier implied volatilities of ~1 million European option prices for a pure Python implementation using scipy.optimize.newton, a mixed implementation where a minimalistic C implementation of Halley's/Newton's method is used to solve for the price but iteration through prices is still done in Python, and a ctypes
wrapped pure C implementation. The script illustrates the difference in speed between converting data types and looping directly in C versus iterating through the prices in Python and using ctypes
to call the C function for each price3.
There is a small test suite that can be run with pytest after installation.
Note:
The following sections are out of date and foremly from the c_npy_demo
README.rst
. They will change in the future.
Building from this (unstable) repo will probably only work on Linux systems. Local extension builds are done on WSL Ubuntu 18.04 with gcc 9.3 while builds on Travis CI virtual machines are done on Ubuntu 18.04 with gcc 7.4. There is also an implicit dependency on the gcc version being high enough such that an OpenMP implementation is included4. For example, I have libgomp.so.1.0.0
in /usr/lib/x86_64-linux-gnu/
, with appropriate symbolic links.
Although this package is not on PyPI (yet), I have successfully built manylinux1
wheels using Travis CI on the manylinux1
Docker images provided by PyPA, of which more information can be found at the manylinux GitHub.
TBA. Currently looks like some pure Python code, pytest
test suite, demo module to run benchmarks, separate C shared library for implied volatility calculations, and a Python extension module written in C.
In progress, and will be eventually be hosted on Read the Docs. For now, the doc
directory probably only has conf.py
and index.rst
.