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 ultra‑fast alpha often stems from a subtle timing mismatch that most traders discover only after a strategy has produced spectacular back‑test results. In a high‑frequency environment the exchange, the gateway and the local infrastructure each apply their own clock to every event – market data, order acknowledgement, execution report – and those clocks rarely sit perfectly in sync. When the timestamps that are stored in a research database are taken at face value, the analyst implicitly assumes a single, trustworthy chronology. In practice the chronology is a patchwork of micro‑second marks that can be ahead or behind by tens or even hundreds of micro‑seconds. The result is a fabricated lead‑lag relationship: a trade appears to have been executed before the price move that supposedly caused it, when in fact the price information arrived first but was recorded later.
The problem is not merely academic. A strategy that seems to predict a price swing by 50 µs will look flawless in simulation, yet in live trading the same logic will be chasing a market that has already moved. The discrepancy is amplified when the strategy relies on sub‑millisecond decision windows, as is typical for market‑making, statistical arbitrage or latency‑arbitrage desks. The root cause is the lack of a single, calibrated time base that all components respect.
To understand the magnitude of the issue, consider that modern exchange feeds are timestamped at the source to within a few micro‑seconds, but the gateway that forwards the packets to the trader’s server may introduce an additional, variable delay of up to 150 µs because of network queuing. The trader’s own timestamp, taken at the moment the packet is placed on the inbound socket buffer, may be offset further by the operating system’s clock drift. When these three timestamps are merged without correction, the resulting event log is a collage that can mislead any statistical analysis.

How the mechanism works, step by step
First, the exchange timestamps each quote and each trade at the moment it is generated in the matching engine. Those timestamps travel embedded in the binary protocol and are the most reliable reference, provided the exchange’s internal clock is disciplined by a GPS or atomic source. Second, the gateway – often a co‑located server or a network appliance – receives the packet, records a receive timestamp, and forwards the payload to the trader’s application. The gateway may also generate correction messages if it detects out‑of‑order delivery or duplicate packets, and it typically includes a sequence number that increments monotonically.
Third, the trader’s application records a local timestamp the instant the packet is dequeued from the socket buffer. This timestamp is used for latency measurement, order routing decisions and, crucially, for back‑testing. If the three timestamps are stored side‑by‑side but never reconciled, the analyst will later assume that the local timestamp represents the moment the market information became known, which is false when the gateway timestamp is earlier.
Fourth, the order flow follows a parallel path. An order placed by the algorithm receives a local timestamp at the moment the API call is issued, a gateway timestamp when the order is transmitted, and an exchange timestamp when the order is accepted or rejected. The fill report again carries three timestamps. If any of those clocks drift, the apparent fill latency can be under‑ or over‑estimated, and the strategy’s performance metrics become biased.
Finally, the system must handle correction messages that indicate a prior packet was delayed or duplicated. Without preserving the original sequence numbers and applying the corrections, the event log will contain out‑of‑order entries that further corrupt the perceived causality.
A worked example with real numbers
Suppose a prop‑trading desk is testing a micro‑price‑prediction model on a futures contract. The model triggers a buy order when the bid‑ask spread narrows below 0.2 ticks. In the historical feed the following timestamps are recorded:
– Exchange quote update: 12:00:00.123456 UTC, price 10 500, spread 0.2 ticks. – Exchange trade: 12:00:00.123470 UTC, size 100 contracts, price 10 500.5. – Gateway receive timestamp for the quote: 12:00:00.123520 UTC. – Local receive timestamp for the quote: 12:00:00.123560 UTC.
The algorithm, using the local timestamp, believes the quote arrived at 12:00:00.123560 and the trade at 12:00:00.123470, thus concluding that the trade preceded the quote. The back‑test therefore records a profitable entry at the trade price, followed by a favourable price move.
In reality the gateway received the quote 64 µs after the exchange generated it, while the trade packet arrived at the gateway only 10 µs after the exchange timestamp. Because the local timestamp for the quote is later than the trade’s exchange timestamp, the apparent causality is inverted. If the desk had aligned all events to the exchange clock, the model would have seen the quote first, recognised that the spread had already widened, and refrained from trading – the apparent alpha would vanish.
The distortion is amplified when the strategy’s decision latency is 30 µs. The erroneous ordering gives a fictitious 20 µs advantage, which translates into a 0.3 % edge on a 100 k contract position, enough to mislead a risk manager into allocating excessive capital.
Where it breaks in live markets
When the strategy is deployed, the same mis‑alignment manifests as missed fills, stale orders and unexpected slippage. The algorithm may submit an order based on a quote it believes is current, but the exchange has already moved beyond that price because the quote arrived later than the trade that shifted the market. The order is then either rejected or executed at an unfavourable price, eroding the theoretical profit.
Furthermore, the problem compounds during periods of high traffic, such as macro‑data releases or market‑open bursts. Network congestion increases gateway queuing, widening the offset between exchange and local timestamps. Clock drift becomes more pronounced when the operating system’s NTP discipline is insufficiently aggressive, leading to offsets of several hundred micro‑seconds over a trading day. In such environments the tail of the latency distribution – the worst‑case delays – dominates performance, not the median latency that many back‑tests report.
The risk is not limited to a single instrument. Multi‑asset strategies that cross‑reference order books across venues rely heavily on the relative timing of disparate feeds. If one feed’s timestamps are consistently earlier, the strategy will systematically favour that venue, creating a spurious arbitrage that disappears as soon as the timing bias is corrected.
The operating path, stage by stage
The first stage is timestamp acquisition. The exchange timestamp is captured from the protocol header and stored as the authoritative “source time”. The gateway timestamp is recorded on packet ingress, preferably using a hardware‑timestamping NIC that can tag each packet with a sub‑microsecond counter tied to a disciplined clock. The third stage is the local timestamp, taken by the application immediately after the packet is dequeued, using a high‑resolution timer that is synchronised to the same reference as the gateway.
The second stage is clock synchronisation. All three components must share a common time base, typically a GPS‑disciplined oscillator or a Precision Time Protocol (PTP) grandmaster. The system continuously monitors offset and drift by exchanging timing packets and applying a Kalman filter to estimate the instantaneous skew. Adjustments are applied in software to align the local timestamps to the exchange clock before they are persisted.
The third stage is sequence management. Each packet carries a monotonically increasing sequence number; the gateway also forwards any correction messages that indicate a missing or duplicate packet. The data ingestion pipeline must preserve the original order, flag out‑of‑order arrivals, and re‑inject corrected packets at the appropriate logical position in the event stream.
The final stage is persistence. The database schema stores the three timestamps in separate columns, together with the sequence number and a flag indicating whether the record has been corrected. This design enables downstream analytics to reconstruct the true chronology by selecting the exchange timestamp as the ground truth while still having the local and gateway times for latency diagnostics.

Controls that act before the damage
A robust control framework begins with hardware. Deploy network interface cards that support IEEE 1588 PTP hardware timestamping, and lock the server’s CPU clock to the same grandmaster as the gateway. Use a dedicated time‑synchronisation daemon that logs offset, jitter and drift every second, raising an alarm if the offset exceeds 20 µs for more than ten consecutive seconds.
At the software level, implement a timestamp‑normalisation layer that, before any event is written to the research database, adjusts the local timestamp by the measured offset and applies a drift correction based on the latest NTP/PTP statistics. The layer must also verify that the sequence number of each incoming packet is exactly one greater than the previous; any gap triggers a request for a retransmission or a flag for manual review.
Operationally, run a synthetic‑traffic generator that injects out‑of‑order and duplicate messages at controlled rates. The system should detect these anomalies, re‑order them correctly, and record the correction events. Regular regression tests compare the reconstructed event stream against a golden reference generated from a known‑good clock source.
Finally, enforce a policy that any strategy back‑test must include a “clock‑alignment audit” step. The audit reports the distribution of exchange‑to‑local offsets, the frequency of correction messages and the proportion of events that required re‑ordering. If any metric exceeds pre‑defined thresholds, the back‑test is rejected until the data pipeline is remedied.

How to measure whether it is working
Measurement begins with the offset histogram. Plot the difference between exchange timestamps and local timestamps for a high‑frequency instrument over a full trading day. The median should be near zero, but the critical insight is the tail: the 99.9th percentile must stay within the latency budget of the strategy, typically under 100 µs.
Next, evaluate the drift curve. Compute the cumulative offset drift over time; a flat line indicates a stable synchronisation, while any slope suggests the local clock is diverging and must be re‑calibrated.
Sequence integrity is assessed by counting the number of correction messages per million packets. A healthy pipeline will have fewer than one correction per million, and the proportion of out‑of‑order events should be negligible.
Finally, run a “known‑future” test: insert a synthetic price move into the feed at a predetermined exchange timestamp, and verify that the local timestamps of the preceding quote updates are all earlier than the synthetic move after normalisation. Any violation indicates residual mis‑alignment.
The portfolio view
When the timing infrastructure is sound, the portfolio’s performance attribution becomes reliable. The realised P&L can be decomposed into genuine alpha, execution slippage and latency‑induced decay. Tail‑latency events, such as occasional spikes beyond the 99.9th percentile, appear as isolated loss outliers rather than systematic profit.
Conversely, if the timestamps are mis‑aligned, the attribution will falsely credit the strategy with predictive power that never materialises in live trading. The portfolio may show an inflated Sharpe ratio, a deceptively low turnover, and an understated drawdown, all of which mislead capital allocation decisions.
A disciplined risk framework, inspired by the principle that risk should be inferred from the full distribution of returns rather than a single realised outcome, insists on examining the entire latency distribution. Median latency is insufficient; the analysis must include the probability of extreme delays, the frequency of stale orders and the loss distribution when cancellations are delayed or routed incorrectly. Only then can the desk judge whether the strategy’s edge survives the rigours of the market’s micro‑second reality.
The portfolio view
In practice, the desk should integrate the timing diagnostics into the daily risk dashboard, allowing traders to see at a glance whether any component of the clock chain has drifted out of tolerance and to take corrective action before a mis‑aligned back‑test influences capital deployment.

The portfolio view
By maintaining separate timestamps, continuously monitoring clock health, preserving sequence fidelity and rigorously testing for out‑of‑order or duplicate events, a prop‑trading desk can prevent bad timestamps from fabricating illusory HFT alpha. The effort required is modest compared with the cost of chasing phantom profits that evaporate once the data pipeline is corrected.
Do you have a process in place to verify that the timestamps you rely on truly reflect the moment information became available to your algorithm?
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.