fixed-income
Install
python3 -m pip install -e .
python3 -m pip install -e '.[data]' # datasets[data] (FRED, Treasury.gov, NY Fed, CME)
python3 -m pip install -e '.[viz]' # plotly, dash, matplotlib, …
python3 -m pip install -e '.[dev]' # pytest, ruff, build
python3 -m pip install -e '.[dev,data,viz]'
Bond risk
from fixed_income import Bond
from fixed_income.risk import macaulay, modified
b = Bond(c=0.05, F=100, T=10, P=95.0)
y = b.ytm()
print(macaulay(b, ytm=y), modified(b, ytm=y))
Nelson–Siegel and NSS on Treasury par
from datasets.data import TreasuryParCurveSource
from fixed_income import NelsonSiegel, NelsonSiegelSvensson
par = TreasuryParCurveSource().fetch()
t = [p.maturity_years for p in par.points]
r = [p.par_yield for p in par.points]
ns = NelsonSiegel(t=t, r=r)
ns.fit()
print("NS tau:", ns.tau)
nss = NelsonSiegelSvensson(t=t, r=r)
nss.fit()
print("NSS tau1/tau2:", nss.tau1, nss.tau2)
SOFR OIS curve, forwards, and Hull–White calibration
from datetime import date
from datasets.data import NyFedSofrSource, CmeSofrSettleBundleSource
from fixed_income import bootstrap_ois_from_sofr, HullWhite, forward_rate_from_discount
as_of = date(2026, 5, 22)
sofr = NyFedSofrSource().fetch(as_of=as_of)
ois = bootstrap_ois_from_sofr(sofr, pillars=[0.25, 0.5, 1.0, 2.0, 5.0])
fwd = forward_rate_from_discount(ois, 0.25, 1.0)
print(f"1y forward (from OIS): {fwd:.4%}")
bundle = CmeSofrSettleBundleSource(trade_date=as_of).fetch(as_of=as_of)
cal = HullWhite.calibrate_to_futures(bundle.sr3, ois)
print(f"HW a={cal.a:.4f}, sigma={cal.sigma:.4f}, RMSE={cal.rmse:.4f}")
Examples
Dash dashboard
python3 -m pip install -e '.[viz]'
python3 -c "from fixed_income.viz import create_dash_app; create_dash_app().run_server(debug=True)"
Build / test
./scripts/build_test.sh
python3 -m pytest tests/test_rates.py -q
Release files for fixed-income 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fixed_income-0.1.3.tar.gz | 690.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fixed_income-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 710.2 kB
Release files / fixed_income-0.1.3.tar.gz
| Download URL | fixed_income-0.1.3.tar.gz |
|---|---|
| Size | 690.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ebae9a9998c763860a872c3931df50b15ca9f69ce962b1ce96f531f1ec9fb69
|
|
BLAKE2b-256 checksum How to use checksums |
8146b429663739c6b50b48c32726ffa4a7a34fd2e5a9839324f153e2cb726d3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / fixed_income-0.1.3-py3-none-any.whl
| Download URL | fixed_income-0.1.3-py3-none-any.whl |
|---|---|
| Size | 19.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e8964f5265feb3eb6ebb5caa5611d3112c092bce8e811e4ab42c243765d9c445
|
|
BLAKE2b-256 checksum How to use checksums |
89ac22cedb98fee4b4e736a97f7b8584e29a650e2f6f6bfec08529e915fb7308
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|