Documentation
Conventions
Dates, day counts, business-day rules, holiday calendars, tenor codes, spot rules, schedules and index conventions as NitroX implements them.
Every curve and swap in NitroX is built from the conventions in this chapter. Codes are plain strings and characters, compared against fixed spellings: where this page says a code is case-sensitive, a different case is not understood.
Dates
NitroX::Date (NX_Date.h) is a calendar date held as a Julian Day Number.
All date arithmetic is integer arithmetic on that number; there is no time of
day and no floating-point date.
NitroX::Date d(15, 1, 2026); // day, month, year
long serial = d.ExcelJulian(); // Excel serial number (46037)
NitroX::Date e;
e.SetFromExcel(serial); // and back
long days = e - d; // difference in calendar days
int wd = d.WeekDay(); // 1 = Monday ... 7 = Sunday
| Member | Behaviour |
|---|---|
Date(d, m, y), Set(d, m, y) | A day past the end of the month is clamped to the last day (Date(31, 2, 2026) is 28 Feb 2026). Month and year are not validated. |
Date() | Excel serial 0, 30 December 1899. |
AddDay(n), AddWeek(n) | Calendar days and weeks; n may be negative. |
AddMonth(n), AddYear(n) | Calendar arithmetic with the day clamped to month end: 31 Jan + 1M = 28 Feb (29 Feb in a leap year). There is no end-of-month stickiness: 28 Feb + 1M = 28 Mar. |
ExcelJulian(), SetFromExcel(serial) | Excel serial = Julian Day Number − 2415019, valid for dates from 1 March 1900. |
Date::Today() | The system date. |
comparison operators, operator- | On the day number; operator- returns days as long. |
Day counts
Date::Coverage(start, end, basis) returns the accrual fraction. Every basis
argument in the library (fixed and floating legs, funding margins, past
fixings) is one of these codes. They are case-sensitive.
| Code(s) | Convention |
|---|---|
A5, A365 | Actual/365 Fixed |
MM, A/360, Act/360 | Actual/360 |
AA | Actual/Actual (ISDA): each calendar year contributes its own days over its own length (365 or 366) |
BB, 30/360, Z, z | 30/360 (ISDA bond basis): D1 = 31 → 30; D2 = 31 → 30 only when D1 is 30 or 31 |
360/360, 30U/360 | The same computation as BB (no February end-of-month rule) |
30E/360 | 30E/360 (Eurobond): D1 = 31 → 30, D2 = 31 → 30 |
30E/360 ISDA | 30E/360 ISDA: a last day of month (including February) → 30; no maturity exception |
30/360 RAW, BB RAW | (360·ΔY + 30·ΔM + ΔD) / 360 with no day adjustment at all. Not a market convention. |
Any other string throws. Examples: 31 Mar 2026 → 30 Sep 2026 is 0.5 under BB;
30 Jun 2019 → 30 Jun 2022 is exactly 3.0 under AA.
The 30/360 family does not apply a February rule, because a single
Coverage call does not know whether the trade follows the end-of-month
convention.
Curve time is not a day count
Inside every curve, time is days / 365.25 and zero rates are continuously
compounded. This is not a day-count code you can choose; it is how a discount
factor is stored and interpolated (see Concepts).
Day counts only enter through the instruments: accrual fractions of coupons,
deposits and FRAs, and the basis in which an index rate is returned.
Date::DiscountFactor
Date::DiscountFactor(start, end, rate, basis) is a standalone helper, not
used by the curves:
basis | Discount factor |
|---|---|
"C" | exp(-rate · days / 365.25) |
"Z" | (1 + rate)^(-cov), cov on 30/360 |
| any day-count code | (1 + rate)^(-cov), annual compounding on that day count |
Business-day rules
Date::Modify(calendars, rule) moves a date that is not a business day on the
given calendars.
| Rule | Meaning |
|---|---|
'f' / 'F' | Following |
'm' / 'M' | Modified following: following, unless that crosses into the next month, then preceding |
'p' / 'P' | Preceding |
| any other character | Unadjusted |
A roll rule is passed as a single char throughout the library.
Holiday calendars
Calendars are computed from rules (NitroX::Holidays, NX_Holidays.h); there
are no holiday files. A calendar argument is a string of three-letter codes
concatenated without separators: a date is a business day for "USDEUR" only
if it is open in both USD and EUR.
| Code | Weekend | Closing days |
|---|---|---|
USD | Sat, Sun | Federal Reserve calendar: New Year’s Day, Martin Luther King Day, Presidents’ Day, Memorial Day, Juneteenth (from 2022), Independence Day, Labor Day, Columbus Day, Veterans Day, Thanksgiving, Christmas. A holiday on a Sunday is observed on the Monday; a holiday on a Saturday is not observed. |
EUR | Sat, Sun | TARGET2: 1 Jan, Good Friday, Easter Monday, 1 May, 25 Dec, 26 Dec. No substitute days. |
GBP | Sat, Sun | England and Wales bank holidays: New Year’s Day, Good Friday, Easter Monday, early May (first Monday), spring (last Monday of May), summer (last Monday of August), Christmas Day, Boxing Day, with weekend substitutes. |
JPY | Sat, Sun | National holidays, with the vernal and autumnal equinoxes computed by the standard approximation (valid 1900–2099), the Emperor’s Birthday on 23 Dec up to 2018 and 23 Feb from 2020, Mountain Day from 2016, the 2020 and 2021 Olympic moves, the substitute-holiday and citizens’-holiday rules, and the bank holidays 2–3 Jan and 31 Dec. |
MXN (also MEX) | Sat, Sun | Banxico: 1 Jan, Constitution Day (first Monday of February), Benito Juárez (third Monday of March), Holy Thursday and Good Friday, 1 May, 16 Sep, Revolution Day (third Monday of November), 1 Dec in presidential handover years (2024, 2030, …), 12 Dec, 25 Dec. |
AED | Sat, Sun from 1 Jan 2022; Fri, Sat before | 1 Jan, Eid al-Fitr (1–3 Shawwal), Arafat Day and Eid al-Adha (9–12 Dhu al-Hijjah), Islamic New Year, the Prophet’s Birthday, Commemoration Day (30 Nov 2015–2018, 1 Dec from 2019), National Day (2–3 Dec). |
SAR | Fri, Sat | Eid al-Fitr (1–4 Shawwal), Arafat Day and Eid al-Adha (9–13 Dhu al-Hijjah), National Day (23 Sep), Founding Day (22 Feb, from 2022). |
Behaviour to be aware of:
- Case. Each code is recognised in upper case or all lower case (
"USD","usd"); mixed case ("Usd") is not. - Unknown codes are an error. Any other three-letter code (
CHF,CAD,AUD, …) throws, naming the code and the ones that are known. - The empty string means weekends only: Saturday and Sunday are closed, and there are no holidays.
- No separators. The string is cut into consecutive three-character
chunks, so its length must be a multiple of three:
"USD,EUR"and"D"are refused. The same applies to the calendar part of a business-day rule ("2USD","0EUR", or"0"for weekends only);"0D"is refused. - One-off closures are not modelled: state funerals, royal or imperial events, national days of mourning, and similar days announced outside the regular rules.
Validity horizon
The Islamic holidays of AED and SAR are fixed by announcement and cannot
be computed exactly. Both calendars use a table of observed dates for Hijri
years 1436–1447 (Gregorian 2015–2026). Beyond the table they fall back to the
tabular (arithmetic) Islamic calendar, which, measured against published Saudi
dates for 2015–2026, runs 0 to 2 days late and never early. The observed table covers the two Eids (with
Arafat Day); the AED Islamic New Year and the Prophet’s Birthday always use the
tabular calendar.
The rule-based calendars have no horizon in the code, but they encode the holiday rules as legislated when they were written (December 2026): a holiday added or moved later is not included until the rules are updated.
Holidays::ValidUntil(code) reports the horizon:
| Return value | Meaning |
|---|---|
a year (currently 2026 for AED and SAR) | the last Gregorian year backed by observed dates |
0 | a rule-based calendar with no horizon (USD, EUR, GBP, JPY, MXN/MEX) |
-1 | an unrecognised code (IsOpen refuses it) |
NitroX::Holidays hol;
int horizon = hol.ValidUntil("SAR"); // 2026
bool open = NitroX::Date(1, 5, 2026).IsOpen("EUR"); // false: Friday 1 May is a TARGET2 holiday
Spot rules
A spot rule (bizzDayRule in NxIndexParam, the bizzDaysRule arguments
elsewhere) is applied by Date::ValueDate(rule):
rule := <n><calendars> [ <n><calendars> ... ]
Each segment adds n business days on its calendars, segment after segment.
The result is then rolled following on the calendars of the last segment.
| Rule | Meaning |
|---|---|
"2USD" | two USD business days |
"2EUR" | two TARGET2 business days |
"2USDGBP" | two days open in both USD and GBP |
"1GBP1USD" | one GBP business day, then one USD business day, then following on USD |
"0EUR" | no lag: the date itself, rolled following on EUR |
ValueDate(rule, -1) walks backwards. A count that is not a usable number
throws.
Tenor codes
Date::GetFwdDate(date, code, calendars, bizzDaysRule) turns a tenor code into
a date. Curves and swaps use it for every tenor you pass.
| Code | Meaning |
|---|---|
nD | n calendar days |
nW | n weeks |
nM | n months (day clamped to month end) |
nY | n years |
nB | n business days on calendars |
n* | n × 28 days (Mexican TIIE periods) |
ON | one day from date |
TN | one day from the next business day |
SN | one day from spot (bizzDaysRule) |
1.25Y, 1.5Y, 1.75Y | fractional years, converted to months (1.5Y = 18M) |
a month letter + year (H26, Z27) | an IMM date: the third Wednesday of that month |
The unit letter may be upper or lower case. Points to watch:
- The result of
GetFwdDateis unadjusted. The schedule generator and the curve instruments adjust end dates with the index roll rule. - Only the fractions
.25,.5and.75are recognised, and a fractional code is always read as years:1.5Mbecomes 18 months, and0.50Yis not recognised as half a year. A comma is accepted in place of the point. - An unrecognised unit letter is not rejected:
"3X"returns the start date unchanged. - Futures codes use the month letters
F G H J K M N Q U V X Z, and the year is 2000 plus the digits:H26is March 2026, butH6is March 2006. Use two digits.
FRA codes
A FRA is written AxB ("3x6", "18x24"; an M after either number is
accepted, as is X). In a curve, the FRA period starts A months after the
curve date, with no spot lag, and runs for B − A months. Anything that
is neither AxB with B > A nor a futures code throws.
Index tenor and roll helpers
Date::TenorMaturity(start, tenor, spotRule, calendars, rollRule) applies a
spot rule to start, adds the tenor and adjusts with the first character of
rollRule; pass an empty rollRule for an unadjusted date.
Schedules
The library generates every coupon schedule (curve instruments and swap legs) the same way:
- The start date is adjusted with the roll rule. The end date is adjusted with the roll rule too, unless that would put it on or before the start, in which case it is rolled following.
- Period dates are generated backwards from the unadjusted maturity, each computed directly from the maturity (maturity − k periods), not by chaining rolls. Only the generated dates are then adjusted. A maturity that falls on a weekend therefore does not shift the other coupon dates.
- This leaves any irregular period at the front: a short front stub.
- If modified following collapses the first two dates into one, the duplicate is dropped.
- Schedules built from a tenor (rather than from two dates) merge a short first period into the next one when it is shorter than one full period minus 5 days, which gives a long front stub. Schedules built from explicit start and end dates keep the short stub unless asked otherwise.
| Frequency | Period |
|---|---|
M | 1 month |
Q | 3 months |
S | 6 months |
A, Y | 12 months |
Z | zero coupon: a single period from start to end |
* | 28 days |
1 … 9 | every 1 to 9 years |
M, Q, S, A, Y and Z are also accepted in lower case.
End of month. The end-of-month rule is an option of the date-based
schedule initialiser (eom argument, off by default). When it is on and the
unadjusted maturity is the last day of its month, every generated date is
moved to the last day of its month before business-day adjustment (a 30 Jun
anchor pays on 31 Dec, not 30 Dec). With it off, an anchor on the 30th rolls to the 30th of each month.
The curve calibrations and swap legs do not switch it on.
There is no back stub, no explicit roll day and no IMM roll for interest-rate schedules.
Index conventions: NxIndexParam
All conventions of an index live in one NxIndexParam:
NxIndexParam(const std::string & ccy, const std::string & indexName,
const std::string & holidayCurrencies, const std::string & bizzDayRule,
const char rollRule, const std::string & floatBasis, long shortLimit,
const std::string & shortFixBasis, const char shortFixFreq, const char shortFloatFreq,
const std::string & longFixBasis, const char longFixFreq, const char longFloatFreq,
long floatFreqShortLimit = 0);
| Argument | Meaning |
|---|---|
ccy | Currency code. Curves of one currency must share it. |
indexName | Index family name ("SOFR", "ESTR", "EURIBOR"). An IBOR index is later named with its fixing tenor appended ("EURIBOR6"). |
holidayCurrencies | Calendars for adjustment and business-day counts ("EUR", "USDGBP"). |
bizzDayRule | Spot rule ("2EUR"). |
rollRule | Business-day rule for schedule dates ('m'). |
floatBasis | Day count of the floating leg and of the index rate ("MM"). |
shortLimit | The switch between the short and long conventions, in days. |
shortFixBasis, shortFixFreq, shortFloatFreq | Fixed-leg day count, fixed frequency and floating frequency for instruments up to shortLimit. |
longFixBasis, longFixFreq, longFloatFreq | The same beyond shortLimit. |
floatFreqShortLimit | An optional separate switch for the floating frequency, read by NxIndexParam::FloatFreq only. The curve calibrations switch the floating frequency at shortLimit. |
Short and long conventions
Many markets quote short swaps on different terms from long ones: a one-year OIS pays a single coupon at maturity, a five-year OIS pays annually; a short IBOR swap may pay a single fixed coupon. NitroX models this with one switch. For each instrument the library measures
matDays = (spot date + tenor, unadjusted) - spot date (calendar days)
and uses the long conventions when matDays > shortLimit, the short
ones otherwise. For custom-dated OIS periods, matDays is end − start.
Because matDays counts calendar days, a 1Y tenor is 365 or 366 days
depending on whether it spans 29 February. A shortLimit of exactly 365 sends
a leap-year 1Y to the long conventions. A limit a few days above a year (the
SOFR example below uses 370) keeps every 1Y on the short side.
Examples
These are the parameter sets the library’s own tests use.
using namespace NitroX;
// EUR overnight index: ACT/360, annual fixed and floating at all tenors.
auto estr = std::make_shared<NxIndexParam>(
"EUR", "ESTR", "EUR", "2EUR", 'm', "MM", 365,
"MM", 'A', 'A', // short: ACT/360, annual fixed, annual float
"MM", 'A', 'A'); // long
// USD SOFR.
auto sofr = std::make_shared<NxIndexParam>(
"USD", "SOFR", "USD", "2USD", 'm', "MM", 370,
"MM", 'A', 'A',
"MM", 'A', 'A');
// EURIBOR: zero-coupon fixed leg up to one year, 30/360 annual beyond.
auto euribor = std::make_shared<NxIndexParam>(
"EUR", "EURIBOR", "EUR", "2EUR", 'm', "MM", 365,
"MM", 'Z', 'S', // short: ACT/360, zero-coupon fixed, semi-annual float
"BB", 'A', 'S'); // long: 30/360, annual fixed, semi-annual float
With an annual short frequency ('A'), a period of up to a year has a single
coupon, so 'A' and 'Z' give the same short instrument.
From the library at v1.0.0 (ccaff0b). Edit this page on GitHub