# Exchange-Calendar Alignment

`D01-F03-A04` · Market Data Engineering → Time Synchronization · archetype `row-classify` · difficulty 3/5 · verification **contract**

Full page: https://docs.thefintechbuilder.com/market-data-engineering/time-synchronization/exchange-calendar-alignment/
Agent skill: `npx skills add IslamBaraka90/Fintech-Algorithms-Library` — https://docs.thefintechbuilder.com/guides/agent-skill/

## Install and import

```bash
npm install fintech-algorithms
```

```ts
import { validateCalendar } from "fintech-algorithms/market-data-engineering/time-synchronization/exchange-calendar-alignment";
```

## Signature

```ts
validateCalendar(bundle)
```

Validates a trading-calendar bundle before anything is aligned to it: that sessions do not overlap, that closures are consistent with sessions, and that the licence terms permitting redistribution are present.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `bundle` | `{ license, calendar, sessions, closed_dates }` | yes | The calendar under test together with its licence metadata. Calendars are usually licensed data, which is why the licence block is part of the contract rather than an afterthought. |

## Returns

`void`

Returns nothing on success. Validation is a gate, not a transform — the value of calling it is the failure.

## Errors

- When sessions overlap or are out of order — throws
- When a closed date contradicts a defined session — throws
- When required licence metadata is missing — throws

## Complexity

Time `O(n log n)`, space `O(n)`.

## Worked example

Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

### Input

`bundle`:

```json
{
  "license": "CC0-1.0 teaching transcription; contains calendar facts, not market data",
  "calendar": {
    "calendar_id": "nyse-tape-a-core-teaching",
    "calendar_version": "2026-07-22",
    "retrieved_at": "2026-07-22",
    "venue": "New York Stock Exchange",
    "market": "NYSE Tape A core equities",
    "time_zone": "America/New_York",
    "tzdb_version": "2026c",
    "boundary": "[open, close)",
    "outside_coverage": "fail_closed",
    "local_time_policy": "reject_nonexistent_require_fold_for_ambiguous",
    "opening_auction_policy": "include_at_open",
    "closing_auction_policy": "exclude_at_close",
    "extended_hours_policy": "exclude",
    "supported_dates": [
      "2018-12-05",
      "2025-03-07",
      "2025-03-10",
      "2025-07-03",
      "2025-07-04",
      "2026-07-03"
    ]
  },
  "sessions": [
    {
      "session_id": "XNYS-2025-03-07-CORE",
      "session_date": "2025-03-07",
      "local_open": "2025-03-07T09:30:00",
      "local_close": "2025-03-07T16:00:00",
      "open": "2025-03-07T14:30:00.000Z",
      "close": "2025-03-07T21:00:00.000Z",
      "session_type": "regular",
      "source_ids": ["R03", "R04"]
    },
    {
      "session_id": "XNYS-2025-03-10-CORE",
      "session_date": "2025-03-10",
      "local_open": "2025-03-10T09:30:00",
      "local_close": "2025-03-10T16:00:00",
      "open": "2025-03-10T13:30:00.000Z",
      "close": "2025-03-10T20:00:00.000Z",
      "session_type": "regular",
      "source_ids": ["R03", "R04"]
    },
    {
      "session_id": "XNYS-2025-07-03-CORE",
      "session_date": "2025-07-03",
      "local_open": "2025-07-03T09:30:00",
      "local_close": "2025-07-03T13:00:00",
      "open": "2025-07-03T13:30:00.000Z",
      "close": "2025-07-03T17:00:00.000Z",
      "session_type": "early_close",
      "source_ids": ["R02", "R03", "R04"]
    }
  ],
  "closed_dates": [
    {
      "session_date": "2018-12-05",
      "closure_type": "exceptional_closure",
      "reason": "National Day of Mourning for President George H. W. Bush",
      "source_ids": ["R05"]
    },
    {
      "session_date": "2025-07-04",
      "closure_type": "holiday",
      "reason": "Independence Day",
      "source_ids": ["R02", "R03"]
    },
    {
      "session_date": "2026-07-03",
      "closure_type": "holiday",
      "reason": "Independence Day observed",
      "source_ids": ["R01"]
    }
  ]
}
```

### Call

```ts
validateCalendar(bundle)
```

### Returns

undefined

```json
undefined
```

## Other exports

`localWallToUtc`, `alignEvents`, `sessionGrid`. Every module additionally exports `run` as an alias of its primary
function, and a `meta` object carrying its catalog id, domain, family, shape and article URL.

## Verification and provenance

Tier: **contract**.

The module loads, the entry point is callable and its declared signature matches the compiled code. The example below is real captured output, but no independently published figure asserts the numbers.

Both tiers guarantee the signature. Full explanation: https://docs.thefintechbuilder.com/guides/verification/

Generated from the docs.json payload shipped inside fintech-algorithms@0.13.1.
The signature and parameter list are checked against the compiled implementation at build time,
so a description that contradicts the code fails the build rather than reaching this file.

## Links

- Article (how it works, step by step): https://thefintechbuilder.com/market-data-engineering/time-synchronization/exchange-calendar-alignment/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/market-data-engineering/time-synchronization/exchange-calendar-alignment/impl.ts
- Standalone repository: https://github.com/IslamBaraka90/Fintech-Exchange-Calendar-Alignment-Time-Synchronization-algorithm
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/market-data-engineering/llms.txt
