Skip to main content

Python bindings for QuantLib

Project description

PyQuantLib: Modern Python bindings for QuantLib

Documentation macOS Linux Windows codecov PyPI 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.9+
  • 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.1.0.tar.gz (836.1 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.1.0-cp313-cp313-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.13Windows x86-64

pyquantlib-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pyquantlib-0.1.0-cp313-cp313-macosx_11_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyquantlib-0.1.0-cp312-cp312-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.12Windows x86-64

pyquantlib-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pyquantlib-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyquantlib-0.1.0-cp311-cp311-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.11Windows x86-64

pyquantlib-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyquantlib-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyquantlib-0.1.0-cp310-cp310-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.10Windows x86-64

pyquantlib-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pyquantlib-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for pyquantlib-0.1.0.tar.gz
Algorithm Hash digest
SHA256 47b0823316fe20d9d23385c1bf30967e081d28654dc5afb7c981d09466d11545
MD5 0c3b571ac234ca4f9cd89a8b09743154
BLAKE2b-256 4016958067e8a05a1ac9200c4d39cf5a1d0ff3689f6cbe2d1b086fe1ae1b462f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyquantlib-0.1.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.8 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.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 4baa38786a27f7dd0c13b7dcd9b251f1312dfd0c11585681733f781ea76e6801
MD5 88d7467c9fd47ee76fe60a8a8180f1d1
BLAKE2b-256 5abc552fdd93f317bf53e44b376a8839df560b6faf4cc776cac4824b5259dc11

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyquantlib-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7cbb159c60b22d68b36c2b55fcc76bb3c0541c4ccb497f65d1cd2469167467da
MD5 0aa6431c91f5b30d6f56d431c404d366
BLAKE2b-256 0330ef17ff2a8c6ad6463a9fce042661f881d5ea9ebc7e667276d7630854ddf1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyquantlib-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9eed39ca5f6acf7815837e06c8b50e4430494468609b83b0ceb8a06e0680be60
MD5 a16ff7764202cdb2e80c6fd63091ffaf
BLAKE2b-256 be33d16247925b11136768f611adced6d4a2dec2b34fde9b60926829d7923f9d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyquantlib-0.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.8 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.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3074fd5a800649e5fd1174cf4907bfec40f4d13ce9a7de94e35c316754da92c2
MD5 b23eec897ad7ee1d242cad5fa1b9a745
BLAKE2b-256 a8bf705ef9abbbb46f21c77b888a5d9a247879f8e08c74e6e7137dd56ccc1c49

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyquantlib-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 36e3e57c5fe944256dcd7cac3f34e0916a8aef6608e47d2f86fc0e4508cc613a
MD5 a3b684d77867ee5d7791378307f4b325
BLAKE2b-256 d500dc536db1aea25939d3f8a83b54082b983e4f7d0e2490951922af950f95c8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyquantlib-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e1eb4987a099ece816d22422d5939652ed58d28597e2ce9821e935382888c0c1
MD5 04992a4d9bd9353c28083f59e74c7759
BLAKE2b-256 350c5dedd60e834140284c1b0ebdb6ab65cb377eb209c86a180b1567b833c0ef

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyquantlib-0.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.8 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.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0c82323e1fd8e16c9baf34aa4cc97d8514b5d745c93e99a6f0ce5345bdadba11
MD5 5adea8acb9c3bc642b94fa0b96b08101
BLAKE2b-256 986b9182bf4d1cc6dda72e2873f8d886f7755e5ac2ee6f7f1506e97d2b22bdfd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyquantlib-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8d1418afa59dfb572dd1a8b61c1d7898cee9e97e0f6b397106ac3652ea4c775b
MD5 9a2ea702ef061267045ca5a637233f4d
BLAKE2b-256 9bf8e1f1c24bf14693bbe89fcb2b74d5eec3e73c659c3cacba28a2e65c8e45b0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyquantlib-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 56e811f47bbbc54dcf27e7a347935768c3f8f0300900341342d34b0c167edbc9
MD5 603c388b4e47fcd50b924be7dd48a161
BLAKE2b-256 0986bc1093ab041f12128d98cbc0836d5411018743a077df9669759045e96b2f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyquantlib-0.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.8 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.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6b43ba9cc06f6ea20b9885ce55a7ca713dd157ffbc190d7fad0605a0c443d437
MD5 198c0fa6c0372f63220efa9567902eb1
BLAKE2b-256 11fc3ff770baba0f7f36b0e27808ef4e88b9887a3ffd5e02d3f6e12ea22a8c6b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyquantlib-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dc64fee900694fff9a5d11ab0ff12f8cc778a928cf41add5524ab502d4ba725f
MD5 f46c55082ed8572ce15952f40fa174d6
BLAKE2b-256 bb4626102064308029a8ac144a05676637624b0d4173375be050e5ebc0332650

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyquantlib-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c4eaea55793e585e3ddcb79c30ca9b3713deb33fffc0a55ef5f34eff3617675e
MD5 707f349084776648bb4a1c4f9dbc1d4f
BLAKE2b-256 229344ec40f2e50d435953466b13fbd96902750a5b59a6db4094c0199753de31

See more details on using hashes here.

Provenance

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