QuantLib Python Bindings

Official stock QuantLib Python bindings made by the project are available on PyPi: https://pypi.org/project/QuantLib/. You can install them simply with:

pip install QuantLib

or with poetry, pipenv or other Python packing tools. The source code is in https://github.com/lballabio/QuantLib-SWIG.

We offer services to extend the Python bindings, optimisation and deployment to various systems including cloud-based environments.

Architecture

The architecture of QuantLib-SWIG Python bindings is shown below. The binding are based on the SWIG system we have experience with since 2002:

quantlib_py Architecture of the QuantLib Python wrapper cluster_QLBase QuantLib C++ Library cluster_QLApp Your application built on QuantLib-Python cluster_QLSWig QuantLib-SWIG wrapper QLSource QuantLib C++ Source Code QLLib QuantLib Dynamic Lib (.so, .dll) QLSource->QLLib C++ Compiler (gcc, MS Visual Studio) QLSWIGLib QuantLib-Swig Dynamic Lib (.so, .dll) QLLib->QLSWIGLib QLSwig SWIG Interface Definitions (*.i files) QLPyWrapC C CPython wrapper code (generated C files) QLSwig->QLPyWrapC SWIG QLPyClass Swig Python Wrapper Classes (generated .py files) QLSwig->QLPyClass SWIG QLPyWrapC->QLSWIGLib C++ Compiler (gcc, MS Visual Studio) QLPyWheel QuantLib Wheel QLPyClass->QLPyWheel setuptools / pip QLSWIGLib->QLPyWheel QLAppWheel Application wheel (.wheel file) QLPyWheel->QLAppWheel QLAppSource Application source (.py files) QLAppSource->QLAppWheel pip

Try online

You can try the official Python examples using Jupyter Notebooks on mybinder. Direct links:

  1. American Option with multiple valuation engines
  2. Basket options
  3. Bermudan Swaptions calibrated to market data with multiple models
  4. Floating and fixed rate bonds
  5. Callable Fixed Rate Bond
  6. Caps with Black valuation
  7. Cashflow analysis of an Overnight Index Swap
  8. Credit Default Swap
  9. European Option under Black Scholes and Heston Models
  10. Swaption priced with 1d Gaussian Models
  11. Global zero curve fitting
  12. CDS valued with an ISDA-like engine

Contact

Copyright and published by: BN Algorihtms Ltd 2025. For general information only. Not to be relied for any purpose. Not advice about investment. No warranty of any kind. No liability for any use of this information accepted. Contact: webs@bnikolic.co.uk