Docs menu

Latency

Latency is the time an order spends in transit before it can fill. The setting is one fixed number of milliseconds, applied to every order.

Where to set it

In the Backtester, open Settings and find Fills and fees: Latency (ms). The default is 50, and the field accepts 0 to 5000. A run can override it in the Engine & execution card. In Paper, Settings has Order latency. A change applies to orders placed from then on, and an order already resting keeps the eligibility it was placed with. Live fills are the exchange's, so a live instance has no latency setting.

What it does

  • A resting limit or stop placed at time T cannot fill before T plus the latency. Stop-loss and take-profit brackets wait the same way.
  • With latency above 0, a market order fills at the first market-data event at or after T plus the latency, at that event's price.
  • With latency 0, a market order fills at once at the current price.

By data resolution

  • Tick. Latency has its full effect, because events are single prints.
  • 1s. A latency below one second does not move resting orders. A strategy that only rests orders gives identical results at 0 and at 50 ms. It does move market orders, such as signal exits and flattens: they fill at the next bar's open.
  • 1m. Any value above 0, up to 60 seconds, defers a market order to the next minute's open, and the value itself makes no difference. 1 ms and 50 ms give the same result. Use 0 for 1m work, and 1s or tick data for latency studies.

Exits that are already through the price

When a take-profit or stop is moved to a level that price has already passed, that leg exits at market instead of resting. In a backtest or on paper the exit fills by data type. On tick data it fills at the first trade at or after the decision time plus the latency, at that trade's price. On 1s data it fills at the next bar's open. On 1m data it fills at once. The taker fee applies.

End of data

A market order still waiting after the last market-data event is settled at the last price. Without this a flatten at the end of a day, delayed by latency, would never fill.

Not simulated yet

Latency does not vary from order to order. Every order waits the same time.

Related: Fills and slippage and Limit fills and queue lots.