A C++20 interest-rate derivatives engine for curve calibration, swap valuation, market-quote risk, portfolio replay, and contractual lifecycle accounting. It supports OIS discounting, separate projection curves, seasoned SOFR swaps, and same-currency overnight basis swaps, with optional Python bindings and independent Python/QuantLib validation.
The repository connects numerical pricing to practical workflows: importing and checking market inputs, producing cash flows and sensitivities, sizing hedges, replaying historical snapshots, and reconciling payments and cash collateral. Research studies examine curve-model uncertainty and the limits of hedging.
Source: 2.4.0-dev, unreleased. Published download: v2.3.0. The newer solver, curve ambiguity workflow, and subsequent fixes are available in source; they are absent from that release. See the changelog.
Quick start · Interfaces and workflows · Validation · Documentation · Contributing
| Area | Implemented behavior | Guide |
|---|---|---|
| Dates and conventions | Gregorian dates, explicit holiday calendars, business-day adjustment, month-end handling, short final stubs, ACT/360, ACT/365F and 30E/360 accrual | Conventions |
| Curve construction | Deposit/par-swap bootstrapping and direct continuous-zero inputs; OIS discounting; separate projection calibration; SOFR and basis calibrators; log-linear discount interpolation and quote-repricing diagnostics | Methodology, multi-curve pricing |
| Swap valuation | Fixed/floating swaps, future OIS, seasoned SOFR and compounded overnight/overnight basis swaps; cash flows, PV, par rates/spreads, and SOFR/basis clean/dirty PV with accrued amounts | SOFR lifecycle, basis swaps |
| Risk and portfolios | Parallel and bucketed quote DV01 through full rebootstrap, separate zero-node sensitivities, downstream curve recalibration, shared single-curve portfolio scenarios and explicit per-trade failures | Risk methodology, portfolio design |
| Market data and replay | Availability-aware fixing revisions, captured NY Fed SOFR data, validated OIS quote imports, timestamped quote lookup, freshness checks, and synthetic/Fed Treasury-proxy replay | Market-data status, historical data |
| Clearing and collateral | In-memory acceptance, rejection, payment and termination events; cash-collateral calls, transfers, interest and return; contractual basis-payment reconciliation and optional SQLite journals | Lifecycle and persistence |
| Hedging and research | Bounded, lot-rounded SOFR hedge sizing; nonlinear stress scenarios; quote-compatible curve bounds, exported witness curves and conditional additional-quote ranking | Hedge study, curve ambiguity |
Quotes, calendars and conventions define the calibration instruments. The bootstrappers produce discount and projection curves; pricing combines those curves with trade schedules and, for seasoned overnight coupons, available fixings. Risk calculations perturb market quotes and repeat calibration and valuation. Portfolio calculations reuse calibrated scenarios across trades.
Lifecycle components track a different part of the workflow: which contractual payments are due, which have settled, and how cash collateral changes. The basis contract adapter connects priced, fully realized coupons to those obligations; the optional SQLite layer persists and replays the validated event journals.
The native library owns the financial calculations. Command-line tools handle CSV input and exports, while Python provides data adapters, persistence, research orchestration and independent reference implementations.
| Calibrated curve | Quote risk versus zero-node risk |
|---|---|
![]() |
![]() |
These plots use the introductory synthetic single-curve example. Inputs and reproduction and chart provenance are retained.
Run source commands from the repository root. Builds use CMake 3.25+, Ninja, a C++20 compiler and Python 3.10+. See the toolchain setup for compiler installation and Windows Developer shells.
On Windows, with the compiler and CMake available:
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install ninja pybind11 QuantLib "scipy>=1.14,<2"
.\run.ps1 -WithPython -TestThe launcher builds Release, runs CTest and prices the sample swap.
Use -Configuration Debug for Debug.
On Linux/macOS:
python3 -m venv .venv
. .venv/bin/activate
python -m pip install ninja pybind11 QuantLib "scipy>=1.14,<2"
cmake --preset release -DRATES_BUILD_PYTHON=ON -Dpybind11_DIR="$(python -m pybind11 --cmakedir)" -DPython3_EXECUTABLE="$(python -c 'import sys; print(sys.executable)')"
cmake --build --preset release --parallel 4
ctest --preset release
./build/release/rates_cli --quotes examples/synthetic_quotes.csv --swap examples/sample_swap.csv --out results/demoGoogleTest is fetched on the first test build if it is not installed. The
Python-enabled suite needs pybind11, QuantLib and SciPy; Matplotlib is needed
only to regenerate charts. Bindings are optional: use RATES_BUILD_PYTHON=OFF
for native tools. With tests and bindings disabled, the native library needs
neither Python nor GoogleTest.
Extract the v2.3.0 Windows x64 ZIP, open PowerShell in the extracted root, and run:
.\bin\rates_cli.exe --quotes examples/synthetic_quotes.csv --swap examples/sample_swap.csv --out results/demoFor this synthetic 1 million notional, 5Y payer at 3.7% fixed, expect approximately
4,531.35 PV, 3.80% par rate, and -451.94 currency/bp signed parallel
quote DV01. Both source and packaged demos write summary, curve, calibration,
cash-flow and risk CSVs under results/demo.
The ZIP contains native tools and a static C++ library, with Windows compiler runtimes embedded. Python extensions must be built for the chosen interpreter. Package verification records the published download and extracted-binary checks.
| Interface | Purpose |
|---|---|
rates::rates_engine |
Installed CMake target for the C++ library; public headers are in include/rates |
pyrates |
Optional pybind11 module exposing native pricing, risk, SOFR, basis, lifecycle and ambiguity APIs |
rates_cli |
One single-curve swap with configurable conventions and detailed CSV exports |
rates_batch |
Single-curve portfolio valuation and timestamped replay, including stale-data and partial-failure reporting |
rates_simulate |
A separate single-instrument ETF long/cash simulation experiment |
| Python workflow scripts | Captured-fixing valuation, hedge studies, contractual lifecycle persistence, historical replay and curve ambiguity |
The CSV tools retain their single-curve scope. Use the C++ or Python APIs for separate discount/projection curves and the richer SOFR/basis conventions.
After building bindings, these commands run the main Python demonstrations:
python python/run_sofr_valuation.py --module-dir build/release --manifest data/sofr/manifest.json --out results/sofr
python python/hedge_study.py --module-dir build/release --out results/hedging --require-quantlib
python python/run_basis_lifecycle.py --module-dir build/release --out results/lifecycle --database results/lifecycle.sqlite
python python/curve_ambiguity.py --module-dir build/release --input examples/curve-ambiguity.json --out results/ambiguity --require-quantlibUse the active environment's Python; on Windows the equivalent is
.\.venv\Scripts\python.exe. The examples above create results/ before the
SQLite command. The replay runbook covers rates_batch,
snapshot selection and exit statuses. For C++ consumers, use
find_package(rates_engine CONFIG REQUIRED) and link rates::rates_engine;
the consumer example demonstrates installation and usage.
Curve construction. Curves store positive discount factors and interpolate their logarithms between pillars. Instantaneous forwards are consequently piecewise constant, with jumps at pillars. Extrapolation is rejected. Vanilla/OIS calibration uses safeguarded secant steps with bisection fallback; seasoned SOFR and basis calibration retain bisection. Calibrated instruments must pass quote-residual checks.
Multiple curves. Discount factors value future payments; projection curves generate floating rates. A discount-quote shock rebuilds discounting and recalibrates projection to unchanged forwarding quotes. Basis risk extends this dependency chain through the other overnight projection curve.
Seasoned SOFR. Coupon valuation combines realized fixings and projected daily rates, with lookback, observation shift, lockout, and spot/payment lags. Fixings are selected by availability at the valuation timestamp. Missing required past fixings fail explicitly. Accrued amounts and payment-date inclusion have documented conventions.
Risk coordinates. Quote risk bumps market inputs and rebuilds curves;
zero-node risk shifts continuous node yields directly. Signed DV01 is
(PV_down - PV_up) / (2 * bump_bps), in currency per basis point. Thus a
negative DV01 for a payer means its PV rises when rates rise.
Portfolio execution. The single-curve portfolio path shares base/shocked curves and equal-date/convention schedules. Invalid trades are reported individually; aggregates cover successful trades only. Benchmarks measure this scenario-reuse design and calibration costs on stated workloads.
The SOFR adapter captures public NY Fed fixings and archives snapshots with hashes. OIS quote imports check schema, units, timestamps, freshness, required tenors and convention compatibility. These checks do not supply an executable quote feed. The captured SOFR demonstration combines real fixings with synthetic OIS quotes.
Historical replay supports immutable timestamped quote files and explicit as-of/freshness policies. The Fed GSW dataset contains fitted Treasury zero curves used as a retrospective valuation proxy; it is not an executable swap market or a point-in-time strategy backtest.
Clearing and collateral ledgers validate events before committing state and support idempotent replay. The contractual basis workflow checks the complete payment inventory and amounts before normal-maturity closure. SQLite journals add atomic batches, rollback and serialized concurrent writers on local disk. These are generic modeled rules, without a live clearinghouse connection.
Worked examples retain inputs, valuation dates and
expected outputs. Recorded results and their manifests identify
specific configurations and revisions; generated local output goes in ignored
build/ and results/ directories.
| Workflow | Recorded example | Details |
|---|---|---|
| Multi-curve valuation | Synthetic 1 million, 5Y, 3.5% payer: PV 28,509.36 with separate projection, versus -16,545.34 using the discount curve in both roles | Inputs, conventions and comparison |
| Seasoned SOFR | Captured 21 October 2026 example: dirty PV -4,448.43 USD, clean PV -4,593.36 USD; 15 realized and 484 projected observations | Cash-flow chart, reproduction |
| Constrained hedging | Synthetic 5Y SOFR swap hedged with 2Y/4Y/6Y swaps: quote-risk norm reduced by 51.68%; some stress outcomes worsen | Hedge chart, study and assumptions |
| Curve ambiguity | Synthetic 1 million, 3.5Y payer: baseline PV 2,720.35; admissible PV range -66,244.31 to 63,956.10 with assumed forwards between -1% and 10% | Witness-curve chart, research and prior art |
The ambiguity workflow solves LPs over discount factors, exports witness curves, and checks numerical optimality and independent QuantLib repricing. Its ranges are conditional on quote intervals and forward assumptions, not confidence intervals or forecasts. Admissible-curve bounds have prior art; no new mathematical theory or global novelty is claimed.
Performance work includes portfolio scenario reuse, Linux profiling, and the bootstrap solver study. Measurements identify hardware and workloads; no QuantLib performance comparison is claimed. The ETF simulator is a separate supporting experiment.
GoogleTest exercises native invariants and failure paths. Python checks CLI, bindings, replay and journal behavior; independent Python and QuantLib implementations compare prices, cash flows, calibrations and quote risk. CI defines Linux GCC/Clang, Windows MSVC and macOS builds, plus sanitizer, formatting/static-analysis and coverage jobs.
| Recorded scope | Result | Evidence |
|---|---|---|
| Published v2.3.0 Windows Release, bindings enabled | 100/100 CTest entries passed | Runtime verification |
| Published v2.3.0 commit, cross-platform CI | 7/7 jobs passed | CI record |
| Independent OIS/separate-projection suite | 230/230 comparisons passed | Report |
| Expanded SOFR lifecycle and two-curve quote risk | 30,524/30,524 comparisons passed | Methods and tolerances |
| Expanded ambiguity audit, 2.4.0-dev | 28 witnesses repriced; 154 QuantLib comparisons passed, including all sweeps | Consistency verification |
These counts describe different suites and revisions. The badge shows current main-branch CI; historical records do not certify later changes. Coverage documents its C++-library denominator, the basis coverage gap and LLVM profile warnings. CLI, bindings and Python are excluded from that denominator. Tests and comparisons cover the documented cases and tolerances, not every possible convention combination.
| Path | Contents |
|---|---|
| include/rates, src | Public C++ APIs and native implementations |
| apps | Pricing, batch-replay and simulation executables |
| python | Bindings, adapters, workflows, reference pricers and validation scripts |
| tests, benchmarks | Native tests and measured performance workloads |
| examples, data | Synthetic trades/quotes, consumer project and captured data with provenance |
| docs, ops | Methods, worked examples, research, validation evidence and replay operations |
| cmake, .github/workflows | Installation/export, packaging and CI |
This is a deterministic quantitative engineering and research project. Supported products and conventions are explicit: there is no options/stochastic pricing, XVA, cross-currency basis, general trade-amendment service, or production clearing infrastructure. Calendars require supplied holidays; schedules use month-based periods with short final stubs. See the full model boundaries.
For setup, formatting, testing and pull requests, read CONTRIBUTING.md. The documentation index organizes current guides and historical records; CHANGELOG.md separates development work from published releases.
MIT licensed; dependencies retain their own licenses.

