Skip to main content

QuantLibAddIn Python Wrapper Overview


The QuantLibAddIn Python Wrapper provides a Python interface to QuantLibAddIn, exposing the functionality of the QuantLib C++ analytics library through an object-oriented API that close mirrors the architecture used by Excel-based QuantLibXL.


Examples

Vanilla Option


from pprint import pprint
import quantlib_addin as qla
from datetime import datetime,timedelta

def main():
    try:
        qla.initializeAddin()

        print("Begin example program.")
        print("QuantLibAddin version =", qla.qlAddinVersion(False))
        print("ObjectHandler version =", qla.ohVersion(False))

        evaluation_date = 46218

        evaluation_date_str = datetime(year=1899, month=12, day=30) + timedelta(days=evaluation_date)
        print(f"Evaluation Date = {evaluation_date_str}")

        qla.qlSettingsSetEvaluationDate(evaluation_date, False)

        exercise = qla.qlEuropeanExercise(ObjectId="exercise",
                                          ExpiryDate=evaluation_date + 10,
                                          Permanent=False, Trigger=False, Overwrite=False)

        striked_pay_off = qla.qlStrikedTypePayoff(ObjectId="qlStrikedTypePayoff",
                                                  PayoffID="Vanilla",
                                                  OptionType="Call",
                                                  Strike=45.75,
                                                  ThirdParameter=0,
                                                  Permanent=False, Trigger=False, Overwrite=False)

        vol_id = qla.qlBlackConstantVol(ObjectId="qlBlackConstantVol",
                                        SettlementDate=evaluation_date+1,
                                        Calendar="TARGET",
                                        Volatility=0.02,
                                        DayCounter="Act/Act",
                                        Permanent=False, Trigger=False, Overwrite=False)

        ql_generalized_black_scholes_process = qla.qlGeneralizedBlackScholesProcess(ObjectId="qlGeneralizedBlackScholesProcess",
                                                                                    BlackVolID=vol_id, Underlying=50,
                                                                                    DayCounter="Act/Act",
                                                                                    SettlementDate=evaluation_date+1,
                                                                                    RiskFreeRate=0.05,
                                                                                    DividendYield=0.1,
                                                                                    Permanent=False, Trigger=False, Overwrite=False)

        pricing_engine = qla.qlPricingEngine(ObjectId="PricingEngine",
                                             EngineID="AE",
                                             ProcessID=ql_generalized_black_scholes_process,
                                             Permanent=False, Trigger=False, Overwrite=False)

        option = qla.qlVanillaOption(ObjectId="VanillaOptions",
                                     Payoff=striked_pay_off,
                                     Exercise=exercise,
                                     Permanent=False, Trigger=False, Overwrite=False)

        qla.qlInstrumentSetPricingEngine(ObjectId=option,
                                         PricingEngine=pricing_engine,
                                         Trigger=False)

        option_npv = qla.qlInstrumentNPV(option, False)
        print(f"Option NPV: {option_npv}")

        option_results = qla.qlAddinCalculate(option)
        pprint(option_results)

        option_implied_vol = qla.qlAddinCalculate(option, {'price':5.25, 'process':ql_generalized_black_scholes_process})
        print(f"Implied Vol: (5.25) = {option_implied_vol['results']['impliedVolatility']}")


        option_implied_vol = qla.qlAddinCalculate(option,
                                                {'price':5.25,
                                                 'process':ql_generalized_black_scholes_process,
                                                 'dividends':{evaluation_date+5:0.6, evaluation_date+15:0.7}})
        print(f"Implied Vol: (5.25) + Div (0.06) = {option_implied_vol['results']['impliedVolatility']}")


    except Exception as e:
        print("Error:", e)
        return 1

    return 0

if __name__ == "__main__":
    raise SystemExit(main())

OIS Mid-Curves

import quantlib_addin as qla
from datetime import datetime, timedelta


def main():
    try:
        # Initialize the environment
        qla.initializeAddin()

        print("Begin example program.")
        print("QuantLibAddin version =", qla.qlAddinVersion(False))
        print("ObjectHandler version =", qla.ohVersion(False))

        evaluation_date = 46218
        evaluation_date_str = datetime(year=1899, month=12, day=30) + timedelta(days=evaluation_date)
        print(f"Evaluation Date = {evaluation_date_str}")

        qla.qlSettingsSetEvaluationDate( evaluation_date, False,)

        fixing_days = 2
        rate_factor = 100

        sofr_index = qla.qlOvernightIndex(ObjectId="ois_index",
                                          FamilyName="SOFR",
                                          FixingDays=fixing_days,
                                          Currency="USD",
                                          Calendar="TARGET",
                                          DayCounter="Act/Act",
                                          YieldCurve = "",
                                          Permanent=False,
                                          Trigger=False,
                                          Overwrite=False)

        ois_curve_rates = {
            '5D': 5.0,
            '1W': 5.0,
            '2W': 5.0,
            '1M': 5.0,
            '3M': 5.0,
            '6M': 5.0,
            '9M': 5.0,
            '1Y': 5.0,
            '18M': 5.0,
            '2Y': 5.0,
            '3Y': 5.0,
            '5Y': 5.0,
            '10Y': 5.0,
            '20Y': 5.0,
            '30Y': 5.0
        }

        rate_helpers = []

        for swap_tenor, rate in ois_curve_rates.items():

            ois_rate_helper = qla.qlOISRateHelper(
                ObjectId=swap_tenor,
                SettlDays=2,
                Tenor=swap_tenor,
                FixedRate=rate/rate_factor,
                ONIndex=sofr_index,
                DiscountingCurve="",
                TelescopicValueDates=False,
                PaymentLag=0,
                Permanent=False,
                Trigger=False,
                Overwrite=False,
            )

            rate_helpers.append(ois_rate_helper)

        piecewise_ois_curve = qla.qlPiecewiseYieldCurve(
            ObjectId="piecewise_yieldcurve",
            NDays=fixing_days,
            Calendar="TARGET",
            RateHelpers=rate_helpers,
            DayCounter="Actual/360",
            Jumps=[],
            JumpDates=[],
            TraitsID="Discount",
            InterpolatorID="LogLinear",
            Permanent=False,
            Trigger=False,
            Overwrite=False,
        )

        qla.qlYieldTermStructureEnableExtrapolation(ObjectId=piecewise_ois_curve,
                                                    ExtrapolationFlag=True,
                                                    Trigger=True)

        engine = qla.qlDiscountingSwapEngine(
            "piecewise_ois_curve",
            YieldCurve=piecewise_ois_curve,
            IncludeSettlDate = False,
            SettlementDate=None,
            NpvDate=None,
            Permanent=False,
            Trigger=False,
            Overwrite=False,
        )

        sofr_index_with_curve = qla.qlOvernightIndex(ObjectId="ois_index_with_curve",
                                                     FamilyName="SOFR",
                                                     FixingDays=fixing_days,
                                                     Currency="USD",
                                                     Calendar="TARGET",
                                                     DayCounter="Act/Act",
                                                     YieldCurve=piecewise_ois_curve,
                                                     Permanent=False, Trigger=False, Overwrite=False)

        forward_start = [
            '0D', '1M', '3M', '6M', '1Y', '3Y', '5Y',
            '7Y', '10Y', '15Y', '20Y', '25Y', '30Y'
        ]

        swap_tenor = ['1Y', '3Y', '5Y', '7Y', '10Y', '15Y', '20Y', '25Y', '30Y']

        # Store results: rates[start][tenor]
        rates = {}

        for start in forward_start:
            rates[start] = {}

            for tenor in swap_tenor:
                ticker = start + "x" + tenor

                ois_swap = qla.qlMakeOIS(
                    ObjectId=ticker,
                    SettlDays=2,
                    SwapTenor=tenor,
                    OvernightIndex=sofr_index_with_curve,
                    FixedRate=0.000001,
                    ForwardStart=start,
                    FixDayCounter="Act/Act",
                    Spread=0.0,
                    PaymentLag=0,
                    Permanent=False,
                    Trigger=False,
                    Overwrite=False
                )

                qla.qlInstrumentSetPricingEngine(ois_swap, engine, False)

                results = qla.qlAddinCalculate(ois_swap)
                rates[start][tenor] = results['results']['fairRate']

        # Print table
        column_width = 10

        header = f"{'Forward':>{column_width}}"
        for tenor in swap_tenor:
            header += f"{tenor:>{column_width}}"

        print(header)
        print("-" * len(header))

        for start in forward_start:
            row = f"{start:>{column_width}}"
            for tenor in swap_tenor:
                # Display as percentage
                rate = rates[start][tenor] * 100
                row += f"{rate:>{column_width}.4f}"
            print(row)

    except Exception as e:
        print("Error:", e)
        return 1

    return 0


if __name__ == "__main__":
    raise SystemExit(main())

Metadata

Release files for quantlib-addin 0.1.3

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

Built distributions (wheels)

Table of built distributions (wheels) for quantlib-addin 0.1.3
File Actions
quantlib_addin-0.1.3-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for quantlib_addin-0.1.3-cp313-cp313-win_amd64.whl
quantlib_addin-0.1.3-cp313-cp313-manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64 Details for quantlib_addin-0.1.3-cp313-cp313-manylinux_2_28_x86_64.whl
quantlib_addin-0.1.3-cp313-cp313-macosx_15_0_x86_64.whl CPython 3.13 CPython 3.13 macOS 15.0+ x86-64 Details for quantlib_addin-0.1.3-cp313-cp313-macosx_15_0_x86_64.whl
quantlib_addin-0.1.3-cp313-cp313-macosx_15_0_arm64.whl CPython 3.13 CPython 3.13 macOS 15.0+ ARM64 Details for quantlib_addin-0.1.3-cp313-cp313-macosx_15_0_arm64.whl

Total release size: 158.8 MB

Release files / quantlib_addin-0.1.3-cp313-cp313-win_amd64.whl

Download URL quantlib_addin-0.1.3-cp313-cp313-win_amd64.whl
Size 53.5 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
d51920632fa370e28f1e9107323e2688dd9ce94b49b700f364d9d7ce3fafff68
BLAKE2b-256 checksum
How to use checksums
b0a669daa700134f768e0d43eb2ea462088587bdbee2817443efd58f3497f6d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 8, 2026.

Transparency log

Release files / quantlib_addin-0.1.3-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL quantlib_addin-0.1.3-cp313-cp313-manylinux_2_28_x86_64.whl
Size 48.3 MB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
b73d8f1345213402ca7285b89091b8d8d1b8de3c77449dfad70e248ff3618aee
BLAKE2b-256 checksum
How to use checksums
3a79417f2b25428e3c0c731aa5f8a831e5964957c15ec81a85eb416635bc304f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 8, 2026.

Transparency log

Release files / quantlib_addin-0.1.3-cp313-cp313-macosx_15_0_x86_64.whl

Download URL quantlib_addin-0.1.3-cp313-cp313-macosx_15_0_x86_64.whl
Size 29.2 MB
Tags CPython 3.13 macOS 15.0+ x86-64
SHA-256 checksum
How to use checksums
dae8af3327a4d1bceffec79b4af2476780893211d3a02ae5f096d52b2bbc96a4
BLAKE2b-256 checksum
How to use checksums
c279387feb14a122c8ab8a5a000a12eaa76f9793f8606eec103b46f516894197
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 8, 2026.

Transparency log

Release files / quantlib_addin-0.1.3-cp313-cp313-macosx_15_0_arm64.whl

Download URL quantlib_addin-0.1.3-cp313-cp313-macosx_15_0_arm64.whl
Size 27.8 MB
Tags CPython 3.13 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
f28e3f8d56ebdb574f445527a3da53036e33d60e26ebc2b4e07641aaca084d5e
BLAKE2b-256 checksum
How to use checksums
eb6cb4c18ddc372d470ec69cdddb9e334cd3b3748e54e4ccc476e8ff51a20325
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 8, 2026.

Transparency log

Security for quantlib-addin 0.1.3

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.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for quantlib_addin-0.1.3-cp313-cp313-win_amd64.whl

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 Nov 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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