Overview
QuantLib Python provides pricing and risk analytics for fixed income, equity, FX, and credit derivatives. Covers yield curves, options, swaps, bonds, caps/floors, swaptions, and structured products. The standard open-source quantitative finance library used by banks, hedge funds, and fintech.
Installation
uv pip install QuantLib-Python
Bond Pricing
import QuantLib as ql
ql.Settings.instance().evaluationDate = ql.Date(15, 6, 2024)
schedule = ql.Schedule(
ql.Date(15, 6, 2023), ql.Date(15, 6, 2028),
ql.Period(ql.Semiannual),
ql.UnitedStates(ql.UnitedStates.GovernmentBond),
ql.Unadjusted, ql.Unadjusted,
ql.DateGeneration.Backward, False)
bond = ql.FixedRateBond(2, 100.0, schedule, [0.05], ql.ActualActual())
ytm = bond.bondYield(95.0, ql.ActualActual(), ql.Compounded, ql.Semiannual)
print(f"YTM: {ytm:.4%}")
References
1---2name: quantlib-python3description: QuantLib Python bindings for quantitative finance. Pricing and risk analytics for fixed income, equity, FX, credit derivatives, and structured products. Yield curves, options, swaps, bonds, and Monte Carlo simulation.4---5## Overview67QuantLib Python provides pricing and risk analytics for fixed income, equity, FX, and credit derivatives. Covers yield curves, options, swaps, bonds, caps/floors, swaptions, and structured products. The standard open-source quantitative finance library used by banks, hedge funds, and fintech.89## Installation1011```bash12uv pip install QuantLib-Python13```1415## Bond Pricing1617```python18import QuantLib as ql1920ql.Settings.instance().evaluationDate = ql.Date(15, 6, 2024)21schedule = ql.Schedule(22 ql.Date(15, 6, 2023), ql.Date(15, 6, 2028),23 ql.Period(ql.Semiannual),24 ql.UnitedStates(ql.UnitedStates.GovernmentBond),25 ql.Unadjusted, ql.Unadjusted,26 ql.DateGeneration.Backward, False)27bond = ql.FixedRateBond(2, 100.0, schedule, [0.05], ql.ActualActual())28ytm = bond.bondYield(95.0, ql.ActualActual(), ql.Compounded, ql.Semiannual)29print(f"YTM: {ytm:.4%}")30```3132## References33- [QuantLib docs](https://www.quantlib.org/)34- [QuantLib-Python](https://quantlib-python-docs.readthedocs.io/)