Registry / data / QuantLib-Python

QuantLib-Python

JSON →
library1.18pypypi✓ verified 21d ago

QuantLib-Python provides official Python bindings for the open-source Quantitative Finance Library (QuantLib C++). It offers a comprehensive suite of models and tools for pricing, risk management, and analysis of financial instruments. As of version 1.41, the library is actively maintained with regular updates, making advanced financial analytics accessible in Python.

pip install QuantLib-Python
INSTALL
IMPORT
SIG · QUANTLIB-PYTHON
Q
QuantLib-Python
datapythonv1.18
Install
2.5s avg
Import
1104ms
Disk
102MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.18 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 1.158s · 108.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.5s · import 1.050s · 99MB
102MB installed
● package 102MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

QuantLib
import QuantLib as ql
It is common practice to import QuantLib with the alias 'ql' for brevity.

This quickstart demonstrates how to import QuantLib, set a global evaluation date, create QuantLib Date objects, and use a calendar function. Setting the evaluation date is a fundamental first step for most QuantLib applications.

import QuantLib as ql # Set a global evaluation date (crucial for many QuantLib calculations) todaysDate = ql.Date(15, ql.May, 2023) ql.Settings.instance().evaluationDate = todaysDate # Create another QuantLib Date object another_date = ql.Date(15, ql.May, 2024) # Print dates and check a simple calendar function (e.g., TARGET) print(f"Evaluation date: {todaysDate}") print(f"Another date: {another_date}") print(f"Is evaluation date a business day (TARGET calendar)? {ql.TARGET().isBusinessDay(todaysDate)}")
Debug
Known issues
gotchaQuantLib uses its own robust date, calendar, and day counter system (e.g., `ql.Date`, `ql.Calendar`). Mixing directly with Python's `datetime` objects without proper conversion or misunderstanding QuantLib's specific business day conventions can lead to incorrect or unexpected results.
fix
Always use `QuantLib.Date` and `QuantLib.Calendar` for internal calculations, converting to/from `datetime` explicitly only when interacting with external Python libraries or data sources. Consult QuantLib documentation for specific date arithmetic and calendar rules.
affects: All versions
gotchaQuantLib heavily relies on an 'observable' pattern for dependency management (e.g., an instrument observing a yield curve). If underlying data or objects change, dependent objects might not automatically update their calculated values unless explicitly refreshed or properly observing these changes.
fix
Ensure proper observer registration for dependent objects. In scenarios where values seem stale, explicit calls to `update()` on observable objects might be necessary to trigger recalculations or verify that the observation chain is correctly configured.
affects: All versions
gotchaWhile robust, the Python bindings introduce a performance overhead compared to direct C++ QuantLib usage. For very high-frequency calculations, large-scale Monte Carlo simulations, or iterative optimizations, this overhead can become significant.
fix
Profile critical sections of your code to identify performance bottlenecks. For highly performance-sensitive tasks, consider offloading computations to a C++ extension or pre-calculating results where feasible, or explore alternative pure-Python libraries for less complex tasks.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'QuantLib'
The QuantLib-Python package is not installed or the Python environment cannot locate it.
fix
Ensure that QuantLib-Python is installed in your environment by running 'pip install QuantLib'.
ModuleNotFoundError: No module named '_QuantLib'
The '_QuantLib' module, a core component of QuantLib-Python, is missing or not properly installed.
fix
Verify that QuantLib-Python is correctly installed and that your Python environment is set up to locate the '_QuantLib' module.
ImportError: DLL load failed: The specified module could not be found.
A required DLL for QuantLib-Python is missing or not accessible.
fix
Ensure that all necessary dependencies, such as the Microsoft Visual C++ Redistributable, are installed and that the system's PATH includes the directory containing the required DLLs.
ImportError: DLL load failed while importing gurobipy: The specified module could not be found.
The 'gurobipy' module is missing a required DLL or the DLL is not in the system's PATH.
fix
Add the directory containing the 'gurobi90.dll' to the system's PATH or copy the DLL to the 'gurobipy' package directory.
ImportError: DLL load failed while importing shell: The specified module could not be found.
The 'shell' module is missing a required DLL or the DLL is not in the system's PATH.
fix
Ensure that all necessary dependencies are installed and that the system's PATH includes the directory containing the required DLLs.
Upgrade
Version history
1.18latest on PyPI · released Mar 23, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
80 hits · last 30 days
node
66
OpenAI (training)
1
Resources
QuantLib-Python — pip install QuantLib-Python · libregistry