Documentation
Curves
Building OIS, IBOR, funding and cross-currency curves in C++, the instruments each takes, and how the bootstrap resolves, solves and interpolates them.
This chapter shows how to build a curve set: which instruments each object takes, how each quote is turned into a calibration instrument, and what the bootstrap does with them. It assumes the model in Concepts and the codes in Conventions. Inflation curves are covered in Inflation.
The objects, in build order
| Step | Class | Constructor inputs |
|---|---|---|
| 1 | NxIndexParam | conventions (Conventions) |
| 2 | NxOisData, NxIborData | a Param and the quotes |
| 3 | NxOisShape, NxIborShape | a start date, a Data (an IBOR shape also takes its deposits and turn jumps), an interpolation code |
| 4 | NxDiscountLoc | a shape, and optionally funding margins or cross-currency basis quotes |
| 5 | NxOisIndex, NxIborIndex | a funding curve, a shape, a Data |
| 6 | NxCcyIndexes | one funding curve and the indexes built on it |
| 7 | NxIndexGlob | one NxCcyIndexes per currency |
All objects are passed by std::shared_ptr. Every rate, spread and quote is a
decimal (0.0325 for 3.25 %), with one exception: the convexity adjustment
of an NxSr3Future is in basis points.
A complete EUR build
ESTR OIS discounting, an ESTR index and a EURIBOR 6M index:
#include <memory>
#include <string>
#include <vector>
#include "NX_Date.h"
#include "NX_Params_NxIndexParam.h"
#include "NX_Datas_NxOisData.h"
#include "NX_Datas_NxIborData.h"
#include "NX_DiscountLoc_NxOisShape.h"
#include "NX_DiscountLoc_NxIborShape.h"
#include "NX_DiscountLoc_NxDiscountLoc.h"
#include "NX_IndexLoc_NxOisIndex.h"
#include "NX_IndexLoc_NxIborIndex.h"
#include "NX_CcyIndexes_NxCcyIndexes.h"
#include "NX_IndexGlob_NxIndexGlob.h"
using namespace NitroX;
std::shared_ptr<NxIndexGlob> BuildEur(const Date & today)
{
// Empty inputs, named: several constructors have overloads, and named
// vectors keep overload resolution unambiguous.
const std::vector<std::string> noTenors;
const std::vector<double> noRates;
const std::vector<Date> noDates;
// 1. Conventions.
auto estrParam = std::make_shared<NxIndexParam>(
"EUR", "ESTR", "EUR", "2EUR", 'm', "MM", 370,
"MM", 'A', 'A', // up to 370 days: ACT/360, annual fixed, annual float
"MM", 'A', 'A'); // beyond
auto euriborParam = std::make_shared<NxIndexParam>(
"EUR", "EURIBOR", "EUR", "2EUR", 'm', "MM", 370,
"MM", 'Z', 'S', // up to 370 days: zero-coupon fixed leg
"BB", 'A', 'S'); // beyond: 30/360 annual fixed, semi-annual float
// 2. ESTR quotes: overnight rate and OIS par rates.
const std::vector<std::string> oisTenors = { "1W", "1M", "3M", "6M", "1Y",
"2Y", "5Y", "10Y", "20Y", "30Y" };
const std::vector<double> oisQuotes = { 0.0190, 0.0191, 0.0192, 0.0194, 0.0197,
0.0205, 0.0225, 0.0250, 0.0262, 0.0258 };
auto estrData = std::make_shared<NxOisData>(
estrParam, 0.0190, // overnight rate
oisTenors, oisQuotes,
noTenors, noRates, // OIS FRAs
noDates, noDates, noRates, // custom periods: start, end, quote
noDates, noRates, "MM", // turn Diracs: dates, rates, basis
noDates, // central-bank step dates
noDates, noRates, // past overnight fixings: dates, rates
true); // rejectZeroRates
// 3. OIS shape (Hagan-West), 4. funding = the shape itself, 5. ESTR index.
auto estrShape = std::make_shared<NxOisShape>(today, estrData, 'm');
auto eurFunding = std::make_shared<NxDiscountLoc>(estrShape);
auto estrIndex = std::make_shared<NxOisIndex>(eurFunding, estrShape, estrData);
// EURIBOR 6M: last fixing, FRAs, swaps.
const std::vector<std::string> fraTenors = { "6x12", "12x18" };
const std::vector<double> fraQuotes = { 0.0218, 0.0222 };
const std::vector<std::string> swapTenors = { "2Y", "3Y", "5Y", "7Y", "10Y", "15Y", "20Y", "30Y" };
const std::vector<double> swapQuotes = { 0.0228, 0.0234, 0.0247, 0.0258, 0.0272,
0.0284, 0.0289, 0.0284 };
auto noFixings = std::make_shared<NxIborPastFixings>();
auto euribor6Data = std::make_shared<NxIborData>(
euriborParam,
6, // fixing tenor, in months
'A', // fixed frequency of the quoted swaps
0.0212, // today's fixing
fraTenors, fraQuotes,
swapTenors, swapQuotes,
noFixings,
true); // rejectZeroRates
// The IBOR shape takes the deposits and its own turn jumps directly.
const std::vector<std::string> cashTenors = { "1D", "1M", "3M", "6M" };
const std::vector<double> cashQuotes = { 0.0190, 0.0198, 0.0205, 0.0212 };
auto euriborShape = std::make_shared<NxIborShape>(
today, euribor6Data, cashTenors, cashQuotes,
noDates, noRates, "", // no turn Diracs
'm');
// The index is projected off its shape, discounted on ESTR.
auto euribor6 = std::make_shared<NxIborIndex>(eurFunding, euriborShape, euribor6Data);
// 6. One currency: one funding curve, its indexes.
auto eur = std::make_shared<NxCcyIndexes>();
eur->SetDiscountLoc(eurFunding);
eur->AddIndexLoc(estrIndex);
eur->AddIndexLoc(euribor6);
// 7. All currencies.
auto glob = std::make_shared<NxIndexGlob>();
glob->AddCcyIndexes(eur);
return glob;
}
Querying it:
#include <cstdio>
int main()
{
const Date today(15, 1, 2026);
std::shared_ptr<NxIndexGlob> glob;
try
{
glob = BuildEur(today);
}
catch(const std::string & error) // the library throws std::string
{
std::fprintf(stderr, "%s\n", error.c_str());
return 1;
}
double df = glob->DiscountFactor(Date(15, 1, 2031), "EUR");
double fwd6 = glob->IndexRate(Date(19, 1, 2027), Date(19, 7, 2027), "EUR", "EURIBOR6", "MM");
double fwdO = glob->IndexRate(Date(19, 1, 2027), Date(19, 4, 2027), "EUR", "ESTR", "MM");
std::printf("%.6f %.6f %.6f\n", df, fwd6, fwdO);
return 0;
}
IndexRate(from, to, ccy, indexName, basis) returns a simple rate in basis.
The index names are "ESTR" (the OIS Param name) and "EURIBOR6" (the IBOR
Param name with the fixing tenor in months).
The intermediate objects answer directly too: estrShape->DiscountFactor(d)
and estrShape->ZcRate(d) for the shape, eurFunding->DiscountFactor(d),
euribor6->IndexRate(from, to, "MM").
Market data objects
NxOisData
NxOisData(std::shared_ptr<NxIndexParam> param, const double & overnightRate,
const std::vector<std::string> & tenors, const std::vector<double> & quotes,
const std::vector<std::string> & fraTenors, const std::vector<double> & fraQuotes,
const std::vector<Date> & customStartDates, const std::vector<Date> & customEndDates,
const std::vector<double> & customQuotes,
const std::vector<Date> & diracDates, const std::vector<double> & diracRates,
const std::string & diracBasis,
const std::vector<Date> & stepDates,
const std::vector<Date> & fixingDates, const std::vector<double> & fixingRates,
bool rejectZeroRates = true);
A second overload takes an NxOisPastFixings object in place of
fixingDates/fixingRates.
| Argument | Meaning |
|---|---|
overnightRate | Today’s overnight rate. The first calibration instrument of the OIS shape and index: a one-day deposit from the curve date. |
tenors, quotes | OIS par rates by tenor ("ON", "TN", "SN", "1W", "3M", "10Y", …). |
fraTenors, fraQuotes | OIS FRAs ("3x6") or futures codes ("H26"): the compounded rate over the period. |
customStartDates, customEndDates, customQuotes | OIS over explicit dates. This is how futures normally enter an OIS curve. |
diracDates, diracRates, diracBasis | Turn-of-period jumps. diracBasis is not used in the computation. |
stepDates | Central-bank effective dates. |
fixingDates, fixingRates | Past overnight fixings, compounded in the Param’s floating day count, used for periods that started before the curve date. |
NxIborData
NxIborData(std::shared_ptr<NxIndexParam> param, int fixingMat, char swapsFixFreq,
double lastFixing,
const std::vector<std::string> & fraTenors, const std::vector<double> & fraQuotes,
const std::vector<std::string> & swapTenors, const std::vector<double> & swapQuotes,
std::shared_ptr<NxIborPastFixings> pastFixings,
bool rejectZeroRates = true);
NxIborData(std::shared_ptr<NxIndexParam> param, int fixingMat, char swapsFixFreq,
double lastFixing,
const std::vector<std::string> & fraTenors, const std::vector<double> & fraQuotes,
const std::vector<std::string> & swapTenors, const std::vector<double> & swapQuotes,
const std::vector<std::string> & spreadTenors, const std::vector<double> & spreadQuotes,
std::shared_ptr<NxIborData> spreadIndex,
std::shared_ptr<NxIborPastFixings> pastFixings,
bool rejectZeroRates = true);
| Argument | Meaning |
|---|---|
fixingMat | Fixing tenor in months (3, 6, …). It also names the index: Param "EURIBOR" with fixingMat = 6 is "EURIBOR6". |
swapsFixFreq | Fixed-leg frequency of the quoted swaps, used by the index calibration. The shape prices the same swaps with the Param’s short/long fixed frequency. Keep the two consistent. |
lastFixing | Today’s fixing, for the period starting at spot. Used by the index, not by the shape. |
fraTenors, fraQuotes | FRAs ("6x12") and futures codes ("H26"). |
swapTenors, swapQuotes | Par swap rates from spot. |
spreadTenors, spreadQuotes, spreadIndex | Tenor-basis quotes against another IBOR index (see below). |
pastFixings | Past fixings of the index, for periods that started before the curve date. Pass std::make_shared<NxIborPastFixings>() when there is no history. |
Deposits are not part of NxIborData; they are passed to NxIborShape.
Blank and zero quotes
- An empty tenor string removes its quote: IBOR FRA, swap and spread tenors, OIS tenors and OIS FRA tenors.
- With
rejectZeroRates = true(the default), a quote equal to exactly0.0is also removed: IBOR FRA and swap quotes, OIS tenor, FRA and custom quotes. This lets a sheet leave a quote cell blank. It also drops a genuine zero rate, so passfalsefor curves that can quote at or through zero. - Deposits, basis spreads, the overnight rate, the last fixing and funding margins are never filtered.
- Mismatched tenor and quote lengths throw, except for OIS FRAs and the three custom-period vectors, which must be given the same length by the caller.
Instruments
Each quote becomes one calibration instrument. The pillar column says where the bootstrap places the value it solves for (see One pillar per date).
| Instrument | Where it goes | Period | Priced as (shape) | Pillar |
|---|---|---|---|---|
| Overnight deposit (IBOR) | cash tenor "1D" | curve date + 1 day, following | single-period deposit in the float basis | end date; never dropped |
| Overnight rate (OIS) | overnightRate | curve date + 1 day, following | single-period deposit in the float basis | end date; never dropped |
| Deposit | IBOR cash tenors other than "1D" | spot + tenor, roll rule | single-period deposit in the float basis | end date |
ON, TN, SN | OIS tenors | overnight, tom-next, spot-next | single-period deposit | end date |
| FRA | fraTenors, "AxB" | curve date + A months to + B months, no spot lag | single period in the float basis | end date |
| Future | fraTenors, IMM code | third Wednesday of the month, for one period (see below) | single period in the float basis | end date |
| IRS | IBOR swapTenors | spot + tenor | par bond, Param fixed conventions | end date |
| OIS | OIS tenors | spot + tenor | par bond, Param fixed conventions | end date |
| OIS FRA | OIS fraTenors | as FRA or future | single period | end date |
| Custom-dated OIS | customStartDates/EndDates/Quotes | the given dates | par bond, Param fixed conventions for its length | end date |
| Tenor-basis spread | IBOR spreadTenors/Quotes | spot + tenor | synthetic swap quote | end date |
| OIS long end from IBOR | NxIborData passed to NxOisShape | IBOR swap segments | forward segments | IBOR swap maturities |
| Funding margin | NxDiscountLoc | spot + tenor ("1D" from the curve date) | par bond on the funding curve | maturity |
| Cross-currency basis | NxDiscountLoc | spot + tenor | par bond against a reference leg | maturity |
| Turn jump | Diracs | one night | multiplies the discount factor | none |
| Central-bank step | stepDates | between two step dates | flat overnight forward | step date |
Deposits
In an IBOR shape, deposits are passed as cashTenors/cashQuotes:
"1D"is the overnight deposit from the curve date. If no"1D"is given, the shape inserts one at the rate of its earliest-maturing deposit or FRA.- Every other cash tenor starts at spot.
"ON","TN"and"SN"are not special here: use"1D"for the overnight. - Deposits are read in the order given, and reading stops after the first deposit that ends on or after the start of the first FRA or future. Give deposits in increasing maturity.
- Deposits are not filtered for empty tenors or zero quotes.
In an OIS curve, the overnight rate is overnightRate, and "ON", "TN" and
"SN" may appear among the OIS tenors: overnight from the curve date,
tom-next from the next business day, spot-next from spot, each one day long
and adjusted following.
FRAs
A FRA code "AxB" starts A months after the curve date, not after spot,
and runs for B − A months; the start is adjusted following and the end with
the roll rule. A "6x12" therefore covers curve date + 6M to + 12M, not the
spot-starting period of a market 6x12 FRA. In an OIS curve, if the exact
period matters, enter the FRA as a custom period with its dates instead.
Futures
A futures code ("H26", "Z27") in a FRA list is a period starting on the
IMM date, the third Wednesday of the contract month:
- In an OIS curve it lasts three calendar months from the IMM date (end
adjusted with the roll rule), which is not always the next IMM date. For
the exact IMM-to-IMM quarter, use a custom period, for example from
NxSr3Future. - In an IBOR curve it lasts one fixing period of the index, but if
AxBFRAs are listed before it, it takes the length of the last FRA parsed before it. Put futures first in the list, or keep FRA lengths equal to the fixing tenor.
For SOFR futures, NxSr3Future (NX_Datas_NxSr3Future.h) computes the exact
IMM-to-IMM quarter from the contract code and the forward from the price:
NxSr3Future(const std::string & code, double price, double convexityBp);
// StartDate(), EndDate(): IMM date of the contract and of the contract 3 months later
// Forward() = (100 - price) / 100 - convexityBp / 10000
// IsPriced(): price > 0
Pass its dates and forward as an OIS custom period (see the SOFR example below).
Futures are taken without convexity adjustment. A futures quote, whether
an IMM code in a FRA list or a custom period, is fitted as a forward rate. The
library does not compute a convexity adjustment: subtract your own from the
futures rate before passing it, or pass it to NxSr3Future in basis points.
IRS and OIS
Swaps and OIS start at spot (Param spot rule) and end at spot + tenor,
adjusted with the roll rule. The shape prices each as a single-curve par bond
with the Param’s fixed frequency and day count, chosen by maturity against
ShortLimit (see
Conventions). The quote is the
par rate.
The indexes price the same quotes as two-leg swaps discounted on funding:
- OIS index: fixed leg as above, floating leg at the Param’s floating frequency for that maturity, with coupons from the index.
- IBOR index: fixed leg at
swapsFixFreqand the Param’s fixed day count, floating leg at the fixing tenor.
Custom-dated OIS
customStartDates[i], customEndDates[i], customQuotes[i] define an OIS
from start to end with quote customQuotes[i]. Its fixed conventions are
chosen from its length (end − start) against ShortLimit; with an annual or
zero-coupon short fixed leg, a period up to a year has a single coupon and
the quote is the compounded rate over the period in the fixed day count. This
is the natural way to enter futures and any period with known dates.
Custom periods count as futures for the pillar rules, including the futures-strip rule: every OIS tenor maturing between the first custom start and the last custom end (+ 14 days) is dropped (rule 4 below). A custom period far out the curve therefore removes every OIS quote maturing before it, back to the first custom start.
Tenor-basis spreads
An IBOR index can be quoted as spreads over another IBOR index, the spread
index (its own NxIborData, with its fixing and swaps):
auto euribor3Data = std::make_shared<NxIborData>(
euribor3Param, 3, 'A', 0.0205,
noTenors, noRates, swapTenors3, swapQuotes3, noFixings, true);
const std::vector<std::string> basisTenors = { "1Y", "2Y", "5Y", "10Y", "30Y" };
const std::vector<double> basisQuotes = { 0.0012, 0.0011, 0.0010, 0.0009, 0.0007 };
auto euribor6Data = std::make_shared<NxIborData>(
euriborParam, 6, 'A', 0.0212,
noTenors, noRates, // FRAs
swapTenors6, swapQuotes6, // 6M swaps quoted directly, may be empty
basisTenors, basisQuotes, // 6M swap = 3M swap + basis
euribor3Data,
noFixings, true);
A basis quote is the difference between the two indexes’ par swap rates at that tenor. The library strips the spread index’s own single curve, then for each swap tenor of the spread index that this index does not quote directly, adds a synthetic swap quote:
quote(T) = spreadIndexSwap(T) + B(T) / A(T)
where B is the product basis × annuity, linearly interpolated in time
between the basis tenors (flat outside them), and A(T) the annuity of the
tenor-T swap on the spread index curve. A tenor quoted directly takes
priority over a synthetic one (tenors are compared as strings). Both the IBOR
shape and the IBOR index do this; the index adds synthetic tenors only from
the first basis maturity onwards.
OIS long end from IBOR
When OIS quotes stop short of the IBOR swap curve, NxOisShape can extend
itself with IBOR quotes:
NxOisShape(const Date & startDate, const std::shared_ptr<NxOisData> nxOisData,
const std::shared_ptr<NxIborData> nxIborData, char interp = 'l');
The IBOR last fixing and swaps (not its FRAs) are stripped as a single curve with the same interpolation. The IBOR−OIS spread is measured on the IBOR segment that contains the last OIS maturity, as the difference between the par rates of the forward swap over that segment (annual, 30/360) on the IBOR curve and on the OIS shape. Each later IBOR segment is then added to the OIS shape at the IBOR forward par rate minus that spread. If the OIS set ends inside the first IBOR instrument, the segment starts at the IBOR value date. Nothing happens if the OIS quotes already reach the last IBOR maturity.
Funding margins
NxDiscountLoc(std::shared_ptr<NxShape> shape,
const std::vector<std::string> & fundTenors, const std::vector<double> & fundQuotes,
char fundFreq, const std::string & fundBasis);
const std::vector<std::string> fundTenors = { "1Y", "3Y", "5Y", "10Y" };
const std::vector<double> fundMargins = { 0.0008, 0.0012, 0.0015, 0.0020 };
auto bankFunding = std::make_shared<NxDiscountLoc>(estrShape, fundTenors, fundMargins, 'A', "MM");
For each tenor, a par bond from spot (from the curve date for "1D") with
frequency fundFreq and day count fundBasis is given the target coupon
shape par coupon + margin, and a zero-rate spread pillar at its maturity is
solved so the funding curve prices it there. The spread curve is linear in
time between pillars, starts at zero on the curve date and extrapolates flat
forward. Funding tenors are not checked for duplicates: give each maturity
once.
Cross-currency basis
NxDiscountLoc(std::shared_ptr<NxShape> discShape,
std::shared_ptr<NxShape> xCcyIndexShape,
const std::vector<std::string> & xCcyTenors, const std::vector<double> & xCcyQuotes,
char xCcyFreq, const std::string xCcyBasis,
std::shared_ptr<IndexLoc> fundRefXccyIndex,
const std::vector<std::string> & fundRefXccyTenors,
const std::vector<double> & fundRefXccyQuotes,
char fundRefXccyFreq, const std::string & fundRefXccyBasis,
const std::string & bizzDaysRule, char rollRule, const std::string & rollHolidays);
| Argument | Meaning |
|---|---|
discShape | Shape of the curve being built (currency C). The result is this shape plus a zero spread. |
xCcyIndexShape | Shape whose par rate the C leg pays. |
xCcyTenors, xCcyQuotes | Basis swap tenors and quotes; the quote is the spread on the C leg. |
xCcyFreq, xCcyBasis | Frequency and day count of both legs. |
fundRefXccyIndex | The reference currency’s index (e.g. a SOFR NxOisIndex), already built on its funding curve. |
fundRefXccyTenors, fundRefXccyQuotes | The reference currency’s funding margins over that index, linearly interpolated in time. Give at least one (zeros if there is no margin). |
fundRefXccyFreq, fundRefXccyBasis | Conventions used to date the reference margin tenors. |
bizzDaysRule, rollRule, rollHolidays | Spot rule and schedule conventions of the basis swaps ("2USDEUR", 'm', "USDEUR"). |
For each tenor, the C leg is a fixed coupon par rate of xCcyIndexShape +
basis quote with notional exchange, valued on the curve being built; the
reference leg pays the reference index plus its margin, with notional
exchange, valued with that index and its funding. The zero spread at the
tenor’s maturity is solved so the two have equal value per unit notional.
// EUR cash flows funded in USD: EUR discount curve from EUR/USD basis swaps,
// against SOFR flat.
const std::vector<std::string> xccyTenors = { "1Y", "2Y", "5Y", "10Y", "30Y" };
const std::vector<double> xccyQuotes = { -0.0012, -0.0014, -0.0016, -0.0015, -0.0010 };
const std::vector<std::string> usdTenors = { "1Y" };
const std::vector<double> usdMargins = { 0.0 };
auto eurXccyFunding = std::make_shared<NxDiscountLoc>(
estrShape, estrShape,
xccyTenors, xccyQuotes, 'Q', "MM",
sofrIndex, // from the SOFR build below, on USD funding
usdTenors, usdMargins, 'Q', "MM",
"2USDEUR", 'm', "USDEUR");
// EUR indexes are then calibrated on this funding curve.
auto estrIndexX = std::make_shared<NxOisIndex>(eurXccyFunding, estrShape, estrData);
A SOFR build with futures, FOMC steps and a turn
#include "NX_Datas_NxSr3Future.h"
auto sofrParam = std::make_shared<NxIndexParam>(
"USD", "SOFR", "USD", "2USD", 'm', "MM", 370,
"MM", 'A', 'A', "MM", 'A', 'A');
// SR3 futures: price, and the convexity adjustment you computed (bp).
const std::vector<NxSr3Future> futures = {
NxSr3Future("H26", 96.400, 0.2), NxSr3Future("M26", 96.520, 0.6),
NxSr3Future("U26", 96.620, 1.1), NxSr3Future("Z26", 96.700, 1.7) };
std::vector<Date> futStart, futEnd;
std::vector<double> futForward;
for(const NxSr3Future & f : futures)
{
if(!f.IsPriced()) continue;
futStart.push_back(f.StartDate());
futEnd.push_back(f.EndDate());
futForward.push_back(f.Forward());
}
// OIS tenors. 3M to 1Y mature inside the futures strip (18 Mar 2026 to
// 17 Mar 2027) and would be dropped by the strip rule, so they are left out.
const std::vector<std::string> tenors = { "1W", "1M", "18M", "2Y", "3Y", "5Y", "7Y", "10Y", "30Y" };
const std::vector<double> quotes = { 0.0363, 0.0361, 0.0310, 0.0303, 0.0298, 0.0305, 0.0315, 0.0328, 0.0335 };
// FOMC effective dates (the day after each meeting).
const std::vector<Date> fomc = { Date(29, 1, 2026), Date(19, 3, 2026), Date(30, 4, 2026),
Date(18, 6, 2026), Date(30, 7, 2026), Date(17, 9, 2026),
Date(29, 10, 2026), Date(10, 12, 2026) };
// Year-end turn: +25 bp (ACT/360) on the 31 Dec 2026 fixing, which runs four
// nights to Monday 4 Jan 2027. Booked on the end of the period.
const std::vector<Date> turnDates = { Date(4, 1, 2027) };
const std::vector<double> turnRates = { 0.0025 * 4 * 365.25 / 360.0 };
const std::vector<std::string> noTenors;
const std::vector<double> noRates;
const std::vector<Date> noDates;
auto sofrData = std::make_shared<NxOisData>(
sofrParam, 0.0363,
tenors, quotes,
noTenors, noRates,
futStart, futEnd, futForward,
turnDates, turnRates, "MM",
fomc,
noDates, noRates,
true);
const Date today(15, 1, 2026);
auto sofrShape = std::make_shared<NxOisShape>(today, sofrData, 'm');
auto usdFunding = std::make_shared<NxDiscountLoc>(sofrShape);
auto sofrIndex = std::make_shared<NxOisIndex>(usdFunding, sofrShape, sofrData);
The bootstrap
Order and solver
Every calibration in the library (shapes, index spreads, funding spreads) works the same way:
- Build one instrument per quote and apply the pillar rules.
- Sort the instruments by pillar date.
- Solve one pillar per instrument, in that order. The unknown is the value at
the pillar: a zero rate for a shape, a forward spread for an IBOR index, a
zero-rate spread for an OIS index or a funding curve. The solver is a
secant iteration started at the quote, with the slope taken by a small
forward bump:
x ← x + (target − p0) · ε / (p1 − p0). - An instrument is solved when its model par rate is within 1e-9 of the
quote (1e-5 bp). The solver allows 30 iterations (100 for the OIS shape)
and throws a
NitroX::Errorif it has not converged, naming the curve, the pillar and the quote, for example"Error : NxIborShape could not calibrate. [EUR-EURIBOR pillar 2031-03-17, quote 2.4500%]". The bootstrap never returns a curve that silently misses a quote.
There is no global solve. With local interpolation (l, t, s, f) a new
pillar does not move the curve before the previous pillar, so one pass
reprices every instrument. Hagan-West is not local: each new pillar moves the
node forwards on both sides. Shapes built with 'm' are therefore
re-swept: after the first pass every instrument is repriced, only those
outside the tolerance are re-solved, and the sweep repeats until none needs
it (two or three sweeps in practice, at most 50; reaching the cap leaves the
curve as the last sweep had it without raising). The index and funding
spreads use local interpolation and need one pass.
Instruments are priced inside the fit with everything the curve contains, turn Diracs included. Adding a Dirac does not change the quoted instruments’ par rates; it moves the forwards around it.
Inputs a bootstrap cannot fit
- An IBOR shape with no quotes at all is refused with a message.
- A curve whose only instrument is a single distant swap (a lone 5Y or longer IBOR swap, with nothing between it and the overnight) may fail to converge; it throws rather than returning a curve.
One pillar per date
Every curve holds one value per pillar date, so two quotes cannot both put a pillar on the same date. The pillar date is:
| Curve | Pillar date of an instrument |
|---|---|
| IBOR shape, its basis-spread curve, OIS shape | the instrument’s end date |
| IBOR index | the instrument’s last fixing date (the start of its last floating period; a FRA’s start) |
| OIS index | the instrument’s maturity |
| inflation index | see Inflation |
Overlapping quotes are resolved by four rules:
| # | Overlap | Outcome |
|---|---|---|
| 1 | Two quotes of the same kind on the same pillar date: two 5Y swaps; 1Y and 12M; two futures | Refused with an error naming the kind, the date, both rates and the curve. |
| 2 | A FRA or future within 14 calendar days of a cash or swap pillar, the same date included. In an OIS curve, custom periods count as futures. | The cash or swap quote is dropped; the FRA or future is kept. |
| 3 | Cash and a swap on the same date (cash 1Y and swap 1Y) | The swap is kept, the cash quote dropped. |
| 4 | OIS curves only: a cash or swap pillar maturing inside the futures strip, from the first custom period’s start to the last custom period’s end + 14 days, gaps between contracts included | The swap is dropped. Swaps maturing before the first custom start, or more than 14 days after the last custom end, are kept. The OIS shape and the OIS index drop the same quotes. |
The rule 1 error reads, for example:
Error : two swap quotes put a pillar on the same date, 2031-01-15 (2.8500% and 4.0000%),
in the EUR-EURIBOR6 IBOR shape. A curve holds one value per date, so one would silently
replace the other; remove one of them.
Further points:
- Anchors are exempt: the overnight deposit or rate a curve starts from, and an IBOR index’s fixing, are never dropped or refused.
- Dropped quotes are dropped silently. The library has no warning channel. A quote you passed that does not reprice on the finished curve is the sign that a rule removed it.
- Two quotes of the same kind a few days apart (two swaps, two futures) are both kept: no rule prefers one.
- FRA codes start at the curve date while swaps start at spot. A
"18x24"FRA and a"2Y"swap end a few days apart, so rule 2 drops the swap. - Rule 4 lets an OIS quote sheet keep every tenor filled: the futures set the front of the curve, and the swaps they cover are ignored.
- The rules apply to the shapes and indexes (and the inflation index). They are not applied to funding margins, cross-currency quotes, or the IBOR curve that extends an OIS shape.
Interpolation
Shapes take an interpolation code as their last constructor argument. The
C++ default is 'l'; pass 'm' for Hagan-West.
| Code | Interpolation of zero rates between pillars |
|---|---|
'm' | Hagan-West monotone convex |
'l' | linear in the zero rate |
't' | linear in r·t, i.e. flat (piecewise constant) forwards |
's' | √t-weighted |
'f' | step: the zero rate of the previous pillar |
For the local modes the curve is flat in the zero rate before the first
pillar and flat in the forward (linear in r·t) after the last. An unknown
code is not rejected: it gives zero rates of 0 between pillars. Pass only the
codes above.
Hagan-West monotone convex
The 'm' mode implements Hagan and West (2006) on continuously compounded
zero rates against ACT/365.25 time:
- Discrete forwards between pillars,
fd_i = (r_i·t_i − r_{i−1}·t_{i−1}) / (t_i − t_{i−1}), with a node at t = 0 added. - Instantaneous forwards at the nodes, as time-weighted averages of the adjacent discrete forwards.
- A sign-aware collar on each node forward: within
[0, 2·min(fd)]when its adjacent discrete forwards are both positive, within[2·max(fd), 0]when both are negative, and 0 when they have opposite signs. This keeps the interpolated forward from changing sign within an interval, and handles negative-rate curves correctly. - The paper’s four-sector function
gbetween nodes, and its integral for the zero rate. - Extrapolation past the last pillar at the last node’s instantaneous forward, held flat.
The paper’s optional amelioration step is not implemented. A node whose two adjacent discrete forwards straddle zero is set to exactly 0 by step 3, which puts a kink in the forward curve at that node.
In an OIS shape, 'm' applies to the interpolated part of the curve: the
whole fit when there are no central-bank steps, the deviation from the step
curve when there are. Because that deviation has small forwards of both signs
by construction, the OIS shape interpolates it without the collar. IBOR
shapes use the collar.
Spread curves
The spreads added on top of shapes have fixed interpolation:
| Spread | Interpolation | Before the first pillar | After the last |
|---|---|---|---|
| IBOR index forward spread | linear in fixing time | flat | flat |
| OIS index zero spread | linear in time, from 0 at the curve date | — | flat forward |
| Funding zero spread | linear in time, from 0 at the curve date | — | flat forward |
Turn-of-period jumps
A Dirac multiplies every discount factor on or after its date by
exp(−rate / 365.25): an extra rate rate earned over the single night that
ends on that date. The basis argument passed with Diracs is not used. Both
shapes take Diracs (NxIborShape as constructor arguments, NxOisShape
through its NxOisData).
To book a jump of J (a decimal in the index’s ACT/360 basis) on a fixing
whose period runs n nights (three over a weekend, more across a holiday),
pass
rate = J · n · 365.25 / 360, dated on the end of the period (the next business day)
as in the SOFR example. Because the bootstrap fits the quotes with the Diracs in place, a Dirac moves forwards around the turn and leaves the quoted instruments repricing.
Pass only Diracs dated after the curve date. A Dirac dated on or before it is not discarded and distorts the cumulative jump of the later ones.
Central-bank steps
stepDates in NxOisData are the effective dates of central-bank decisions:
the first day the new rate applies (the day after an FOMC meeting, for
example). With step dates, the OIS shape is split into:
- a step curve whose zero rates at the step dates are linear in
r·tbetween them, so its overnight forward is constant from one step date to the next and flat after the last; and - the rest of the fit, which absorbs what the steps do not explain at the quoted maturities.
The split is computed by a fixed number of passes (30) after the quotes are fitted, and the curve is then re-swept so every quote reprices again. The result: every quote reprices to the solver tolerance, and the overnight forward between two step dates is flat, exactly with linear interpolation and to within a few hundredths of a basis point with Hagan-West (the curve’s smooth part keeps a small slope).
Give step dates only after the curve date; they are not filtered. Without step dates, nothing of this applies.
Start date
Every curve is anchored on the start date passed to its shape, and all discount factors are measured from it. An OIS shape moves a start date that is not a business day on its calendars to the next business day; an IBOR shape does not. Funding curves and indexes take their start date from the shape.
Caching
NxOisShape keeps a per-day table of discount factors and zero rates from its
start date to its last pillar (or to the last IBOR maturity when its long end
is extended). The table is filled once, at the end of calibration; later
queries for a date in that range are table lookups, and dates outside it are
computed directly. A copy made with MakeCopy() has the table switched off and
computes every value directly. NxIborShape, funding curves and indexes do
not cache.
Curve sensitivities: bump and rebuild
This release does not include a risk engine. A curve sensitivity is computed the way any user of the public classes can: build the market twice, once from the original quotes and once with one quote moved, and reprice.
- Build the market (
NxIndexGlob) from your quotes and price the trade withNxSwap::CalcPv(see Swaps). - Copy the quote vectors, move one quote by 1 bp (0.0001), and build a second market from them: new data object, new shape, new funding curve, new indexes, in the same order as the first build.
- Price the same trade off the second market. The difference in PV is the sensitivity to that quote. Repeat for each quote for a bucketed DV01, or move all quotes at once for a parallel DV01.
Build each bumped market from scratch rather than reusing curve objects from the first build. A central difference (bump up and down, halve the difference) removes most of the convexity in the result at the cost of a second rebuild per quote.
Inflation curves
Inflation indexes (NxInflationIndex on NxInflationData, calibrated to
zero-coupon inflation swaps and discounted on a funding curve built as above)
are described in Inflation.
From the library at v1.0.0 (ccaff0b). Edit this page on GitHub