Skip to main content

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.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_vollib_gen-1.0.0.tar.gz (27.1 kB view details)

Uploaded Source

Built Distribution

py_vollib_gen-1.0.0-py3-none-any.whl (64.7 kB view details)

Uploaded Python 3

File details

Details for the file py_vollib_gen-1.0.0.tar.gz.

File metadata

  • Download URL: py_vollib_gen-1.0.0.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

Hashes for py_vollib_gen-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f0d2a1cacb512bc36fedf15d9eff798b2ba970272f95886945934ba8578f2fce
MD5 9ae6eb07e536a502f0497add250bbb63
BLAKE2b-256 466a714c0e56d6acd2d2d82be50670b29a793d34dead74d3a5ee60abca492f0a

See more details on using hashes here.

File details

Details for the file py_vollib_gen-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for py_vollib_gen-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e83e5f8e844a4192b3ae6bc5fb01a87b0d234d691edefb9f7acd68971c6f4bde
MD5 9d8bf2379f0650f2bae7d345abd7f196
BLAKE2b-256 d0db9e1b4ecc0c1b7841950b6f601f425c2ea5727fb8cd3f6bd546246a91f2a8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page