Demo page

Latency and execution

Entry latency is not an abstract penalty. It can change whether an order joins the queue before a trade, rests too late, or has to cross the spread later.

A latency comparison where zero entry latency fills passively and delayed entry latency later crosses the spread.

Core idea

The same replay can tell two different execution stories.

With zero entry latency, the order reaches the venue before the trade and can fill passively at the bid. With 15 ns of entry latency, the same order misses that queue event, arrives late, and later crosses the spread. The point is the exact event where the execution path diverges.

0 ns Order arrives before the trade and can fill passively.
15 ns Order arrives after the trade and the route changes.
Replay One market path, isolated execution assumptions.

Executable reference

The chart is generated from the demo code.

The visual is not decorative. It comes from the ordersim latency demo fixture, which runs one strategy against one replay while changing only the entry-latency assumption. Read the source.

In depth

Latency changes the path, not the average.

Latency is one of the few execution variables that is genuinely visible — and one of the few that is genuinely misunderstood. The mistake is treating it as a uniform penalty applied to PnL, as if every microsecond of delay subtracted some fixed dollar amount per trade. It doesn't. Latency changes the path. Some trades that would have filled passively now have to cross the spread; some that would have crossed now don't trade at all because the price moved away; some are unchanged, because the relevant event was far enough from the queue that the order's arrival time didn't matter.

The demo on this page is built to make that visible at the level of a single trade event. The market path is fixed. The strategy is fixed. Only entry latency changes. The result is two different execution stories from the same replay — and the divergence shows up at one specific event, not as a smooth degradation.

That framing changes the kind of question latency analysis is. "How much does latency cost?" is the wrong unit. The right unit is "at which events does the execution path actually diverge", because those are the events where the strategy is paying its execution cost. Aggregating over them gives you the dollar figure. Skipping the per-event view gives you a dollar figure that hides the mechanism. For the conceptual half of this, see the Trading Reality essay Execution IS the Strategy; for the simulator that produces the per-event view, see ordersim.

Frequently asked

Questions that come up.

Why isn't latency just a penalty applied to PnL?

Because latency does not change PnL smoothly. It changes whether a specific event — a passive fill, a cancel, a cross — happens at all. Two latency settings can produce nearly identical PnL most of the time and dramatically different outcomes on the few events that matter. Averages hide the mechanism.

What does the latency demo actually run?

One strategy. One real order-book replay. Two latency settings — zero and 15 ns. The simulator replays the market at both latencies, logs every order interaction with the simulated venue, and the visual shows the events where the two execution paths diverge.

Why nanoseconds for the demo?

Because the goal is to show a divergence at a single event, not to claim a realistic colocated latency budget. 15 ns is a teaching number — large enough that the order misses one specific queue event in the chosen replay, small enough that the rest of the trace looks identical. Real latency budgets are usually larger; the framing is the same.

Does latency affect every strategy the same way?

No. A strategy that mostly rests passive orders is dominated by queue effects, and small latency increases can push fills from passive to crossing. A strategy that mostly crosses already pays the spread; for it, latency mostly changes which prints it catches. The mechanism is the same; the elasticity is not.

Where do I start reading?

Run the demo first — it is small. Then read the simulation-assumptions document for what the simulator does and does not model. The Trading Reality essay Execution IS the Strategy gives the conceptual frame for why the divergence matters.