High-frequency data

How data is recorded

∞structural
By . Reviewed 22 October 2026. As of 2026: a permanent feature of the market, not an edge that decays.

Trades, quotes and book updates, each stamped with a sequence number and a clock time. Getting the timestamps and ordering right is the difference between a real backtest and a fiction.

The idea

Anatomy of a tape annotated diagramDG-TAPE
One channel, instrument XYZ – the engine narrating the book seqtypesidepxsizeid 1001ADDbid50.00300A 1002ADDask50.01100B 1003ADDbid49.99400C 1004TRADE50.01100 1005DELETEask50.01100B one engine event – apply atomically row 1004 carries no buyer/seller flag – inferred from printing at the ask Row 1004 decomposed 1004 sequence no. TRADE type 50.01 price 100 size exchange tsgateway tscapture ts venue internalyour transport only exchange ts orders events across instruments Miss one message …1003 → 1005 1004? gap: expected 1004 – phantom ask B never cancels, silently corrupting every later book state Top of book after 1005 – the trade moved the touch bid 50.00 × 300 ask empty until next ADD

What this shows. A tape is just the matching engine narrating itself: typed messages (ADD, TRADE, DELETE), each carrying a sequence number and up to three timestamps. One marketable buy emits two messages that must be applied atomically, and the trade carries no aggressor flag. Miss a single sequence number and a phantom order never cancels, silently corrupting every later state – which is why gap-free capture is the integrity check.

What are the three message types on a tape?

A tape carries trades, quotes and book updates. A trade records an execution, a quote records a change to the best bid or offer, and a book update records an order being added, reduced or cancelled at any price level. Trades tell you what happened; quotes and book updates tell you what was available.

The matching engine (the limit order book) does two things all day: it rests and cancels orders, and it crosses orders into trades. The tape is the engine narrating both, message by message, in the order they happened.

A trade (a "print") gives instrument, price, size, timestamp, a trade ID and often condition codes for auction prints, odd lots or late reports. Most public trade feeds do not say which side was the aggressor, which is the whole problem of trade-sign inference. Some do: Binance's trade stream carries a flag m ("is the buyer the market maker?"). The consolidated equity tapes do not. Nasdaq went the other way: since 14 July 2014 the Buy/Sell indicator on the ITCH 5.0 Trade message is always "B", whichever side was resting (Nasdaq TotalView-ITCH 5.0 specification). A quote is a change at the top of book, the L1 stream. A book update is a change at any level, the L2 and L3 streams, from which quotes and even trades can be derived.

One marketable order can emit several messages at once: a trade print plus the updates that remove the resting orders it consumed. Your handler must apply them as one atomic step.
marketable order  ⟶  { TRADE,  DELETE/MODIFY of the resting orders }\text{marketable order} \;\longrightarrow\; \{\,\text{TRADE},\; \text{DELETE/MODIFY of the resting orders}\,\}

What is the difference between L1, L2 and L3 data?

The levels describe how much of the book a feed exposes. L1 is the top of book: best bid and ask plus the last trade. L2 is aggregated depth per price level (market-by-price). L3 is order by order (market-by-order): each order has its own ID and a place in the queue. Deeper feeds are bigger, and let you rebuild more of the microstructure.

L1 is enough to see the price and useless for modelling depth, queueing or fill probability. L2 usually shows the total resting size at each of the top 5 to 10 levels on each side. It is the standard input for most microstructure work and lets you model walking the book, but you cannot recover where a specific order sits in the queue. L3 gives every order with its ID, price, size and arrival, so the book can be rebuilt deterministically. That is what you need to study queue value and fill probability.

The granularity you can get caps the questions you can ask. Nasdaq TotalView-ITCH is order by order, covering Nasdaq-, NYSE-, NYSE American-, NYSE Arca- and BATS-listed securities traded on Nasdaq, whereas most retail "L2" is aggregated and cannot recover the queue. Most queue-position and fill-probability research quietly assumes a clean L3 tape, and few people hold one.

The same book at three resolutions: L1 shows the touch, L2 the depth per price, L3 the individual orders in queue order. Each level hides what the level above cannot represent.
L1: (pb,qb,pa,qa)  ⊂  L2: {(pk,Qk)}  ⊂  L3: {(id,p,q,seq)}\text{L1: } (p_b, q_b, p_a, q_a) \;\subset\; \text{L2: } \{(p_k, Q_k)\} \;\subset\; \text{L3: } \{(\text{id}, p, q, \text{seq})\}

What are the three timestamps, and why do they differ?

A message can carry up to three timestamps: the exchange (matching-engine) timestamp, the gateway timestamp when it left the venue's edge, and your own capture timestamp. They differ by transmission and queueing delay, and only the exchange stamp orders events across instruments correctly.

The event happens in one clock domain (the engine), crosses wires and gateways (another) and is recorded in yours (a third). Each hop adds delay and jitter, and the stamps bracket where the time went. The engine stamp is the causal clock, so use it for any cross-instrument analysis: lead-lag, or the trade-sign rules that compare a trade to a contemporaneous quote. ITCH 5.0, for instance, stamps each message as a 6-byte count of nanoseconds since midnight. The gap from the gateway stamp to the engine stamp measures the venue's internal latency. The gap from capture to gateway is your own transport latency.

The two gaps between the three stamps split total latency into the venue's internal delay and your transport delay, the latter being exactly what the low-latency stack and colocation exist to shrink.
tgw−texch⏟venue internal  +  tcap−tgw⏟your transport  =  tcap−texch\underbrace{t_{\text{gw}} - t_{\text{exch}}}_{\text{venue internal}} \;+\; \underbrace{t_{\text{cap}} - t_{\text{gw}}}_{\text{your transport}} \;=\; t_{\text{cap}} - t_{\text{exch}}

Serious capture stamps at the network card, disciplined by PTP, rather than in software, because operating-system scheduling jitter is larger than the latency differences you want to measure. A time.time() call in a Python handler cannot support microstructure work. Shrinking the capture gap is the job of the low-latency stack and colocation.

Why does clock synchronisation (PTP) matter?

To order events across machines, venues or instruments, every clock must agree to within microseconds, or you cannot tell which of two near-simultaneous events came first. PTP (IEEE 1588) disciplines clocks to a common reference, usually GPS, and with hardware timestamping reaches sub-microsecond accuracy. NTP is millisecond-class, adequate only for daily-bar work.

The danger is manufactured causality. If two clocks drift by a millisecond, a lead-lag measured at millisecond scale is an artefact of the clocks, not the market. IEEE 1588-2019 is the current edition of the standard: a grandmaster clock distributes time across the network and each hop timestamps in hardware.

Regulators set a floor, and the numbers differ by regime. Commission Delegated Regulation (EU) 2017/574 (RTS 25) requires firms using a high-frequency algorithmic technique to keep clocks within 100 microseconds of UTC, at 1 microsecond granularity or finer. Other electronic trading gets 1 millisecond, and voice trading, request-for-quote systems needing human intervention and negotiated trades get 1 second. Venues must meet 100 microseconds if their gateway-to-gateway latency is 1 millisecond or less, and 1 millisecond otherwise. The US Consolidated Audit Trail sets synchronisation to NIST time: 50 milliseconds for broker-dealers (FINRA Rule 6820, CAT FAQ R1) and 100 microseconds for exchanges and FINRA. Both regimes have been in force since about 2018, and competitive shops run far tighter than either. If you buy or build a tape, timestamp quality matters as much as the prices. A feed with software stamps and an undisciplined clock cannot support microstructure research, however cheap it is.

The synchronisation budget set against the events you want to order: a 100 µs MiFID floor, sub-microsecond PTP in practice, but events arriving microseconds apart inside a burst, so millisecond-class NTP cannot order them at all.
ΔNTP∼1 ms  ≫  ΔMiFID=100 μs  ≫  ΔPTP∼10–100 ns\Delta_{\text{NTP}} \sim 1\,\text{ms} \;\gg\; \Delta_{\text{MiFID}} = 100\,\mu\text{s} \;\gg\; \Delta_{\text{PTP}} \sim 10\text{–}100\,\text{ns}

What are sequence numbers, and why must they be gap-free?

Every message on a feed carries an increasing sequence number so that the receiver can detect a missed or reordered packet: if 1004 arrives after 1002, you lost 1003 and your book is now wrong. Gap detection plus a recovery path is what makes a rebuilt book trustworthy.

Your book is a running total of every increment. Miss one and every later state is silently corrupt, with a phantom order that never cancels or a level that never clears. On Nasdaq, ITCH messages travel inside MoldUDP64 packets. Each packet header carries the sequence number of its first message and a message count, so the receiver knows exactly which numbers to expect next. A gap (seqreceived≠seqexpected\text{seq}_{\text{received}} \neq \text{seq}_{\text{expected}}) means packet loss, which is routine on UDP multicast, and the receiver asks a Re-request Server for the missing range over unicast (MoldUDP64 specification v1.00).

A reconstructed book is the running sum of every applied increment; a single missed sequence number poisons every later state. Detect the gap, recover the missing increment, or the book diverges silently.
Bn=B0+∑k=1nΔk⇒one missing Δk  ⇒  Bm wrong for all m≥kB_n = B_0 + \sum_{k=1}^{n} \Delta_k \qquad\Rightarrow\qquad \text{one missing } \Delta_k \;\Rightarrow\; B_m \text{ wrong for all } m \ge k

There are two recovery routes. With redundant A/B feeds, two identical multicast streams are published, you take whichever copy of each message arrives first and fill gaps in A from B. Alternatively a snapshot or refresh channel lets you fetch a fresh book and replay increments after it. Faithful backtesting needs the same discipline: to simulate fills you must replay the exact message sequence the engine produced, which is only possible if capture is gap-free and sequence-checked. Silent gaps give a backtest that diverges from reality in ways you cannot see (backtesting & simulation).

Snapshots vs increments: how do you reconstruct the book?

Load the latest snapshot, then apply every increment whose sequence number is higher, in order. The snapshot is the full book at an instant and bounds recovery time; the increments carry the live changes. Apply the order wrongly and the book desynchronises.

Think of the snapshot as a save point and the increments as the moves since. Incremental feeds send only changes, so bandwidth follows activity rather than book size. A snapshot service lets a late joiner, or a handler that took a gap, resynchronise without replaying the whole day. Nasdaq offers its GLIMPSE snapshot service for exactly this purpose.

The reconstruction rule: keep the snapshot whose sequence is the latest at or before now, then apply only the increments whose sequence strictly exceeds it. Apply a diff that predates the snapshot and you corrupt the book.
B(t)=snapshots  ⊕  ⨁ seq > sΔseq,s=max⁡{ snapshot seq≤now }B(t) = \text{snapshot}_{s} \;\oplus\; \bigoplus_{\,\text{seq} \,\gt\, s} \Delta_{\text{seq}}, \qquad s = \max\{\,\text{snapshot seq} \le \text{now}\,\}

Crypto venues make you do the handshake yourself, and it is the classic recording bug. Binance's documentation for its USD-M futures order book stream gives the procedure: open the WebSocket and buffer events, fetch a REST depth snapshot with its lastUpdateId, drop any buffered event whose final update ID u is below lastUpdateId, and make sure the first event applied straddles it. After that, each event's pu must equal the previous event's u, otherwise you restart. Quantities are absolute, not deltas, and a quantity of zero removes the level. Skip any step and the book is silently wrong.

Professional feeds follow the same model with order-level messages. ITCH 5.0 is a pure incremental order-by-order feed with Add Order, Order Executed, Order Executed With Price, Order Cancel, Order Delete and Order Replace messages, and OUCH is the matching order-entry protocol. For how those messages look on the wire, see messaging protocols, and read the venue's own specification for the full message set.

Worked example

Here is a fragment of an illustrative tape for instrument XYZ, written in a normalised order-by-order format rather than any one venue's wire format. It is one channel, timestamps in nanoseconds since midnight, and seq\text{seq} increasing. Sequence 1001 adds 300 lots to the bid at 50.00 (order A, the best bid); 1002 adds 100 to the ask at 50.01 (order B, the best ask, so the spread is one tick); 1003 adds 400 to the bid at 49.99 (order C, a level-2 bid). Then a marketable buy arrives: 1004 is a TRADE of 100 at 50.01, and 1005 is a DELETE of order B at 50.01.

The marketable buy produced two messages in this format: the print (1004) and the update removing the resting ask (1005). They share a timestamp because they are one engine event, so apply both atomically. Treat them separately and you briefly show a trade against an offer that is still resting. Native ITCH would not look like this. A fill against a displayed order arrives as a single Order Executed message that names the resting order, and the order is considered dead when its displayed shares reach zero, so no separate delete is sent. Either way the print carries no aggressor flag in the normalised tape. You infer a buyer-initiated trade because it printed at the ask, the quote rule from trade-sign inference.

After the trade and the delete, the touch has moved: the ask is empty until the next ADD, so the top of book is one-sided. The trade did not just print; it consumed the offer.
after seq 1005:bid 50.00×300,ask: empty until next ADD\text{after seq 1005:}\quad \text{bid } 50.00 \times 300, \qquad \text{ask: empty until next ADD}

Now drop a packet. Suppose your capture jumped from seq 1003 to 1005. The gap check (expected 1004, received 1005\text{expected } 1004,\ \text{received } 1005) fires at once and forces a recovery. Without it you would apply the delete of order B but never record the 100-lot trade, so volume would be understated and the last price stale. Had the lost message been 1005 instead, you would be left with a phantom resting ask that never cancels. In both cases every later state inherits the error unless the gap is caught. The numbers here are illustrative. The structure (message types, three timestamps, sequence numbers, snapshot plus increments) holds on every venue; field widths and codes are what you look up in the specification.

Sources

  1. Nasdaq. "Nasdaq TotalView-ITCH 5.0" (feed specification). nasdaqtrader.com
  2. Nasdaq. "MoldUDP64 Protocol Specification", v1.00. nasdaqtrader.com
  3. European Commission. Commission Delegated Regulation (EU) 2017/574 of 7 June 2016 (RTS 25, accuracy of business clocks), Annex, Tables 1 and 2. legislation.gov.uk (retained copy)
  4. FINRA. "Rule 6820. Clock Synchronization". finra.org
  5. CAT NMS Plan. "FAQ R1: Clock Synchronization". catnmsplan.com
  6. IEEE 1588-2019. "IEEE Standard for a Precision Clock Synchronization Protocol for Networked Measurement and Control Systems". standards.ieee.org
  7. Binance. "How to manage a local order book correctly" (USDⓈ-M futures WebSocket market streams). developers.binance.com

Where this fits