How is latency measured in high-frequency trading?

The latency of a process is measured by gathering timestamps reflecting the times at which the cause (e.g. price update) and effect (e.g. order placement) occur, and subtracting them. The two primary sources of timestamps that are used to measure latency in HFT are software instrumentation and network capture. Other more exotic timestamping mechanisms have been used, but none has proven as effective or accurate.

In practice, latency is measured by collecting not just a single pair of timestamps for an individual process, but a continuous stream of timestamps of all processes taking place. The stream of timestamped events must be filtered and individual causes must be correctly matched to their corresponding effects using unique identifiers extracted from the captured software events or network packets. This extraction is an especially challenging task in the case of packets because of the speed of network data and the complexity and huge variety of encodings and protocols used.

An understanding of the details of the message formats (whether captured on the network or via software instrumentation) is essential for reliable matching of effects to causes. For example, measuring the latency of the order cancelation process requires knowing the message-types of the requests and responses, and how orders are uniquely identified within those messages.

Knowledge of the business processes is also critical to deriving meaningful latency measurements. For example, the latency of the order cancelation process might be measured from the sending of a order-cancel instruction to receipt of the corresponding cancel-pending response, or to receipt of the cancel-confirmation. The former might be relevant for assessing network round-trip times, while the latter is required to understand how quickly open positions can be adjusted.