Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rates-pricing-cpp

A small, tested C++17 library for linear-rates curve construction and Black-76 option pricing — the two core building blocks behind a rates desk's pricing stack.

I built this to demonstrate, in compiled C++, the analytics I have validated from the calling side: bootstrapping a SOFR/OIS discount curve and pricing the Black-76 options (caps/floors, swaptions) that sit on top of it.

What it does

  1. OIS / SOFR curve bootstrap (OisCurve) — strips discount factors from par swap rates via the deterministic bootstrap, so every input instrument reprices to par. Exposes discount factors, continuously-compounded zero rates, and no-arbitrage forward rates.
  2. Black-76 pricer (black76_*) — prices European options on a forward rate (the model used for caplets/floorlets and swaptions), with delta, gamma and vega.

The maths

Bootstrap. An OIS swap's floating leg PV telescopes to 1 - DF(n), so the par condition S_n * Σ DF(i) = 1 - DF(n) solves pillar by pillar:

DF(n) = (1 - S_n * Σ_{i<n} DF(i)) / (1 + S_n)

Forward rate (no-arbitrage): F(t1,t2) = (DF(t1)/DF(t2) - 1) / (t2 - t1). Zero rate (continuous): z(T) = -ln(DF(T)) / T.

Black-76. For a forward F, strike K, expiry T, vol σ, discount factor df:

d1 = (ln(F/K) + 0.5 σ² T) / (σ √T),   d2 = d1 - σ√T
call = df · [F·N(d1) - K·N(d2)]
put  = df · [K·N(-d2) - F·N(-d1)]

Build & run

cmake -S . -B build && cmake --build build
./build/demo      # bootstrap + Black-76 demo
ctest --test-dir build --output-on-failure   # unit tests

Or without CMake:

clang++ -std=c++17 -Iinclude src/black76.cpp src/curve.cpp src/main.cpp -o demo && ./demo
clang++ -std=c++17 -Iinclude src/black76.cpp src/curve.cpp tests/tests.cpp -o tests && ./tests

Tests

tests/tests.cpp checks the bootstrap against hand calculations, the reprice-to-par identity (residual ~1e-12), the no-arbitrage forwards, and Black-76 put-call parity (C - P = DF·(F - K)).

Notes

C++17, no third-party dependencies (the normal CDF uses std::erfc). Layout: include/ headers, src/ implementation, tests/ unit tests.

About

C++17: OIS/SOFR curve bootstrap + Black-76 pricer, unit-tested

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages