Skip to content

About

Classic interest rate models in Python: Vasicek, CIR, Ho-Lee, Hull-White, G2++, HJM, LMM

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

interest-rate-models

CI/CD Downloads PyPI Python codecov Docs License: MIT

Classic interest rate models in Python: short-rate models (Vasicek, CIR, Ho-Lee, Hull-White, G2++) and full-curve models (Heath-Jarrow-Morton, LIBOR Market Model) behind one interface, with analytic bond and option pricing where it exists and exact or discretized Monte Carlo simulation everywhere.

Full documentation: interest-rate-models.readthedocs.io

Installation

pip install interest-rate-models

Requires Python >= 3.13.

Quick start

import numpy as np
from interest_rate_models import DiscountCurve, get_model

# Market curve: pillar maturities and continuously-compounded zero rates
curve = DiscountCurve.from_zero_rates(
    times=np.array([0.5, 1.0, 2.0, 5.0, 10.0]),
    zero_rates=np.array([0.030, 0.032, 0.034, 0.037, 0.039]),
)

# No-arbitrage short-rate model fitted to the curve
hw = get_model("hull-white", curve=curve, a=0.1, sigma=0.01)
print(hw.bond_price(0.0, 5.0))          # reproduces curve.discount(5.0)
print(hw.bond_option(1.0, 5.0, strike=0.85, kind="call"))

# Equilibrium model calibrated to the curve
vasicek = get_model("vasicek", kappa=0.5, theta=0.04, sigma=0.01)
params = vasicek.calibrate(curve, r0=0.03)

# Full-curve models
lmm = get_model("lmm", curve=curve, tenor=0.5, n_periods=10, vol=0.20)
print(lmm.cap_price(strike=0.035))

The factory accepts "vasicek", "cir", "ho-lee", "hull-white", "g2++", "hjm", and "lmm". See the documentation for each model's dynamics, formulas, parameters, and configuration.

Examples

The examples/ directory has one executed notebook per model, all built on the same live Treasury curve (via yfinance) and following the same structure, so the figures are directly comparable across models.

Contributing

Contributions, bug reports, and feature requests are welcome. Open an issue or submit a PR on GitHub.

License

MIT

About

Classic interest rate models in Python: Vasicek, CIR, Ho-Lee, Hull-White, G2++, HJM, LMM

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages