Skip to content
All library documents

Correcting Timestamp Latency and Ordering Market Events

Code Stratmill research code

Summary

This document describes preprocessing checks for event data that records both exchange timestamps and local receipt timestamps. One routine detects when the local clock appears ahead of the exchange clock, then shifts local timestamps by the largest observed negative latency plus a configurable base latency. This is intended to avoid negative measured feed delays while accounting for clock differences.

A second routine reconciles event streams sorted separately by exchange and local time. It merges the orderings, marks events associated with each timeline, and duplicates records when the two timelines imply different event order. A validator then checks that exchange-marked and locally marked events are each nondecreasing in their respective timestamps. These procedures are useful for market-data preparation and replay, but the document does not provide empirical accuracy tests. Timestamp shifting assumes a single offset inferred from the observed minimum latency; clock drift, outliers, and the selected base latency can affect the result, so the corrected data still requires scrutiny.

Key ideas

  • Local timestamps can be shifted to eliminate negative exchange-to-local latency observations.
  • A configurable base latency can be added to the correction offset.
  • Events can be merged across exchange-time and local-time orderings, with records split when the order differs.
  • Validation separately checks monotonic timestamps for exchange and local events.
  • The correction depends on an observed minimum latency and does not establish that all clock errors are resolved.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.