fintech-algorithms

Point-in-Time Availability Guard

Install and import

bash
npm install fintech-algorithms
ts
import { asOfSnapshot } from "fintech-algorithms/market-data-engineering/data-quality/point-in-time-availability-guard";

Signature

asOfSnapshot(records, knowledgeTime)

Reconstructs what was actually knowable at a given moment, using each record's available_at rather than its observation_time. This is the guard that stops a backtest reading a figure hours before it was published.

Parameters

NameTypeNotes
recordsRecord[]Observations carrying observation_time, available_at and a revision, so restatements are distinguishable from originals.
knowledgeTimestringISO 8601 moment to reconstruct. Only records available at or before this instant are eligible.

Returns

Record[] · length fewer

The latest revision of each entity/feature that had actually been published by the knowledge time.

Errors

  • When knowledgeTime is not a valid ISO 8601 timestamp — throws

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

Worked example

executed 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

records
[
  {
    "entity": "ALFA",
    "feature": "weekly_metric",
    "observation_time": "2026-01-02T00:00:00Z",
    "available_at": "2026-01-04T14:00:00Z",
    "revision": 0,
    "value": 10,
    "record_id": "ALFA-00-r0"
  },
  {
    "entity": "ALFA",
    "feature": "weekly_metric",
    "observation_time": "2026-01-02T00:00:00Z",
    "available_at": "2026-01-11T14:00:00Z",
    "revision": 1,
    "value": 10.07,
    "record_id": "ALFA-00-r1"
  },
  {
    "entity": "ALFA",
    "feature": "weekly_metric",
    "observation_time": "2026-01-02T00:00:00Z",
    "available_at": "2026-01-30T14:00:00Z",
    "revision": 2,
    "value": 10.14,
    "record_id": "ALFA-00-r2"
  }
]

Showing 3 of 180 elements.

knowledgeTime
"2026-02-01T12:00:00Z"

Call

asOfSnapshot(records, knowledgeTime)

Returns

array of 3 objects

[
  {
    "entity": "ALFA",
    "feature": "weekly_metric",
    "observation_time": "2026-01-23T00:00:00Z",
    "available_at": "2026-01-25T14:00:00Z",
    "revision": 0,
    "value": 10.75,
    "record_id": "ALFA-03-r0"
  },
  {
    "entity": "BETA",
    "feature": "weekly_metric",
    "observation_time": "2026-01-23T00:00:00Z",
    "available_at": "2026-01-25T15:00:00Z",
    "revision": 0,
    "value": 13.75,
    "record_id": "BETA-03-r0"
  },
  {
    "entity": "GAMM",
    "feature": "weekly_metric",
    "observation_time": "2026-01-23T00:00:00Z",
    "available_at": "2026-01-25T16:00:00Z",
    "revision": 0,
    "value": 16.75,
    "record_id": "GAMM-03-r0"
  }
]

Other exports

This module also exports leakageAudit. 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.

Diagrams

Point-in-Time Availability Guard — article hero
Point-in-Time Availability Guard — availability timeline

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