Linear Quote Interpolation
Install and import
npm install fintech-algorithmsimport { linearQuoteInterpolation } from "fintech-algorithms/market-data-engineering/time-synchronization/linear-quote-interpolation";Signature
linearQuoteInterpolation(quotes, targets, maxGapMs)Interpolates between the quotes either side of a target time. More accurate than carrying forward, and **not causal** — it uses a quote from after the target, so it belongs in research and never in a live path.
Parameters
| Name | Type | Notes |
|---|---|---|
quotes | Quote[] | Quotes with event_time, available_time, bid and ask. |
targets | Target[] | Times to interpolate at, each with the evaluation time that bounds what may be used. |
maxGapMs | number | Widest gap between bracketing quotes that may still be interpolated across. min: 0 |
Returns
Sample[] · length same-as-input
One sample per target with both bracketing quotes, the interpolated value, and whether the gap budget was met.
Errors
- When maxGapMs is negative — throws
Complexity: time O(n + m),
space O(m).
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
[
{
"instrument": "A",
"venue": "X",
"session_id": "S",
"event_time": "2026-01-01T00:00:00.000Z",
"available_time": "2026-01-01T00:00:00.100Z",
"bid": 99,
"ask": 101
},
{
"instrument": "A",
"venue": "X",
"session_id": "S",
"event_time": "2026-01-01T00:00:02.000Z",
"available_time": "2026-01-01T00:00:02.120Z",
"bid": 101,
"ask": 103
}
][
{
"instrument": "A",
"venue": "X",
"session_id": "S",
"target_time": "2026-01-01T00:00:01.000Z",
"evaluation_time": "2026-01-01T00:00:01.000Z"
},
{
"instrument": "A",
"venue": "X",
"session_id": "S",
"target_time": "2026-01-01T00:00:01.000Z",
"evaluation_time": "2026-01-01T00:00:02.120Z"
},
{
"instrument": "A",
"venue": "X",
"session_id": "S",
"target_time": "2026-01-01T00:00:00.000Z",
"evaluation_time": "2026-01-01T00:00:00.000Z"
}
]Showing 3 of 5 elements.
2000Call
linearQuoteInterpolation(quotes, targets, maxGapMs)Returns
array of 5 objects
[
{
"instrument": "A",
"venue": "X",
"session_id": "S",
"target_time": "2026-01-01T00:00:01.000Z",
"evaluation_time": "2026-01-01T00:00:01.000Z",
"bid": null,
"ask": null,
"status": "right_not_available",
"reason": "right_endpoint_arrives_after_evaluation",
"interpolated": false,
"observable": false,
"left_event_time": "2026-01-01T00:00:00.000Z",
"right_event_time": "2026-01-01T00:00:02.000Z",
"left_available_time": "2026-01-01T00:00:00.100Z"
},
{
"instrument": "A",
"venue": "X",
"session_id": "S",
"target_time": "2026-01-01T00:00:01.000Z",
"evaluation_time": "2026-01-01T00:00:02.120Z",
"bid": 100,
"ask": 102,
"status": "linear",
"reason": "both_endpoints_available",
"interpolated": true,
"observable": false,
"left_event_time": "2026-01-01T00:00:00.000Z",
"right_event_time": "2026-01-01T00:00:02.000Z",
"left_available_time": "2026-01-01T00:00:00.100Z"
},
{
"instrument": "A",
"venue": "X",
"session_id": "S",
"target_time": "2026-01-01T00:00:00.000Z",
"evaluation_time": "2026-01-01T00:00:00.000Z",
"bid": null,
"ask": null,
"status": "exact_not_available",
"reason": "exact_record_arrives_after_evaluation",
"interpolated": false,
"observable": false,
"left_event_time": "2026-01-01T00:00:00.000Z",
"right_event_time": "2026-01-01T00:00:00.000Z",
"left_available_time": "2026-01-01T00:00:00.100Z"
}
]Showing 3 of 5 elements.
Diagrams
Calculation flow
Interpolation eligibility and knowledge boundary
flowchart LR
A["Target plus evaluation cutoff"] --> B{"Exact event?"}
B -->|Yes| C{"Exact record available?"}
C -->|No| D["exact_not_available"]
C -->|Yes| E["exact observed quote"]
B -->|No| F{"Same-partition bracket?"}
F -->|No| G["unavailable; no extrapolation"]
F -->|Yes| H{"Gap within inclusive limit?"}
H -->|No| I["gap_too_wide"]
H -->|Yes| J{"Both endpoints available?"}
J -->|No| K["block at knowledge boundary"]
J -->|Yes| L["linear derived quote; observable=false"]
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
- NIST Digital Library of Mathematical Functions, Section 3.3 — National Institute of Standards and Technology
- SEC Quote Life Report Methodology — U.S. Securities and Exchange Commission, Division of Economic and Risk Analysis
- Frequently Asked Questions: Rule 605 of Regulation NMS — U.S. Securities and Exchange Commission staff
- On covariance estimation of non-synchronously observed diffusion processes — Takaki Hayashi and Nakahiro Yoshida
- RFC 3339: Date and Time on the Internet — IETF; Graham Klyne and Chris Newman
- Evidence classification