Selecting the Lowest-Latency Order Gateway from TCP Measurements
Summary
The document considers how a colocated trading system can choose among exchange order-entry gateways whose delays vary over time. It proposes using TCP round-trip time as an observable proxy for gateway delay, then estimating each gateway’s near-term latency from its history. Candidate estimators include a rolling mean or median with a dispersion measure, an exponential moving average, or a stochastic delay model that predicts future round-trip times; the system can select the gateway with the lowest estimated delay. It also recommends probing gateways regularly so that one unusually slow observation does not keep a gateway excluded indefinitely.
These are suggestions rather than a tested comparison: the document provides no empirical results showing which estimator works best. The proxy relies on assumptions about how gateway delay relates to other components of round-trip time, including independence across delays. Those assumptions may be too strong, and actual delay may also depend on order size or prior gateway usage. The appropriate sampling and prediction method therefore depends on how representative TCP measurements are of order-entry latency in the system being traded.
Key ideas
- TCP round-trip time can serve as an observable proxy for gateway order-entry delay.
- Historical rolling averages, medians, or exponential averages can estimate each gateway’s changing latency.
- A stochastic delay model can be used to forecast round-trip times and select the gateway with the lowest predicted delay.
- Regularly probing every gateway helps prevent a temporary delay spike from excluding it indefinitely.
- Proxy quality depends on assumptions about independent delay components and how latency responds to order size and prior usage.
Tags
Full text
# Mitigating gateway delay
# Mitigating gateway delay
A trading system has $n$ colocated uplinks to TCP order entry gateways $g_1, \dots, g_n$ on a given exchange. Each gateway $g_i$ has a different order entry delay function $d_i(t)$ as a function of time $t$. (Note that I don't explicitly know the $d_i(t)$.)
The game is to build a sample function $S(t)$ which picks a gateway $g_i$ minimising order entry delay at time $t$.
What realtime statistical tests can be applied to the gateways to build a good sampling function $S$? (With TCP, it's easy to measure round-trip times since every message is ACKed.)
## Answer by Walter (score 3, accepted)
https://quant.stackexchange.com/a/9424
If I understand correctly the TCP roundtrip time can be used as a posteriori proxi for the order entry gateway delay.
So assuming the roundtrip time is composed of gate delay and independent other delays $RTT_g(t) = dT_g(t) + d_g(t)$ with assumed $Cov(dT_g,d_g)=0$ and $Cov(d_i,d_j)=0$. Minimizing the this combination of gate delay and other delays is leading to the same goal.
Perhaps a univariate modeling of this $RTT_g(t)$ based on historical observed observations is suitable. Could be that a simple rolling mean/median and (robust) dispersion metric is enough?
I found this http://www.eecis.udel.edu/~bohacek/Papers/paper579.pdf paper about video streaming and congestion. They estimate a Cox-Ingersoll-Ross model (https://en.wikipedia.org/wiki/Cox%E2%80%93Ingersoll%E2%80%93Ross_model) to estimate and predict delays.
$dRTT_g = a (b-RTT_g)dt+\sigma\sqrt{RTT_g}dW_t$ with $dW_t$ brownian.
for this CIR there exist close form solutions for predictions which are chi-square family. so something like $S(t)=\text{argmin}_g \hat{RTT_g}(t+1)$
Note that i dont know if these gateway independence assumptions are not too strong, and i wonder if the gateway delay is not also a function of e.g. ordersize or previous usage. Good luck!
## Answer by Svisstack (score 0)
https://quant.stackexchange.com/a/9405
I think just picking minimum value for $d_i(t)$ will work optimal here, just how calculate that $d()$ function matters more, this can be last order delay from that gateway or some EMA of last X order delays. Important is query each gateway every some amount of time to prevent blocking gateway by one big anomaly delay that prevent $S(t)$ function from selecting that gateway in future. $$ S(t) = g(\operatorname{argmin}_g d_g(t)) $$Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.