What Is Latency in Trading?

Latency is the time between something happening and a system reacting to it. A price changes on an exchange; how long until a trader’s screen shows it? An order is sent; how long until the exchange receives it?

In everyday apps, latency is measured in milliseconds, and anything under a tenth of a second feels instant. In trading systems it’s measured in microseconds (millionths of a second), and at the fastest firms in nanoseconds. To put that in perspective: light in an optical fibre travels about 200 kilometres per millisecond, or roughly 1 kilometre every 5 microseconds. At this level, the length of a cable matters.

Where It Comes From

Every hop on the way adds some delay:

  • Distance. The physical path between two machines. Nothing can make light go faster, so the only fix is a shorter path.
  • Network equipment. Every switch and router reads and forwards each packet.
  • The operating system. In a normal server, each message passes through the kernel’s network stack, and the program waits to be woken up. Ways to reduce this range from epoll and io_uring to kernel bypass (Onload, ef_vi, DPDK), where the program reads the network card directly. How each of these works: From Blocking Sockets to FPGAs.
  • The software. Decoding, copying, memory allocation, locks, cache misses, garbage-collection pauses.
  • Queues. When messages arrive faster than they’re handled, they wait. This is the delay that suddenly explodes on a busy day.

Tail Latency: The Average Hides the Problem

A system can average 10 microseconds and still be slow when it matters. What hurts is the tail: the slowest 1% or 0.1% of messages, written p99 and p99.9. Those slow messages tend to come exactly when the market is busiest, because that’s when queues build up. Variation in latency is called jitter, and in trading, predictable is often worth more than fast-on-average.

On a quiet day, almost any system is fast. The test is the busiest minute of the year.

How Latency Affects Trading and HFT

  • Old prices. A trader who sees a price late is acting on information that has already changed. A market maker whose quotes update late can be traded against at prices it no longer wants.
  • Place in the queue. Exchanges fill orders at the same price first come, first served. Arrive a few microseconds later and you’re further back in the line.
  • Arbitrage. When the same thing trades in two places, the first firm to see a price gap can close it. The prize goes to whoever is fastest.

For someone buying shares on a phone app, these microseconds don’t decide anything meaningful: your order is checked by your broker and matched by the same rules as everyone else’s. Latency matters most to firms whose whole business is reacting first: high-frequency trading (HFT) firms and market makers.

How Exchanges Keep It Fair

An exchange can’t make everyone equally fast. What it can do is make sure the exchange itself doesn’t give anyone an unfair head start.

  • Colocation with equal cables. Exchanges rent rack space next to their own servers. Firms that pay for it get the same cable length to the matching engine, even if their rack is closer, so nobody wins by standing nearer the door.
  • One sequence, one rule. Every order is stamped and processed in the order it arrived, by the same price-then-time rules, one at a time. The matching engine is deterministic: the same orders in the same sequence always give the same trades.
  • Market data sent to everyone at once. Exchanges publish price updates by multicast: one packet, copied by the network to every subscriber at the same moment. Sending to each subscriber one after another over separate connections would mean someone is always first. How a price travels from the exchange to your app is in How Market Data Reaches Your Screen.
  • Two copies of every feed. Market data usually goes out twice, on separate “A” and “B” lines. A receiver takes whichever copy arrives first, and if a message is lost on both, it asks a retransmission service for it, or rebuilds the state from a snapshot.
  • Accurate clocks. Exchanges and trading firms keep their clocks in step, often to within microseconds, so that every event can be timestamped and the sequence checked afterwards. In Europe, MiFID II requires high-frequency traders to keep clocks within 100 microseconds of UTC.
  • Speed bumps. Some venues add a small, deliberate delay. The US exchange IEX famously routes orders through a coil of fibre that adds about 350 microseconds, so the fastest firms can’t react to price changes before the exchange itself has.

Getting this wrong has consequences. In India, the regulator SEBI found that the way NSE’s tick-by-tick data was distributed over individual connections had let some members receive it earlier than others. The case led to regulatory action and years of appeals. Fair distribution is a design decision, not an accident.

From Inside an Exchange

At the New York Stock Exchange I worked on market data systems, where the target was measured end to end in tens of microseconds, and a missing or out-of-order message wasn’t allowed. What I learned there still holds: you can’t improve what you don’t measure, the slow tail matters more than the average, and fairness comes from design, not luck.

For Engineers: Where to Start

  1. Measure first. Timestamp each message as it arrives and as it leaves, ideally on the network card, and track p99 and p99.9, not just the average.
  2. Remove the big pauses: memory allocation on the hot path, locks, and garbage collection.
  3. Pin and isolate. Give the critical threads their own CPU cores, and let them poll instead of sleep.
  4. Then choose the network path. epoll is fine for most systems; io_uring for heavy throughput; kernel bypass when microseconds matter.
  5. Test on the busiest day. Replay a recording of your heaviest real traffic, faster than real time, and watch the tail.

This article explains how the systems work. It is not financial or investment advice, and limits and rules change: check the current ones with SEBI, your broker or the exchange.