# Point-in-Time Availability Guard

`D01-F04-A05` · Market Data Engineering → Data Quality · archetype `snapshot-evaluate` · difficulty 3/5 · verification **contract**

Full page: https://docs.thefintechbuilder.com/market-data-engineering/data-quality/point-in-time-availability-guard/
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 { asOfSnapshot } from "fintech-algorithms/market-data-engineering/data-quality/point-in-time-availability-guard";
```

## Signature

```ts
asOfSnapshot(records, knowledgeTime, validTime)
```

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

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `records` | `Record[]` | yes | Observations carrying `observation_time`, `available_at` and a `revision`, so restatements are distinguishable from originals. |
| `knowledgeTime` | `string` | yes | ISO 8601 moment to reconstruct. Only records available at or before this instant are eligible. |
| `validTime` | `string` | no | Valid-time cutoff, ISO 8601. Defaults to `knowledgeTime`, which collapses the bitemporal query to a single instant on both axes. |

## 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

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`:

```json
[
  {
    "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`:

```json
"2026-02-01T12:00:00Z"
```

### Call

```ts
asOfSnapshot(records, knowledgeTime, validTime)
```

### Returns

array of 3 objects

```json
[
  {
    "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

`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.

## 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/data-quality/point-in-time-availability-guard/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/market-data-engineering/data-quality/point-in-time-availability-guard/impl.ts
- Standalone repository: https://github.com/IslamBaraka90/Fintech-Point-In-Time-Availability-Guard-Data-Quality-algorithm
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/market-data-engineering/llms.txt
