QuantLib-Python

1.41 · active · verified Sun Apr 12

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.

Warnings

Install

Imports

Quickstart

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)}")

view raw JSON →