Skip to main content

Python bindings for QuantLib

Project description

PyQuantLib: Modern Python bindings for QuantLib

Documentation macOS Linux Windows codecov PyPI DOI License Python PRs Welcome

Beta Status: This project is under active development. API may change.

Overview

PyQuantLib provides Python bindings for QuantLib, the open-source library for quantitative finance. Built with pybind11, it offers a more Pythonic API than existing alternatives.

Features

  • Pythonic API: Pass Python objects directly to functions (implicit conversion)
  • Zero-copy NumPy: Buffer protocol for efficient, bidirectional data exchange
  • Type hints: IDE-friendly with complete .pyi stub files
  • Python subclassing: Extend QuantLib classes without C++ recompilation
  • Modern build: scikit-build-core, CMake presets, cross-platform CI/CD

Installation

Prerequisites

  • Python 3.10+
  • CMake 3.18+
  • C++17 compatible compiler
  • Boost headers
  • QuantLib 1.40+ built with std::shared_ptr support (see below)

QuantLib Build Requirement

Important: PyQuantLib requires QuantLib built from source with specific settings.

Required CMake flags:

cmake -DBUILD_SHARED_LIBS=OFF \
      -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
      -DQL_USE_STD_SHARED_PTR=ON \
      -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL \  # Windows only
      -DCMAKE_BUILD_TYPE=Release \
      ...
Flag Why Required
BUILD_SHARED_LIBS=OFF Static build prevents Settings singleton issues on Linux/macOS
CMAKE_POSITION_INDEPENDENT_CODE=ON Required for static libs in Python modules
QL_USE_STD_SHARED_PTR=ON pybind11 uses std::shared_ptr as default holder
CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL Windows only: Python extensions require dynamic runtime (/MD)

Note: Pre-built packages (Homebrew, vcpkg, apt) use shared builds and boost::shared_ptr — they are not compatible. You must build QuantLib from source. See CONTRIBUTING.md for detailed build instructions.

From Source

# After building QuantLib with required flags (see CONTRIBUTING.md)
pip install git+https://github.com/quantales/pyquantlib.git

Quick Start

import pyquantlib as ql

# Set evaluation date
today = ql.Date(15, 6, 2025)
ql.Settings.evaluationDate = today

# Market data
spot = ql.SimpleQuote(100.0)
rate = ql.SimpleQuote(0.05)
vol = ql.SimpleQuote(0.20)

# Term structures (pass quotes directly, handles created internally)
dc = ql.Actual365Fixed()
risk_free = ql.FlatForward(today, rate, dc)
dividend = ql.FlatForward(today, 0.0, dc)
volatility = ql.BlackConstantVol(today, ql.TARGET(), vol, dc)

# Black-Scholes process (pass objects directly)
process = ql.GeneralizedBlackScholesProcess(spot, dividend, risk_free, volatility)

# European call option
payoff = ql.PlainVanillaPayoff(ql.Call, 100.0)
exercise = ql.EuropeanExercise(today + ql.Period("1Y"))
option = ql.VanillaOption(payoff, exercise)

# Price with analytic Black-Scholes
option.setPricingEngine(ql.AnalyticEuropeanEngine(process))

print(f"NPV:   {option.NPV():.4f}")
print(f"Delta: {option.delta():.4f}")
print(f"Gamma: {option.gamma():.4f}")
print(f"Vega:  {option.vega():.4f}")
print(f"Theta: {option.theta():.4f}")

Output:

NPV:   10.4506
Delta: 0.6368
Gamma: 0.0188
Vega:  37.5240
Theta: -6.4140

Module Organization

import pyquantlib as ql          # Concrete classes
from pyquantlib.base import ...  # Abstract base classes (for subclassing)

Coverage includes dates and calendars, market quotes, yield and volatility term structures, stochastic processes, instruments, and pricing engines. See the API Reference for the complete list.

Development

See CONTRIBUTING.md for development setup and guidelines.

# Clone and install in development mode
git clone https://github.com/quantales/pyquantlib.git
cd pyquantlib
python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install -e .

# Run tests
pytest

Documentation

Full documentation is available at pyquantlib.readthedocs.io.

Examples

See the examples directory for Jupyter notebooks demonstrating PyQuantLib usage.

License

BSD 3-Clause License. See LICENSE for details.

Acknowledgments

Status

PyQuantLib is under active development. For broader QuantLib coverage today, use QuantLib-SWIG.

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

pyquantlib-0.2.0.tar.gz (970.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyquantlib-0.2.0-cp313-cp313-win_amd64.whl (4.1 MB view details)

Uploaded CPython 3.13Windows x86-64

pyquantlib-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pyquantlib-0.2.0-cp313-cp313-macosx_11_0_arm64.whl (4.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyquantlib-0.2.0-cp312-cp312-win_amd64.whl (4.1 MB view details)

Uploaded CPython 3.12Windows x86-64

pyquantlib-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pyquantlib-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (4.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyquantlib-0.2.0-cp311-cp311-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.11Windows x86-64

pyquantlib-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyquantlib-0.2.0-cp311-cp311-macosx_11_0_arm64.whl (4.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyquantlib-0.2.0-cp310-cp310-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.10Windows x86-64

pyquantlib-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pyquantlib-0.2.0-cp310-cp310-macosx_11_0_arm64.whl (4.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file pyquantlib-0.2.0.tar.gz.

File metadata

  • Download URL: pyquantlib-0.2.0.tar.gz
  • Upload date:
  • Size: 970.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyquantlib-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5a84a17694d26411e1948afc563ce42637de6737d76dda38436c1c221fa3fefb
MD5 687ba86cab8436ed332d4986d2115449
BLAKE2b-256 b48576397f6e5aec67769293e04442b9eb02c356b705e9dd9061b889b62dbb94

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.2.0.tar.gz:

Publisher: wheels.yml on quantales/pyquantlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyquantlib-0.2.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pyquantlib-0.2.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 4.1 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyquantlib-0.2.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2b857f48df929c56bde1502fadd4d3b09fed140c5a16e705abfa90cb7fcaf4fe
MD5 3f7a933f589352bc9270ddb28c30dcb0
BLAKE2b-256 96204cec8ed1ba335c4bbe1e9213cc7c6f9e5a5e94755e33e22cb97b910f7cc7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.2.0-cp313-cp313-win_amd64.whl:

Publisher: wheels.yml on quantales/pyquantlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyquantlib-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyquantlib-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e7ebcb6aaec127b1636023a062657670d11cfa60a232757b1b8b9d1bfc989c30
MD5 a68052bc15115c67716545a8f535cfe7
BLAKE2b-256 a078045444b0685bd0f85f5cd6ea08f1168dd18b9791335da4bc404c696a1c87

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on quantales/pyquantlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyquantlib-0.2.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyquantlib-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 146973d248a59cb0cc0886b9476faa8ccc6c4ce86ae86d1991b0b290319499a2
MD5 cae020b54ba2587986543c086e42e7c3
BLAKE2b-256 4f950bd6d6b08d83bc19dc01010bf59499f89650e5a9858f6e8a241d4e06dcc0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.2.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: wheels.yml on quantales/pyquantlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyquantlib-0.2.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pyquantlib-0.2.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 4.1 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyquantlib-0.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 258c330b9f352801b2b3b8647451a607db9f047c3e665ffeeb61356fa82f1442
MD5 df14864911e6ccf35ddfde15c5c0b26b
BLAKE2b-256 e8adca51d08b3b59e73931de2d284194ebcfa167e3112dca86bb7357b742952a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.2.0-cp312-cp312-win_amd64.whl:

Publisher: wheels.yml on quantales/pyquantlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyquantlib-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyquantlib-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ca9f84d7f9f0a8c834bae1a5a8e5a48c66cd5fd7c4f23a674e2c0772c3967ed2
MD5 6dbd15947dc67bf1d29724dbd9480d1d
BLAKE2b-256 4bc2e0dcea62bdf2beaac99b89243ce2c9ff82a4e3cbeba2dcba51f780b6b18a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on quantales/pyquantlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyquantlib-0.2.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyquantlib-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 db68c4fe0d4dcbc12da85b551ced2d69a00cf0e5126540f895f54c2ef86a62c4
MD5 e5d38206463fefac70c9a8baf89bc89a
BLAKE2b-256 d08955e2813235b1e1c7f3d8b90fd7fb74be79161704e91b8078435d2932f446

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.2.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: wheels.yml on quantales/pyquantlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyquantlib-0.2.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pyquantlib-0.2.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyquantlib-0.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a85c36c35b26147948bc52d57f61364f8051daa7be66c1b33e1be7f0e2a14e54
MD5 7b5ce88b33fc5cffa7d2e2ea19f88e6c
BLAKE2b-256 c15c104c91e1554627625956283eabe0daa809c811181cbe73fdf478b22e8d9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.2.0-cp311-cp311-win_amd64.whl:

Publisher: wheels.yml on quantales/pyquantlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyquantlib-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyquantlib-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 78a2679d09e522c98c7c720aa44f84026643cadc220f95774aa9c823a10d327c
MD5 b82099b68ab079a6c9243234121e32ec
BLAKE2b-256 c994d987bc0dbcb60e6d0ec798252cb0446a9bb9cb5f36326ceb22869eb36e6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on quantales/pyquantlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyquantlib-0.2.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyquantlib-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cdec2ca78a246063cf963c01e50ecc056be431e11e113fb9dbaea15703b13b1b
MD5 8c4d97e9ede676d0866eb7ed7d3b09da
BLAKE2b-256 266c2737e611354a3c9689a4c97248eecc149a49f077025390a569aa4e83b464

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.2.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: wheels.yml on quantales/pyquantlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyquantlib-0.2.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pyquantlib-0.2.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyquantlib-0.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e014ed6cf366f9742bea429b2035532bc95a3111d0fef2c77c3ddad53b5c8f6e
MD5 01759267b5a8e88ebf69e876c8e12ad7
BLAKE2b-256 d800bcd7756fb471a133f37f7c0b081aafbd7f909ed80f1fc312585d84f2d998

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.2.0-cp310-cp310-win_amd64.whl:

Publisher: wheels.yml on quantales/pyquantlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyquantlib-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyquantlib-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cdb7ce6ecb971e7b4d10e6163f361ca821a1557a6fb179a728123ddc44228675
MD5 b5df429a3afd2077d19d7bef3abd41de
BLAKE2b-256 3d6787025be7bcd05aec046a60b149339996463bcc0e460293782a2feb7356ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on quantales/pyquantlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyquantlib-0.2.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyquantlib-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ff33b00e1156a32f814c5cd16f9aef9b44d8c5bdbd65e5e8dbad8675f25faf74
MD5 131b8c95057863535ffa19097571fe9d
BLAKE2b-256 a0cd2d78ed1bc423331deff5c83c9764605984b8704aa77aed6fd99d8d8c00e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.2.0-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: wheels.yml on quantales/pyquantlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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