fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

Time Order, Frequency, Regularity, and Financial Calendars

Install and import#

bash
npm install fintech-algorithms
ts
import { timeOrderFrequencyRegularityAndFinancialCalendars } from "fintech-algorithms/foundations/financial-time-series-foundations/time-order-frequency-regularity-and-financial-calendars";

Signature#

timeOrderFrequencyRegularityAndFinancialCalendars(input)

Checks whether a timestamped series runs in chronological order and whether its observations are evenly spaced, reporting the common spacing in seconds when there is one.

Parameters#

NameTypeNotes
inputD00InputReads timestamps, a list of parseable date-time strings, and values, a non-empty list of finite numbers of the same length. Only the timestamps drive this calculation; the values supply the count.

Returns#

D00Output

ordered is true when no timestamp precedes the one before it, regular is true when every consecutive gap is identical, observations is the series length, and frequencySeconds is that common gap in seconds or null when the spacing varies.

Errors#

  • When values is absent, empty, or holds a non-finite number — throws RangeError
  • When timestamps and values have different lengths — throws RangeError
  • When the series holds fewer than two observations — throws RangeError

Complexity: time O(n), space O(n).

Worked example#

verified This is the worked example published in the article, replayed by the test suite on every run. The output cannot drift.

Input#

input
{
  "timestamps": [
    "2025-01-01T00:00:00Z",
    "2025-01-02T00:00:00Z",
    "2025-01-03T00:00:00Z",
    "2025-01-04T00:00:00Z",
    "2025-01-05T00:00:00Z",
    "2025-01-06T00:00:00Z"
  ],
  "values": [100, 102, 101, 104, 106, 105],
  "lag": 1,
  "window": 3,
  "resampleSize": 2,
  "period": 3,
  "stationarityTolerance": 3,
  "alpha": 0.4,
  "splitIndex": 4
}

Call#

timeOrderFrequencyRegularityAndFinancialCalendars(input)

Returns#

object with 2 fields: ordered, regular

{
  "ordered": true,
  "regular": true
}

Diagrams#

Time Order, Frequency, Regularity, and Financial Calendars — article hero
Time Order, Frequency, Regularity, and Financial Calendars — calculation ledger
Time Order, Frequency, Regularity, and Financial Calendars — concept anatomy
Time Order, Frequency, Regularity, and Financial Calendars — failure boundary
Time Order, Frequency, Regularity, and Financial Calendars — method map
Time Order, Frequency, Regularity, and Financial Calendars — scenario contrast

How it works#

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References#

The rest of the Financial Time-Series Foundations family#