Documentation

Inflation

CPI curves calibrated to zero-coupon inflation swaps - market data, index lag and interpolation, the CPI definition, calibration, seasonality, and pricing zero-coupon inflation swaps.

An inflation curve in NitroX is an NxInflationIndex: a projection of a CPI built from published CPI prints and zero-coupon inflation swap (ZCIS) quotes, attached to a funding curve for discounting. It sits in an NxCcyIndexes beside the currency’s interest-rate indexes, and zero-coupon inflation swaps are ordinary NxSwap objects whose floating leg names the CPI index (see Swaps).

Three objects are involved:

ObjectHeaderHolds
NxIndexParamNX_Params_NxIndexParam.hConventions: currency, index name, calendar, spot rule, roll rule, day counts and frequencies
NxInflationDataNX_Datas_NxInflationData.hZCIS tenors and quotes, published CPI history, swap periodicity, observation lag, interpolation flag
NxInflationIndexNX_IndexLoc_NxInflationIndex.hThe calibrated CPI curve, its seasonality, and the funding curve

Everything is in namespace NitroX.

Conventions

An inflation index uses the same 14-argument NxIndexParam constructor as the rate indexes (see Conventions), with zero-coupon ("Z", 'Z') day counts and frequencies throughout:

auto cpiParam = std::make_shared<NxIndexParam>(
    "USD", "USCPI", "USD", "2USD", 'm',   // ccy, index name, calendar, spot rule, roll rule
    "Z",                                  // floating basis
    370,                                  // short/long limit, in days
    "Z", 'Z', 'Z',                        // short end: fixed basis, fixed freq, float freq
    "Z", 'Z', 'Z',                        // long end:  fixed basis, fixed freq, float freq
    360);                                 // float-frequency short limit

What the CPI calibration reads from it: the index name (the name the curve is found under), the calendar, the spot rule ("2USD": the calibration swaps start two USD business days after the curve date), the roll rule, and the fixed and floating bases. A basis of "Z" is handled as 30/360 (ISDA) for accrual, with the fixed rate compounded annually. The index’s currency is that of its funding curve.

Market data: NxInflationData

NxInflationData(std::shared_ptr<NitroX::NxIndexParam> param,
                const std::vector<std::string> & swapTenors,   // "1Y", "2Y", ...
                const std::vector<double> & swapQuotes,        // ZCIS fixed rates, annually compounded
                const std::vector<Date> & pubDates,            // published CPI: reference months
                const std::vector<double> & pubValues,         // published CPI: index levels
                char periodicity,                              // 'Z' for zero-coupon swaps
                int lag,                                       // observation lag, in months
                bool indexInterp);                             // daily interpolation of the reference CPI
  • Quotes are zero-coupon swap rates: the fixed leg pays N * ((1 + q)^t - 1) at maturity.
  • Published CPI: one value per reference month, dated on the first day of the month it refers to (the October print is dated 1 October, whenever it was released). The CPI curve reads every month at its first day; a print dated otherwise is not read back as that month’s value. At least one print is required (the index constructor does not check), and the calibration swaps’ base month should be published (see Calibration).
  • Periodicity: the payment frequency of the calibration swaps; 'Z' (one period, start to maturity) for zero-coupon swaps. Only zero-coupon swaps are covered in this release.
  • Lag and indexInterp define the reference CPI of a date; see the next section.

The accessors SwapTenors(), SwapQuotes(), PubDates(), PubValues(), Periodicity(), Lag() and IndexInterp() return what was given.

The CPI of a date

The curve holds a deseasonalised CPI level D(m) for each month m, on the first day of the month, and twelve additive seasonal coefficients s_1 ... s_12 (index points, January first). The CPI level of a month is

CPI(m) = D(m) + s_month(m)

The reference CPI of a date d in month M, with observation lag L months:

  • Non-interpolated (indexInterp = false): the CPI of month M - L.

    CPI_ref(d) = CPI(M - L)
  • Interpolated (indexInterp = true): the market formula (US CPI and euro HICP linked products, zero-coupon inflation swaps), linear by day of month between months M - L and M - L + 1, with day the day of d and Days the number of days in M:

    CPI_ref(d) = CPI(M - L) + (day - 1) / Days * (CPI(M - L + 1) - CPI(M - L))

    On the first of the month this is CPI(M - L); it would reach CPI(M - L + 1) on the first of the next month. With L = 3 it brackets M - 3 and M - 2, as the market does.

Until December 2026 the library interpolated one month earlier (M - L - 1 and M - L) with the weight (day - 1) / (Days - 1); the market formula replaced it.

Reference dates are a swap leg’s adjusted start and end dates, so in interpolated mode a maturity rolled over a weekend reads a different day of the month.

Calibration

NxInflationIndex is calibrated in its constructor:

NxInflationIndex(std::shared_ptr<NitroX::DiscountLoc> funding,
                 std::shared_ptr<NitroX::NxInflationData> data,
                 const std::vector<double> & seasonCoefs);   // exactly 12 values, January first

seasonCoefs takes twelve values, January first, or none for no seasonality; any other length throws. The coefficients are shifted by their mean so they sum to zero, and SeasonCoefs() returns the shifted values. A constant added to all twelve only moves the deseasonalised curve the other way, so CPI levels and prices do not depend on it; the shift makes D the CPI’s trend. At least one published CPI is required; with none the constructor throws.

  1. Start. The curve starts on the funding curve’s start date. The published CPI, less each month’s seasonal coefficient, gives the initial deseasonalised points.
  2. Calibration swaps. The value date S is the curve date moved by the param’s spot rule. For each tenor, a swap runs from S to T = S + tenor, with the start adjusted following and the maturity adjusted with the param’s roll rule and calendar.
  3. Target. The quote q is converted to its simple 30/360 equivalent over the swap’s actual dates, r = ((1 + q)^t - 1) / t with t the 30/360 year fraction from S to the adjusted T: the same dates a swap built with these conventions uses to price.
  4. Pillar. Each swap gets one pillar: the deseasonalised level D at the first day of the month of T - L, or of the month after it in interpolated mode (the last month the swap’s reference CPI reads), so each swap fixes the last level it depends on. A secant search (0.1 index point step, at most 30 iterations) moves that level until the swap’s par rate matches r to within 1e-9. If it does not converge, the constructor throws "Error : NxIborIndex could not calibrate." (the message names the IBOR class, but comes from the inflation calibration).

For a zero-coupon swap, the par condition is

CPI_ref(T) / CPI_ref(S) = (1 + q)^t

Both legs pay once, at T, so the discount factor cancels: the CPI curve does not depend on the funding curve. Funding matters only when the swaps are priced.

Consequences and requirements:

  • Every quote reprices. A ZCIS built with the same conventions (spot start, 'Z' frequency, "Z" basis on both legs) has a par rate equal to its quote to within the solver’s 1e-9.
  • One quote per CPI month. Two tenors whose pillar months coincide would need two values on one pillar. They are refused with an error naming both quotes.
  • Pillars after the history. Every pillar month should be later than the last published month. A pillar on a published month replaces that print; a pillar before the first print is not supported.
  • Base CPI. CPI_ref(S) reads month M_S - L (and the month after it, interpolated). If it is published, the base is the print. If it falls after the last print, it is interpolated between the last print and the first pillar, and so moves with the calibration.
  • Order. List the tenors in increasing maturity.
  • Between and beyond pillars. D is linear in calendar days between its points (prints and pillars) and extrapolated linearly from the last two points beyond the last one (and from the first two before the first print). The seasonal coefficient is then added month by month.

At a pillar month the seasonal coefficient is absorbed by the calibration: the CPI there is fixed by the quote, whatever the coefficient. Seasonality shapes the months in between, and, in interpolated mode, the month before each pillar month (month T - L), which enters the swap’s reference CPI.

Seasonality

Applying coefficients

The seasonCoefs vector holds twelve additive adjustments in index points, January first. They are subtracted from the prints to build D and added back when a CPI is read, so every published month reads back as its print. Being additive in points, a fixed coefficient represents a smaller percentage as the index level rises.

Estimating coefficients: CalcSeasonalityCoefs

static std::vector<double> NxInflationIndex::CalcSeasonalityCoefs(std::vector<Date> & cpiDates,
                                                                  std::vector<double> & cpiValues);

The arguments are taken by non-const reference (pass named vectors) and are not modified. The result is twelve coefficients, January first, ready to pass to the constructor. What it does:

  1. Input. The dates and values must have the same length, and the prints must be consecutive months once sorted by date: a missing or repeated month throws. With fewer than 24 prints (one seasonal value per calendar month) it returns twelve zeros, without error.

  2. Trend. A centred 2×12 moving average:

    T_t = (X_{t-6} + X_{t+6}) / 24 + (X_{t-5} + ... + X_{t+5}) / 12
  3. Seasonal + irregular, additively: SI_t = X_t - T_t.

  4. Smoothing across years, per calendar month, with the X-11 3×3 seasonal filter: the same month of neighbouring years, weights (1, 2, 3, 2, 1) / 9:

    S_t = (SI_{t-24} + 2 SI_{t-12} + 3 SI_t + 2 SI_{t+12} + SI_{t+24}) / 9

    A month’s factor is the average of its smoothed values. A month with fewer than five seasonal values (under about six years of prints) gets the plain average of its values instead.

  5. Zero sum. The mean of the twelve factors is subtracted, so the coefficients sum to zero.

On a linear trend with a pure seasonal pattern, the pattern is recovered exactly, demeaned: a +1 index point January effect gives +0.917 in January and −0.083 in every other month.

Until December 2026 step 4 smoothed across adjacent months instead (December, January, February around a January), which spread the same January effect over November to March and returned +0.250 for January.

If you estimate seasonality elsewhere (for example with an X-11/X-13 style filter on the same month across years), pass the resulting additive coefficients, in index points and summing to zero, directly to the constructor.

Building the curve

The CPI index must be built on the same funding curve object as the currency’s other indexes: NxCcyIndexes::AddIndexLoc refuses an index whose funding curve is a different object.

#include "NX_Date.h"
#include "NX_Params_NxIndexParam.h"
#include "NX_Datas_NxInflationData.h"
#include "NX_IndexLoc_NxInflationIndex.h"
#include "NX_CcyIndexes_NxCcyIndexes.h"
#include "NX_IndexGlob_NxIndexGlob.h"
#include "NX_Swap_NxSwap.h"

using namespace NitroX;

// From the USD curve build (see Getting started / Curves):
//   discount : std::shared_ptr<NxDiscountLoc>, the USD funding curve, stripped on `today`
//   sofr     : std::shared_ptr<NxOisIndex>, the SOFR index built on `discount`
const Date today(30, 11, 2026);

const std::vector<std::string> tenors = { "1Y", "2Y", "3Y", "5Y", "7Y", "10Y", "15Y", "20Y", "30Y" };
const std::vector<double> quotes = { 0.0260, 0.0250, 0.0245, 0.0240, 0.0240, 0.0242, 0.0245, 0.0247, 0.0248 };

// Monthly prints, each dated on the first of its reference month, oldest first.
std::vector<Date> pubDates;
std::vector<double> pubValues;
// ... fill from your CPI history, e.g. pubDates.push_back(Date(1, 10, 2026)); pubValues.push_back(...);

std::vector<double> seasonality = NxInflationIndex::CalcSeasonalityCoefs(pubDates, pubValues);
// or: std::vector<double> seasonality(12, 0.0);

auto cpiData = std::make_shared<NxInflationData>(
    cpiParam, tenors, quotes, pubDates, pubValues,
    'Z',        // zero-coupon calibration swaps
    3,          // observation lag, months
    true);      // interpolated reference CPI

auto cpi = std::make_shared<NxInflationIndex>(discount, cpiData, seasonality);

auto usd = std::make_shared<NxCcyIndexes>();
usd->SetDiscountLoc(discount);
usd->AddIndexLoc(sofr);
usd->AddIndexLoc(cpi);          // registered as "USCPI", the param's index name

auto market = std::make_shared<NxIndexGlob>();
market->AddCcyIndexes(usd);

Reading the curve

NxInflationIndex does not expose CPI levels directly. What it exposes:

  • IndexRate(const Date & from, const Date & to, const std::string & basis): the simple rate (CPI_ref(to) / CPI_ref(from) - 1) / Coverage(from, to, basis). A basis of "Z" (or "z") is read as "BB", so the result is a 30/360 simple rate, not a compounded one. The CPI ratio is therefore 1 + IndexRate(from, to, "BB") * Date::Coverage(from, to, "BB").
  • DiscountFactor(date) and DiscountFactor(toDate, fromDate): those of the funding curve.
  • IndexName(), Ccy(), StartDate(): the param’s index name, the funding curve’s currency and start date.

Zero-coupon inflation swaps

A ZCIS is an NxSwap with zero-coupon conventions on both legs: frequency 'Z', basis "Z", and the CPI index as the floating index. With the single-currency constructors, leg 0 is the fixed leg (coefficient +1) and leg 1 the inflation leg (−1), so a positive notional receives fixed and pays inflation.

// 10Y USCPI ZCIS from spot, receive 2.45% fixed on 20mm.
NxSwap zcis("USD", today, "2USD", "", "10Y", "USD", 'm',
            0.0245, 'Z', "Z",
            "USCPI", 'Z', "Z",
            false, 20e6);

Each leg pays once, at the adjusted maturity T, with S the adjusted start:

fixed leg      N * ((1 + K)^t - 1),       t = 30/360 year fraction from S to T
inflation leg  N * (CPI_ref(T) / CPI_ref(S) - 1)
PV (receiver)  N * DF(T) * [ (1 + K)^t - CPI_ref(T) / CPI_ref(S) ]

DF(T) is the currency’s discount curve, discounted to the pricing date. t is 30/360 on adjusted dates, so a maturity rolled off a weekend gives a slightly non-integer t; the calibration uses the same t, so the swap still prices at par at its quote.

Par rate, PV and PV01

const double par = zcis.CalcFixRate(*market, 0, today);   // annually compounded, as quoted
NxWallet pv = zcis.Pv(*market, today);
const double pvUsd = pv.Amount("USD");

// PV01 with respect to the swap's own fixed rate, per bp.
std::shared_ptr<DiscountLoc> usdDiscount = market->GetDiscountLoc("USD");
const double k = zcis.Leg(0)->FixRate();
const double pv01 = zcis.Coef(0) * zcis.Leg(0)->CalcSensi(usdDiscount.get(), today, k) / 1e4;
  • CalcFixRate returns the zero-coupon rate, compounded annually. A spot-starting swap at a quoted tenor returns the quote.
  • A swap struck at its par rate has a PV of zero; an off-par swap is worth N * DF(T) * ((1 + K)^t - (1 + par)^t) to the fixed receiver.
  • CalcSensi on a "Z" leg is the annuity per unit of the simple 30/360 rate; the third argument converts it to a sensitivity per unit of the compounded rate, evaluated at that rate. Passing the leg’s own FixRate() gives the derivative of the PV with respect to the contract rate. See Swaps.
  • The cash-flow report (NxSwapPricer::CalcCancellation) shows the fixed rate as quoted.

Seasoned swaps

A ZCIS that started before the curve date is built with explicit dates and priced in the same way. Its base CPI_ref(S) reads the published history:

NxSwap seasoned("USD", Date(16, 6, 2025), Date(17, 6, 2030), "USD", 'm',
                0.0260, 'Z', "Z", "USCPI", 'Z', "Z", false, 30e6);

const double seasonedPar = seasoned.CalcFixRate(*market, 0, today);
NxWallet seasonedPv = seasoned.Pv(*market, today);

The prints covering the base months must be in the data (month M_S - L, and the month after it in interpolated mode).

Funding

Discounting is the only place the funding curve enters. NxSwap::Pv discounts the inflation leg on the CPI index’s funding curve and the fixed leg on the currency’s discount curve; since the index must share the currency’s funding curve to enter the NxCcyIndexes, both legs are discounted on the same curve. Rebuilding the CPI curve on a different funding curve changes swap PVs (through DF(T)) but not the CPI curve itself.

Inflation risk by bump and rebuild

A sensitivity to each ZCIS quote is obtained by bumping that quote alone, rebuilding the CPI index on the same funding curve, and repricing:

auto buildMarket = [&](const std::vector<double> & q) {
    auto data = std::make_shared<NxInflationData>(cpiParam, tenors, q, pubDates, pubValues, 'Z', 3, true);
    auto index = std::make_shared<NxInflationIndex>(discount, data, seasonality);
    auto ccy = std::make_shared<NxCcyIndexes>();
    ccy->SetDiscountLoc(discount);
    ccy->AddIndexLoc(sofr);
    ccy->AddIndexLoc(index);
    auto glob = std::make_shared<NxIndexGlob>();
    glob->AddCcyIndexes(ccy);
    return glob;
};

const double bump = 1e-6;                          // 0.01 bp
const double base = zcis.Pv(*market, today).Amount("USD");
std::vector<double> dv01(quotes.size());
for(size_t i = 0; i < quotes.size(); ++i)
{
    std::vector<double> bumped = quotes;
    bumped[i] += bump;
    auto m = buildMarket(bumped);
    dv01[i] = (zcis.Pv(*m, today).Amount("USD") - base) / bump * 1e-4;   // per 1 bp
}

Because the funding curve is unchanged, this is pure CPI risk. Rate risk comes from rebuilding the rate curves; see Curves.

Limits

  • Zero-coupon inflation swaps only. Year-on-year swaps and inflation options are not part of this release.
  • Seasonality is additive in index points; see Seasonality.
  • No direct CPI level accessor; use IndexRate for CPI ratios.
  • See Accuracy and known behaviours.

From the library at v1.0.0 (ccaff0b). Edit this page on GitHub