Skip to main content

PQuantLib

A pure-Python port of the industry-standard QuantLib quantitative-finance library, tracking C++ QuantLib v1.42.1 (pinned commit 099987f0) as the ground truth. Every ported class is cross-validated against the C++ reference across 4000+ tests using tiered tolerances (exact / tight / loose).

The library is fully typed (py.typed) and delegates the heavy numerics to the scientific Python stack (numpy / scipy / mpmath) rather than re-implementing them.

Install

uv add pquantlib          # or: pip install pquantlib

Requires Python ≥ 3.14. Runtime dependencies (numpy, scipy, mpmath) are pulled in automatically.

Quick start — price a European option

from pquantlib.time.date import Date
from pquantlib.time.month import Month
from pquantlib.time.calendars.null_calendar import NullCalendar
from pquantlib.daycounters.actual_365_fixed import Actual365Fixed
from pquantlib.quotes.simple_quote import SimpleQuote
from pquantlib.termstructures.yield_.flat_forward import FlatForward
from pquantlib.termstructures.volatility.equity_fx.black_constant_vol import BlackConstantVol
from pquantlib.processes.generalized_black_scholes_process import GeneralizedBlackScholesProcess
from pquantlib.payoffs import OptionType, PlainVanillaPayoff
from pquantlib.exercise import EuropeanExercise
from pquantlib.instruments.european_option import EuropeanOption
from pquantlib.pricingengines.vanilla.analytic_european_engine import AnalyticEuropeanEngine

dc = Actual365Fixed()
ref = Date.from_ymd(15, Month.June, 2026)

process = GeneralizedBlackScholesProcess(
    x0=SimpleQuote(100.0),
    dividend_ts=FlatForward.from_rate(reference_date=ref, forward_rate=0.0, day_counter=dc),
    risk_free_ts=FlatForward.from_rate(reference_date=ref, forward_rate=0.05, day_counter=dc),
    black_vol_ts=BlackConstantVol(
        reference_date=ref, calendar=NullCalendar(), day_counter=dc, volatility=0.20
    ),
)

option = EuropeanOption(PlainVanillaPayoff(OptionType.Call, 100.0), EuropeanExercise(ref + 365))
option.set_pricing_engine(AnalyticEuropeanEngine(process))

print(f"NPV={option.npv():.4f}  delta={option.delta():.4f}  vega={option.vega():.4f}")

The public API is reached through submodule imports (e.g. from pquantlib.time.date import Date); the top-level package exposes only __version__.

What's covered

  • Time — Date, calendars, day-count conventions, schedules, Settings.evaluation_date
  • Term structures — flat & bootstrapped yield curves, Black/local volatility surfaces
  • Indexes & cashflows — Ibor/overnight indexes, fixed & floating legs, CMS/capped-floored/digital coupons
  • Instruments — bonds, vanilla & overnight swaps, vanilla/exotic options (barrier, double-barrier, Asian, basket, lookback, cliquet, digital), convertibles
  • Pricing engines — analytic, binomial tree, Monte Carlo (incl. Longstaff-Schwartz American), finite differences
  • Models — short-rate (Vasicek / Hull-White / CIR / G2++ / Black-Karasinski / Gaussian1d), Heston & Bates, SABR/ZABR, with Levenberg-Marquardt / Simplex calibration
  • Market models — the full LMM/BGM stack (models, evolvers, products, callability, pathwise greeks)
  • plus inflation, credit (CDS / default curves), and the experimental/* surface

See the project repository for the full migration history, design docs, and carve-out documentation.

Interactive showcase

A companion Streamlit app, pquantlib-showcase, drives this library live — yield curves, bonds, swaps, vanilla options across all four pricing engines, Greeks, exotics, and the Heston volatility smile + calibration, each recomputed as you move a slider. From a clone of the repository:

uv run streamlit run pquantlib-showcase/app.py

It is a separate workspace member, so it is not bundled with the pquantlib wheel.

License

BSD-3-Clause — same spirit as upstream QuantLib.

Metadata

Release files for pquantlib 1.42.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pquantlib 1.42.1
File Size Uploaded
pquantlib-1.42.1.tar.gz 5.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for pquantlib 1.42.1
File Interpreter ABI Platform
pquantlib-1.42.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.9 MB

Release files / pquantlib-1.42.1.tar.gz

Download URL pquantlib-1.42.1.tar.gz
Size 5.3 MB
Tags Source
SHA-256 checksum
How to use checksums
41567446244ef4464a0ee14fd22280012dce0aedeaa58473cb24b3ef819a2e73
BLAKE2b-256 checksum
How to use checksums
0fe06e34ada0c2c852a31b72bb624c6fef71de06eee0005643f99c954132cdd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 28, 2026.

Transparency log

Release files / pquantlib-1.42.1-py3-none-any.whl

Download URL pquantlib-1.42.1-py3-none-any.whl
Size 5.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
b11ee939456b66e697b6bc30f42056ea8cd914db80b75f4df5f1b1e72e10ce54
BLAKE2b-256 checksum
How to use checksums
6e75866c6665f3cbbdf40b780e8d93a95a602791eda46ab7a4abd5c6c29d4fb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 28, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.42.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page