ThirdMomentQuantX

Chapter 1

Dates, tenors and frequencies

Contents
  1. 1.1 Notation
  2. 1.2 Dates
  3. 1.3 Day numbers and differences between dates
  4. 1.4 Adding months and years
  5. 1.5 Tenors
  6. 1.6 Frequencies
  7. 1.7 Excel serial numbers
  8. 1.8 Worked examples
  9. References

Every calculation in QuantX starts from dates: trade dates, fixing dates, payment dates, maturities. This chapter defines exactly what a date is, how dates are compared and shifted by a number of days, months or years, how market tenors such as "3M" are written and applied, and how payment frequencies are described. Holidays and business days are not considered here; they are the subject of the chapters that follow.

1.1 Notation

Symbol Meaning
\(d = (y, m, q)\) A date with year \(y\), month \(m\) and day of the month \(q\)
\(\mathcal{D}\) The set of supported dates (Section 1.2)
\(L(y, m)\) Number of days in month \(m\) of year \(y\)
\(N(d)\) Day number of date \(d\): a count of days from a fixed origin
\(d + k\) The date \(k\) days after \(d\) (\(k\) may be negative)
\(d_2 - d_1\) Number of days from \(d_1\) to \(d_2\)
\(M_k(d)\) The date \(k\) months after \(d\)
\((n, u)\) A tenor: amount \(n\) (an integer) and unit \(u \in \{\text{D}, \text{W}, \text{M}, \text{Y}\}\)
\(d \oplus \tau\) Date \(d\) shifted by tenor \(\tau\)
\(S(d)\) Excel serial number of date \(d\)

1.2 Dates

A date is a day of the proleptic Gregorian calendar (the calendar in civil use today, extended to all years), with no time of day and no time zone. It is written \(d = (y, m, q)\) and displayed in ISO 8601 form yyyy-MM-dd, for example 2026-10-10.

Leap years. Year \(y\) is a leap year when it is divisible by 4, except years divisible by 100 that are not divisible by 400:

\[\text{leap}(y) \iff \left(4 \mid y \text{ and } 100 \nmid y\right) \text{ or } 400 \mid y .\]
(1.1)

So 2024 and 2000 are leap years; 2100 and 2200 are not.

Days in a month. \(L(y, m)\) is 31 for January, March, May, July, August, October and December; 30 for April, June, September and November; and for February, 29 in a leap year and 28 otherwise.

Validity. \((y, m, q)\) is a valid date when \(1 \le m \le 12\) and \(1 \le q \le L(y, m)\).

Supported range. The library supports dates from 1 January 1900 to 31 December 2199 inclusive:

\[\mathcal{D} = \{\, d \text{ valid} : 1900\text{-}01\text{-}01 \le d \le 2199\text{-}12\text{-}31 \,\}.\]
(1.2)

This covers every historical fixing that matters and trades maturing more than 170 years from today. Any operation whose result would fall outside \(\mathcal{D}\) is an error; it is never silently truncated.

Day of the week is the usual Gregorian weekday (Monday to Sunday). For example, 2026-10-10 is a Saturday.

1.3 Day numbers and differences between dates

Each date has a day number \(N(d)\): the number of days elapsed since a fixed origin. The origin itself does not matter, because only differences of day numbers are used. Consecutive dates have consecutive day numbers, including across month and year ends and across 29 February.

The number of days from \(d_1\) to \(d_2\) is

\[d_2 - d_1 = N(d_2) - N(d_1),\]
(1.3)

which is positive when \(d_2\) is later than \(d_1\). Adding \(k\) days to a date gives the date whose day number is \(N(d) + k\):

\[N(d + k) = N(d) + k .\]
(1.4)

Dates are ordered by their day numbers: \(d_1 < d_2 \iff N(d_1) < N(d_2)\).

These are actual calendar days. Business days and day-count fractions (such as Act/360) are defined in later chapters on top of Equation (1.3).

1.4 Adding months and years

Shifting a date by \(k\) months moves the month by \(k\) (carrying into the year as needed) and keeps the day of the month, except when that day does not exist in the target month, in which case the last day of the target month is used. Formally, for \(d = (y, m, q)\) and an integer \(k\):

\[\begin{aligned} m' &= \big((m - 1 + k) \mathbin{\mathrm{mod}} 12\big) + 1, \\ y' &= y + \left\lfloor \frac{m - 1 + k}{12} \right\rfloor, \\ M_k(d) &= \big(y',\ m',\ \min\{q,\ L(y', m')\}\big), \end{aligned}\]
(1.5)

where \(\mathbin{\mathrm{mod}}\) returns a value in \(\{0, \dots, 11\}\) and \(\lfloor\cdot\rfloor\) rounds down (also for negative numbers).

Adding \(k\) years is defined as adding \(12k\) months: \(M_{12k}(d)\). In particular, 29 February plus one year is 28 February.

The clamping in Equation (1.5) has consequences that users must be aware of:

  • It cannot always be undone. \(M_1(2026\text{-}01\text{-}31) = 2026\text{-}02\text{-}28\), but \(M_{-1}(2026\text{-}02\text{-}28) = 2026\text{-}01\text{-}28\).
  • Repeated shifts can differ from one larger shift. \(M_1(M_1(2026\text{-}01\text{-}31)) = 2026\text{-}03\text{-}28\), whereas \(M_2(2026\text{-}01\text{-}31) = 2026\text{-}03\text{-}31\). Schedules are therefore always generated by shifting from a fixed anchor date (\(M_k(d_0)\) for \(k = 1, 2, \dots\)), never step by step.

End of month. A date is an end-of-month date when \(q = L(y, m)\). The end-of-month date of \(d\)'s month is \((y, m, L(y, m))\). The market's end-of-month rule, which keeps month-end dates at month-end when shifting, is a schedule convention and is defined in the schedules chapter; it is not part of Equation (1.5).

1.5 Tenors

A tenor \(\tau = (n, u)\) is an amount \(n\) of a unit \(u\): days (D), weeks (W), months (M) or years (Y). It is written as the amount followed by the unit letter: 1D, 2W, 3M, 10Y. Shifting a date by a tenor is defined by the unit:

\[d \oplus (n, u) = \begin{cases} d + n & u = \text{D}, \\ d + 7n & u = \text{W}, \\ M_n(d) & u = \text{M}, \\ M_{12n}(d) & u = \text{Y}. \end{cases}\]
(1.6)

Shifting backwards by a tenor is shifting by \((-n, u)\).

  • The amount may be zero or negative; 0D leaves the date unchanged.
  • In text, a tenor is an optional minus sign, an amount of at most six digits and the unit letter in either case: -1D, 3m. A plus sign, spaces and amounts above 999999 are rejected. Six digits cover every day shift inside the supported range, and the negation of such an amount can never overflow.
  • Two tenors are equal only if both amount and unit are equal. 12M and 1Y are different tenors, although by Equation (1.6) they always produce the same date. Likewise 7D and 1W.
  • Calendar days are used here. "Business-day" tenors, such as a spot lag of two business days, are defined in Section 2.6.

1.6 Frequencies

A frequency describes how often a regular event, such as a coupon payment, occurs. It is either:

  • Term: a single event at the end (for example, a zero-coupon payment), or
  • a regular frequency with period tenor \(\tau = (n, u)\) and \(n > 0\).
Frequency Period tenor Periods per year
Annual 1Y 1
Semi-annual 6M 2
Quarterly 3M 4
Monthly 1M 12
Weekly 1W —
Daily 1D —
Term — —

Periods per year. For a regular frequency whose period is a whole number of months \(p\) (with \(p = 12n\) for a period in years), the number of periods per year is

\[P = \frac{12}{p},\]
(1.7)

defined only when \(p\) divides 12 (so \(P\) is a whole number). It is undefined for week- and day-based frequencies and for Term, because a year is not a whole number of weeks or days.

Two frequencies are equal when their periods cover the same number of months (for month- and year-based periods) or the same number of days (for day- and week-based periods): 12M and 1Y describe the same frequency.

1.7 Excel serial numbers

Excel stores a date as a serial number: 1 for 1900-01-01, 2 for 1900-01-02, and so on. For compatibility with Lotus 1-2-3, Excel treats 1900 as a leap year and gives the serial number 60 to a non-existent date "1900-02-29". The conversion is therefore

\[S(d) = \begin{cases} d - 1899\text{-}12\text{-}31 & \text{if } d \le 1900\text{-}02\text{-}28, \\ d - 1899\text{-}12\text{-}30 & \text{if } d \ge 1900\text{-}03\text{-}01, \end{cases}\]
(1.8)

with differences of dates as in Equation (1.3). Serial number 60 does not correspond to any date and is rejected. Serial numbers of supported dates range from 1 (1900-01-01) to 109574 (2199-12-31).

1.8 Worked examples

Operation Result Reference
2026-10-10 − 2026-01-31 252 days Equation (1.3)
2026-01-31 ⊕ 1M 2026-02-28 Equation (1.5)
2024-01-31 ⊕ 1M 2024-02-29 (leap year) Equation (1.5)
2024-02-29 ⊕ 1Y 2025-02-28 Equation (1.6)
2026-03-31 ⊕ -1M 2026-02-28 Equation (1.5)
2026-11-30 ⊕ 3M 2027-02-28 Equation (1.5)
2026-10-10 ⊕ 2W 2026-10-24 Equation (1.6)
\(S(2026\text{-}10\text{-}10)\) 46305 Equation (1.8)
\(S(1900\text{-}02\text{-}28)\), \(S(1900\text{-}03\text{-}01)\) 59, 61 Equation (1.8)
Periods per year, Quarterly 4 Equation (1.7)

For example, for 2026-11-30 ⊕ 3M: \(m - 1 + k = 10 + 3 = 13\), so \(m' = (13 \mathbin{\mathrm{mod}} 12) + 1 = 2\) and \(y' = 2026 + \lfloor 13/12 \rfloor = 2027\). February 2027 has \(L = 28\) days, so the day is \(\min\{30, 28\} = 28\).

References

(International Organization for Standardization, 2019; Microsoft, 2023)

Reconnecting Connection paused Could not reconnect Could not resume Session expired

The connection to the server was lost. Trying to restore it. Next attempt in 0s. The connection was paused. It will resume on its own. The server did not answer. Your work is still here. The paused session could not be resumed. The server could not restore this session. Reloading will start a new one.

An unhandled error has occurred. Reload 🗙