Skip to content

Python QuantLib Integration: QuantLib-Risks

The Python package QuantLib-Risks is now available on PyPI. This version integrates automatic differentiation capabilities into QuantLib through its dependency on XAD's Python bindings. This integration significantly boosts the efficiency of performing high-performance risk assessments within QuantLib from Python.

The key advantage brought by QuantLib-Risks is its ability to expediently ascertain how the pricing of derivatives is influenced by various input variables, notably market quotes.

The user interface mimics the official QuantLib Python package, with the addition of replacing it's Real type with xad.adj_1st.Real, which can be tracked on an adjoint automatic differentiation tape and derivatives can be calculated with xad.


pip install QuantLib-Risks

Usage Illustration

import QuantLib_Risks as ql
from xad.adj_1st import Tape

with Tape() as t:
    rate = ql.Real(0.2)

    # quantlib pricing code, setting up an option
    quote = ql.SimpleQuote(rate)
    npv = option.NPV()

    npv.derivative = 1.0

    print(f"price = {npv}")
    print(f"delta = {rate.derivative}")