Point-in-Time Availability Guard
Install and import
npm install fintech-algorithmsimport { 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
| Name | Type | Notes |
|---|---|---|
records | Record[] | Observations carrying observation_time, available_at and a revision, so restatements are distinguishable from originals. |
knowledgeTime | string | ISO 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
[
{
"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.
"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
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.
References
- Apple 2024 third-quarter Form 10-Q filing detail — U.S. Securities and Exchange Commission; filer Apple Inc.
- Apple Form 10-Q for the period ended 2024-06-29 — Apple Inc.; filed with the U.S. Securities and Exchange Commission
- Webmaster Frequently Asked Questions — U.S. Securities and Exchange Commission
- EDGAR Application Programming Interfaces — U.S. Securities and Exchange Commission
- Attach and Submit a Filing Through the EDGAR Filing Website — U.S. Securities and Exchange Commission
- FRED Series Vintage Dates — Federal Reserve Bank of St. Louis