Bad timestamps can invent HFT alpha

0
25

XCore HFT / Trading Lab

Bad timestamps can invent HFT alpha

Quantitative execution, market-microstructure, and risk-control research from XTRSK.

What this problem really is

The illusion of micro‑second precision is a well‑known trap for high‑frequency developers. A strategy that appears to earn a tidy profit in back‑test may be exploiting a timing artefact rather than a genuine market inefficiency. The artefact originates when the timestamps attached to market data, order acknowledgements and execution reports are taken from different clocks that drift, offset, or are simply mis‑aligned. In such a world the “when” of an event is ambiguous: the exchange may have recorded a trade at 09:30:00.123456 UTC, the gateway may have logged the corresponding quote update a few microseconds later on a local clock, and the trader’s own receive timestamp may be earlier still because of a network path that happens to be faster at that instant. When the back‑test aligns everything on the local receive time, the algorithm is effectively being fed information that, in reality, was not yet available to the market. The result is a spurious alpha that evaporates the moment the system is deployed in production.

The problem is not merely academic. Modern prop desks often run multiple co‑located servers, each with its own NTP or PTP synchronisation chain. Even a sub‑microsecond offset can be enough to invert the causal order of a trade and the quote that should have preceded it. When the back‑test assumes a single, flawless clock, the statistical distribution of returns is distorted: the median latency looks acceptable, but the tail of the latency distribution is fattened by hidden out‑of‑order events. The strategy therefore passes a risk‑review that looks solid on paper while harbouring a hidden exposure to stale‑order execution and unexpected slippage.

The core thesis, therefore, is that micro‑second analysis is unreliable whenever feeds, orders and fills are not aligned to a trustworthy clock. The only defensible way to evaluate a fast strategy is to treat timestamps as a proxy for “when the information became knowable” rather than “when it was later recorded”. This subtle shift forces the developer to store exchange, gateway and local receive timestamps separately, to monitor clock offset and drift continuously, and to preserve the sequence numbers and correction messages that the exchange sends when it discovers that an earlier packet arrived out of order. Only then can the back‑test faithfully reproduce the information set that would have been available to a real trader.

Bad timestamps can invent HFT alpha: mechanism
Figure 1. How the components of this idea connect

How the mechanism works, step by step

The first step is to capture three distinct timestamps for every market event: the exchange‑generated timestamp (often embedded in the protocol header), the gateway‑arrival timestamp (the moment the data reaches the co‑location switch or the market data handler), and the local‑receive timestamp (the instant the processing thread reads the packet). The exchange timestamp is the ground truth for when the market actually changed; the gateway timestamp tells us how long the network took to deliver the packet; the local timestamp is what the strategy sees and therefore drives the decision logic.

Next, the system must maintain a continuous estimate of clock offset between the local machine and the exchange’s reference clock. This is typically achieved by a two‑way timestamp exchange (e.g., PTP Sync messages) that yields both offset and drift. The offset is subtracted from each local‑receive timestamp to produce a “corrected” timestamp that can be compared directly with the exchange timestamp. If the drift exceeds a pre‑defined threshold (for example 5 µs per second), the synchronisation source is flagged and a fallback source is engaged.

Finally, the processing pipeline must respect the sequence numbers that accompany each message. When a packet arrives with a sequence number lower than the highest seen so far, the engine must hold it in a re‑order buffer until the missing messages arrive or a timeout expires, at which point a correction message is applied. Duplicate packets are discarded after confirming that they carry the same sequence identifier and checksum. By enforcing this discipline, the system guarantees that the logical order of events mirrors the order in which the exchange generated them, irrespective of network jitter.

A worked example with real numbers

Consider a simple market‑making algorithm that places a limit buy order at the best bid and cancels it if the mid‑price moves more than 0.5 ticks within the next 200 µs. On a particular day the exchange sends a trade message (TradeID = 101) at 09:30:00.123456 UTC, indicating a price of 10 000.00 and a size of 100 lots. The same exchange publishes a quote update (QuoteID = 55) at 09:30:00.123460 UTC, moving the ask from 10 000.02 to 10 000.04.

The gateway receives the trade packet at 09:30:00.123458 UTC (local clock) and the quote packet at 09:30:00.123462 UTC. The local machine, however, is ahead of the exchange by 2 µs because its NTP daemon has not yet compensated for a recent network change. Consequently, the local‑receive timestamps recorded by the algorithm are 09:30:00.123460 for the trade and 09:30:00.123464 for the quote. When the back‑test aligns events on the local timestamps, the trade appears to precede the quote by 4 µs. The algorithm therefore decides to place a buy order, believing the market has not yet moved.

In reality, the quote arrived at the exchange 4 µs before the trade, meaning the best bid had already shifted upwards. The order would have been submitted into a stale price level and likely cancelled immediately, incurring a round‑trip cost. The back‑test, oblivious to the 2 µs clock offset, records a profitable fill at 10 000.00, while the live execution would have been a loss or a wash. The error is amplified when the strategy aggregates many such micro‑seconds; the apparent Sharpe ratio in the back‑test can be inflated by 30 % purely because of the timestamp mis‑alignment.

If the system had stored the three timestamps separately, applied the 2 µs offset correction, and respected the sequence numbers, the corrected timestamps would have shown the quote at 09:30:00.123458 (exchange time) and the trade at 09:30:00.123462, correctly ordering the events and preventing the spurious order placement. The example demonstrates how a seemingly negligible timing discrepancy can manufacture alpha that vanishes in production.

The same idea on a live price series
Figure 2. Real intraday FX candles from the trading feed Data: live FX feed.

Where it breaks in live markets

In a live environment the synchronisation chain is constantly challenged by network congestion, hardware interrupts and occasional loss of PTP packets. When a switch experiences a brief overload, the gateway may drop a few micro‑seconds of latency, causing a trade to be received earlier than the quote that actually preceded it. The back‑test, which assumes a stable offset, will then attribute causality to the wrong side of the market.

Another failure mode occurs when the exchange issues a correction message after detecting an out‑of‑order delivery. If the processing engine discards the correction because it arrived after the strategy has already acted, the recorded state of the order book diverges from the true state. The algorithm may then believe it has a favourable price level when, in fact, the market has moved. This divergence can persist for several milliseconds, enough for a high‑frequency strategy to accumulate a sizeable position based on stale data.

Finally, the problem is exacerbated in multi‑venue arbitrage. Each venue runs its own clock, and the latency between them is not symmetric. When the back‑test aligns the timestamps on a single local clock, it implicitly assumes that the cross‑venue latency is constant and that the clocks are perfectly synchronised. In reality, a 10 µs drift on one venue combined with a 15 µs drift on another can invert the perceived price relationship, leading to arbitrage signals that never materialise in the market.

The operating path, stage by stage

The first stage is the data‑capture layer, where raw packets from the exchange are ingested. Here the gateway timestamp is attached, and the packet is handed to a timestamp normalisation module that applies the latest offset estimate. The second stage is the sequencing buffer, which holds messages out of order and re‑assembles them according to their sequence numbers, emitting correction messages when gaps are filled. The third stage is the market‑state builder, which merges the corrected, ordered stream of trades and quotes into a coherent order‑book snapshot, tagging each update with both the exchange timestamp and the corrected local timestamp.

The fourth stage is the strategy engine, which consumes the market‑state snapshots. It must query the “information‑available‑time” – the later of the exchange timestamp and the corrected local timestamp – to decide whether a signal is admissible. The fifth stage is the order‑routing module, which stamps each outbound order with a local send timestamp, records the expected exchange receipt time based on the current offset, and logs the order ID together with the originating market‑state snapshot. The final stage is the post‑trade reconciler, which matches execution reports to the original order, adjusts for any latency drift observed during the round‑trip, and updates the performance database with both the exchange and local timestamps for each fill.

At each hand‑off the system logs the offset used, the sequence numbers processed, and any correction messages applied. This audit trail is essential for later forensic analysis when an unexpected loss occurs; it allows the analyst to reconstruct precisely which timestamp was used at every decision point.

Execution and control path
Figure 3. Where the decision is made, checked and confirmed

Controls that act before the damage

A robust defence against invented alpha begins with a disciplined clock‑management policy. The primary control is a continuous offset‑monitoring daemon that raises an alarm if the measured drift exceeds a tight bound – for example 1 µs over a five‑minute window. When the alarm triggers, the trading engine automatically pauses new order submissions until the synchronisation source is verified or a secondary source is engaged.

Secondary controls involve the sequencing buffer. By enforcing a maximum re‑order latency of, say, 20 µs, the system guarantees that any out‑of‑order packet will be either reordered or dropped before it can influence a decision. The buffer also logs every correction message; a downstream quality‑control process scans these logs for spikes that could indicate a network issue or an exchange‑side timestamp problem.

A third line of defence is the “knowledge‑time” filter in the strategy engine. Before any signal is acted upon, the engine checks that the corrected local timestamp does not precede the exchange timestamp of the latest quote. If it does, the signal is discarded as potentially based on future information. This simple rule eliminates the class of false‑positive signals that arise from a trade packet arriving before its associated quote due to clock skew.

Together, these controls form a ladder of protection: clock health monitoring, strict sequencing, and knowledge‑time validation. Each rung catches a different failure mode, and the combination ensures that the back‑test and the live system are operating on the same, trustworthy information set.

Control ladder
Figure 4. Warn, reduce, stop — decided before the pressure arrives

How to measure whether it is working

Measurement begins with a latency‑distribution audit. The system records the raw interval between exchange timestamp and corrected local timestamp for every trade and quote. The distribution is then summarised by median, 95th percentile and the extreme tail (99.9th percentile). A healthy system shows a tight cluster around the median with a tail that does not exceed the pre‑defined latency budget (for example 150 µs).

The next metric is the out‑of‑order rate. By counting the number of correction messages per million packets, the team can gauge whether the sequencing buffer is being stressed. A rate above a few parts per million signals a possible network or clock issue that warrants investigation.

A third indicator is the stale‑order frequency. This is the proportion of orders that were cancelled because the market state had already moved beyond the price level at the moment of order submission, as inferred from the corrected timestamps. A rising stale‑order rate, especially in the tail of the latency distribution, points to a breakdown in the knowledge‑time filter.

Finally, a back‑test‑vs‑live consistency check is performed regularly. The same historical data set is replayed using the live‑system’s recorded offsets and sequence‑handling logic; the resulting P&L curve is compared to the original back‑test. Divergence beyond a small tolerance (e.g., 0.2 % of cumulative returns) triggers a review of the timestamp handling pipeline. These quantitative checks together confirm that the controls described earlier are functioning as intended.

The portfolio view

When the timestamp discipline is enforced across all strategies, the portfolio’s risk profile becomes more transparent. Tail latency, which previously manifested as occasional large slippages, now appears as a measurable component of the loss distribution. The median latency, while still useful for capacity planning, no longer dominates the risk assessment.

Because each strategy records both exchange and corrected local timestamps, the risk team can aggregate the “information‑lag” exposure across the desk. If several market‑making bots share the same gateway, a common offset drift will be reflected as a correlated increase in their stale‑order frequencies. This correlation can be modelled as a factor in the portfolio VaR calculation, providing a more realistic estimate of capital at risk during a synchronisation failure.

Moreover, the audit trail of sequence numbers and correction messages enables a post‑mortem attribution of any unexpected loss to a specific timing anomaly. The desk can then decide whether to tighten the latency budget, upgrade the clock infrastructure, or adjust the strategy’s knowledge‑time filter. In this way, the discipline of trustworthy timestamps transforms a hidden source of alpha into a visible risk factor that can be managed, hedged, or eliminated according to the firm’s risk appetite.

Do you have a process in place to verify that the timestamps driving your live decisions truly reflect the moment the market information became available?


About the research behind this lesson

Andrew Lo's lectures build risk analysis from return distributions and statistical measures, rather than treating one realised result as a complete description of risk.

Applied to this lesson: For a fast strategy, median latency or average fill quality is not enough. The review has to include tail delays, stale-order frequency and the loss distribution when cancellation or routing behaves abnormally.


Two live systems, one desk

PULSE-X — power-packed HFT: high-frequency momentum on XAUUSD and EURUSD. System details · Live account

NIC-X — ultra-low drawdown: displaced-print arbitrage for large capital. System details · Live account

Start now: leave your email and request a free trial — we will send the pricing, the connection route and the trial terms. Pricing

Join the market discussion: Telegram @squawklive

Source: Risk and Return

Educational content only. Trading leveraged products involves risk.

Chat with XTRSK

Chat ready

Start a chat and the XTRSK team will be notified immediately.

LEAVE A REPLY

Please enter your comment!
Please enter your name here