Skip to content
01TX
Insights

Trading Infrastructure

After a restart: finding orders the bridge lost track of

3 min read

Sooner or later the bridge restarts while orders are in flight. A deployment, a crash, a server reboot. When it comes back, three systems each hold their own idea of what happened: the MT server, the bridge and the LP. Usually they agree. When they don't, you have an orphan, an order that one of them knows about and another doesn't.

The usual cases are easy to describe. The order was sent to the LP and filled while the bridge was down, so the bridge still shows it as sent. The order was accepted on the MT server but the bridge never received it. Or the bridge sent it, the LP never got it, and the book is carrying a position that was never hedged. Each one has a different fix, and guessing which is which is how duplicates and missing hedges happen.

Three lists, one comparison

On startup, before taking new flow, pull the open orders and recent fills from all three places and compare them by order ID. The ID has to travel with the order the whole way, from the MT ticket through the bridge to the client order ID sent to the LP. Without that you end up matching on price and time and hoping.

Mismatches fall into a small number of patterns. If the LP has a fill and the bridge is stuck at sent, take the LP's answer and update the bridge. If the bridge says sent and the LP has no record, the order probably never arrived, but ask for its status explicitly before deciding, since some LPs report slowly. If the MT server has an order that nobody else has, it never made it out, and what to do depends on whether it's still valid.

MT server101filled102filled103filledBridge101filled102sent103no recordLP101filled102filled103no recordCompared by order ID, which has to travel with the order the whole way.102LP filled, bridge stuck at sent. Take the LP's answer, update the bridge.103MT filled, bridge and LP have nothing. Flag it for a person to decide.
IllustrationOrder IDs and states are made up. Each kind of mismatch has its own fix, and the one that would send a new order is left for a person.

Be careful with automatic fixes

Resending an order you think was lost is the dangerous one. If you were wrong, you've doubled the exposure. Reusing the same client order ID helps, because a venue that has already seen it should reject the duplicate, but not every LP behaves that way, and you shouldn't find that out in production.

A sensible split is to apply the safe corrections automatically, such as updating the bridge from a confirmed LP fill, and to put anything that would send new orders in front of a person, with the three records side by side.

Keep the result of every reconciliation, including the ones with no differences. That log is useful the day someone asks whether anything was lost in last night's restart.

It's also worth rehearsing. Kill the bridge on a test setup in the middle of a burst of orders and see what's left over. The cases you find that way tend to be more varied than the ones you would have listed in advance.

Building something that runs into these problems directly?