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

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

pip install pyquantlib

Pre-built wheels are available for Python 3.10--3.13 on Linux (x86_64), macOS (ARM), and Windows (x64). QuantLib is statically linked -- no separate installation required.

From Source

Building from source requires QuantLib built with specific CMake flags. See CONTRIBUTING.md for detailed instructions.

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.

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. For the latest additions, see the changelog.

Examples

See the examples directory for Jupyter notebooks demonstrating PyQuantLib usage.

License

BSD 3-Clause License. See LICENSE for details.

Acknowledgments

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.5.1.tar.gz (1.1 MB view details)

Uploaded Source

Built Distributions

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

pyquantlib-0.5.1-cp313-cp313-win_amd64.whl (5.7 MB view details)

Uploaded CPython 3.13Windows x86-64

pyquantlib-0.5.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pyquantlib-0.5.1-cp313-cp313-macosx_11_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyquantlib-0.5.1-cp312-cp312-win_amd64.whl (5.7 MB view details)

Uploaded CPython 3.12Windows x86-64

pyquantlib-0.5.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pyquantlib-0.5.1-cp312-cp312-macosx_11_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyquantlib-0.5.1-cp311-cp311-win_amd64.whl (5.7 MB view details)

Uploaded CPython 3.11Windows x86-64

pyquantlib-0.5.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyquantlib-0.5.1-cp311-cp311-macosx_11_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyquantlib-0.5.1-cp310-cp310-win_amd64.whl (5.7 MB view details)

Uploaded CPython 3.10Windows x86-64

pyquantlib-0.5.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pyquantlib-0.5.1-cp310-cp310-macosx_11_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for pyquantlib-0.5.1.tar.gz
Algorithm Hash digest
SHA256 40ff45f62747e3ddc682208400770589b5ab526b1cfd94901c4c144aeadff6b2
MD5 27e9b376c32d148d4dc1c055d3ba32da
BLAKE2b-256 6aae9028b65c2e794cf1b38c4c5c730f3734d229f4be6c8880f9b0a1aa1b0b2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.5.1.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.5.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pyquantlib-0.5.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 5.7 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.5.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e9f7cab97c136380bda2bfafde41c4de18d1e0ef8604814a95b9757f97117245
MD5 4bda231e227ae6066768df10c7cf27f2
BLAKE2b-256 9e1e850e22c868cfdf491dc2229a7a3f3447f8ff4efefb59bbf95c7a04c7a14d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.5.1-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.5.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyquantlib-0.5.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f725cc0043d577879eda8b9e17e31bdb23571527d8c9dc3d3977102cd868f616
MD5 892c7011a6b877c1814f1890a8965fb5
BLAKE2b-256 fb753259cc22341ea91afd9053343574119b814f8e9e0b7d83e4d1cf4dd661a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.5.1-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.5.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyquantlib-0.5.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ff6dc6708b11352affd4e9722471a66b55b248e1e1c405d412b45e647b78c33
MD5 5979b423a393e43b153ac99082c1d887
BLAKE2b-256 0b6bea77c16d65046169c361aa99254a6533c8f7d4bf01652de97133fa9739de

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.5.1-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.5.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pyquantlib-0.5.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 5.7 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.5.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ddc0ab466da238f85daead1f55c13dbcd6101feb3f248e69df2b9fd9545cba7a
MD5 2384d7edfb0bd0afd0c38a6ebb1fe6ae
BLAKE2b-256 b67fe2dcfc999481629c97a63a889fe34c28badee970a6ac8b9445f56da6e877

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.5.1-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.5.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyquantlib-0.5.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 223b88ec1dda0b6452c90120a2736c8bd025b4abf384bed6195f6afa73a8da7f
MD5 c04aebf16db60a0f51d467cb8604623e
BLAKE2b-256 850aba87cdc0d7d5f24109e9cbc0338cbed56cd0649ad093f50badafd8eebd2c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.5.1-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.5.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyquantlib-0.5.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 39915efd11107912cbdb1f7fc8f40308b770a93c9a568e3b8c9cfb8c3a23fbdc
MD5 510dbdb0bc4d3f636fe763f0da30c93b
BLAKE2b-256 8a6f145a467a51e2ec34a71fa35e77e59955f33cff7ce587236caf6d7c6616f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.5.1-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.5.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pyquantlib-0.5.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 5.7 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.5.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e32918810eacae874adfd4153d5e4d52881dda4d015ac4a89a0eb096e5930b91
MD5 1d617a368ac1d0358e7a38945b3611fc
BLAKE2b-256 6ee79b8570b866d1df265bee34e49515c68a8a60a99339d2351401a8099fa6f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.5.1-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.5.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyquantlib-0.5.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ffbe23311ab21f02671691151217d30d08807582bbfa6be59b26c3fca79b0745
MD5 db6c40742a4a8b32e7effbbdb406171b
BLAKE2b-256 35b856d9b51b4702f955ccdda64e6699f5e891f6a884f806f7a23b99843dad65

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.5.1-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.5.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyquantlib-0.5.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 30f87569819a9f11487306859af14ebe84451b9de3cd5d46dff2b9506be07872
MD5 bc01d0db9ec5761a92568e51a1dccb12
BLAKE2b-256 7a8648ad9e8fc0e7468aba45df47a00d000547a7fb4648609c8befb0bd62b6b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.5.1-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.5.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pyquantlib-0.5.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 5.7 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.5.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9e7277233b52cb0a26e6ae6eabe9d13a9c021371e69ee612deb4de65508676ef
MD5 7833662f607def7c15e4a1effabdd3a4
BLAKE2b-256 35db152eff3e2b6af91cdf44e25a03d344f14a666c0ffc65ed21487c80f569a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.5.1-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.5.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyquantlib-0.5.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b20bde18f4293b102213ef73b04e346aa442a868be077d789ab9a82af5bae0f3
MD5 a60865aa38addcf4ae1231ed67cadca9
BLAKE2b-256 17940b71783d296b7abf66abc23a14fbe36926e4529313a3eea375d6c5c9a933

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.5.1-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.5.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyquantlib-0.5.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0f878d6258ab83007e31c7ac8a60a9cb6e59bbadfc66313cefb78012754f39b9
MD5 b213058b8facab9ae957658fbd6da0f2
BLAKE2b-256 d9d997056149b93eedb1b58dec7cc8f0859add17f5130cbc32b5dddf51dbf04f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyquantlib-0.5.1-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