No project description provided
Project description
py_vollib is a python library for calculating option prices, implied volatility and greeks. At its core is Peter Jäckel’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, py_vollib provides functions to calculate option prices, implied volatility and greeks using Black, Black-Scholes, and Black-Scholes-Merton. py_vollib implements both analytical and numerical greeks for each of the three pricing formulae.
Comparison with vollib
Feature |
py_vollib |
vollib |
---|---|---|
Python Version Compatibility |
2.7 and 3.x |
2.7 only |
Source Language |
Python |
C with Python SWIG Wrapper |
Optional Dependencies |
Numba |
None |
Core Dependency (automatically installed by pip) |
py_lets_be_rational |
lets_be_rational |
Execution Speed
Except for the source languages of py_lets_be_rational and lets_be_rational, py_vollib and vollib are almost identical. Each is orders of magnitude faster than traditional implied volatility calculation libraries, thanks to the algorithms developed by Peter Jäckel. However, py_vollib, without Numba installed, is about an order of magnitude slower than vollib. Numba helps to mitigate this speed gap considerably.
Numba Dependency
Numba is an optional dependency of py_vollib . Because Numba installation can be tricky and OS-dependent, we decided to leave it up to each user to decide how and whether to install Numba. If Numba is present, execution speed will be faster. If not, the code will still run – just slower.
Installing Numba
py_lets_be_rational optionally depends on numba which in turn depends on llvm-lite. llvm-lite wants LLVM 3.9 being installed. On Mac OSX, use the latest version of HomeBrew to install numba’s dependencies as shown below:
brew install llvm@3.9 LLVM_CONFIG=/usr/local/opt/llvm@3.9/bin/llvm-config pip install llvmlite==0.16.0 pip install numba==0.31.0
For other operating systems, please refer to the llvm-lite and numba documentation.
About the reference Python implementation
py_vollib contains py_vollib.ref_python, a pure python version of the functions in py_vollib.*, except without any dependency on lets_be_rational or py_lets_be_rational. It is provided purely as a reference implementation for sanity checking. It is not recommended for serious use.
Dependencies
py_vollib is Python 2.7/Python 3.6 compatible. Its core dependency is py_lets_be_rational package, pure python implementation of Peter Jäckel’s original C source code.
To install via pip, type the following:
pip install py_vollib
Installing py_vollib via pip will automatically install the necessary dependencies, except for pip, and Python.
Python, and pip must be installed prior to installing py_vollib.
About “Let’s be Rational”
“Let’s Be Rational” is a paper by Peter Jäckel showing “how Black’s volatility can be implied from option prices with as little as two iterations to maximum attainable precision on standard (64 bit floating point) hardware for all possible inputs.”
The paper is accompanied by the full C source code, which resides at www.jaeckel.org/LetsBeRational.7z.
Copyright © 2013-2014 Peter Jäckel. Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved. WARRANTY DISCLAIMER The Software is provided "as is" without warranty of any kind, either express or implied, including without limitation any implied warranties of condition, uninterrupted use, merchantability, fitness for a particular purpose, or non-infringement.
Links
Development
Fork the GitHub repository. This will make it available under your username e.g. https://github.com/YOUR-USERNAME/py_vollib. Clone that repo on your computer, change the code as you wish. Commit and push it, and create a pull request. That’s all.
Generate documentation
cd docs sphinx-apidoc -f -o apidoc ../py_vollib make html
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file py_vollib_gen-1.0.1.tar.gz
.
File metadata
- Download URL: py_vollib_gen-1.0.1.tar.gz
- Upload date:
- Size: 27.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84bdcef087d4e1b279af6ba4f97a20292197668141c67c8e642262b5c654b736 |
|
MD5 | f89b7dee411026ac9ac28b9b3165aa67 |
|
BLAKE2b-256 | 1b249357100ffeb6ad807a70f52f45d681a35dfcc2a08a74da274b3172dde68c |
File details
Details for the file py_vollib_gen-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: py_vollib_gen-1.0.1-py3-none-any.whl
- Upload date:
- Size: 64.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 083e4cd5ad50afea1a39d37f6da07ae95655dffa4bdcacd2a9507c1d5ab765dc |
|
MD5 | db93c416f13f27387bfef5b22c9a5525 |
|
BLAKE2b-256 | a3a2cd57d6de61d8cb6bb8ed9d28a17de2ebddea8fd405dc38fc3ac8d842197c |