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

  • TimeDate, 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pquantlib-1.42.1.tar.gz (5.3 MB view details)

Uploaded Source

Built Distribution

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

pquantlib-1.42.1-py3-none-any.whl (5.5 MB view details)

Uploaded Python 3

File details

Details for the file pquantlib-1.42.1.tar.gz.

File metadata

  • Download URL: pquantlib-1.42.1.tar.gz
  • Upload date:
  • Size: 5.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pquantlib-1.42.1.tar.gz
Algorithm Hash digest
SHA256 41567446244ef4464a0ee14fd22280012dce0aedeaa58473cb24b3ef819a2e73
MD5 d6721b816aa969f4ca264e1c080da54a
BLAKE2b-256 0fe06e34ada0c2c852a31b72bb624c6fef71de06eee0005643f99c954132cdd9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pquantlib-1.42.1.tar.gz:

Publisher: release.yml on jlmoya/pquantlib

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

File details

Details for the file pquantlib-1.42.1-py3-none-any.whl.

File metadata

  • Download URL: pquantlib-1.42.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pquantlib-1.42.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b11ee939456b66e697b6bc30f42056ea8cd914db80b75f4df5f1b1e72e10ce54
MD5 37db56108d9428fc2eff4b5bb6dcb19f
BLAKE2b-256 6e75866c6665f3cbbdf40b780e8d93a95a602791eda46ab7a4abd5c6c29d4fb5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pquantlib-1.42.1-py3-none-any.whl:

Publisher: release.yml on jlmoya/pquantlib

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

Release history Release notifications | RSS feed

This release

1.42.1 This release

2 files

Supported by

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