3 ms·
I work in videogames and I don't know much about stock trading, but in games we often deal with networking problems like who shot first. It sounds like the cen
by Nition 6y ago
I work in videogames and I don't know much about stock trading, but in games we often deal with networking problems like who shot first.
It sounds like the central stock exchange is handling trades in a naive way like this:
T = 0: Client A sends a trade from 200ms away
T = 0.1s: Client B sends a trade from 50ms away
T = 0.2s: Client C sends a trade from 100ms away
T = 0.15s: Client B's trade arrives, process it
T = 0.2s: Client A's trade arrives, process it
T = 0.3s: Client C's trade arrives, process it
What we usually do on a server (lag compensation by rolling back the enemy player's hitbox) won't work here, but I wonder if a version of what's usually called client-side prediction would work. In this case it would be server-side instead:
At T=0.15s, Client B's trade arrives.
It's timestamped as T = 0.1.
We look at all trades since T = 0.1.
There aren't any so we just process it.
At T = 0.2s, Client A's trade arrives.
It's timestamped as T = 0.
We look at all trades since T = 0.
Client B's trade was timestamped T = 0.1.
*Roll back and resimulate all trades since T = 0.*
Trade order is now A, B.
At T = 0.3s, Client C's trade arrives.
It's timestamped as T = 0.2.
No trades since 0.2 so we process it normally.
Trade order is now A, B, C.
Most likely too complex and not actually feasible, just thought I'd mention it. The clocks on the remote clients would need to be synchronised with the central atomic clock so that their timestamps align correctly which might be tricky/impossible due to the extreme accuracy required. You also have to trust the client to not just fake their timestamp down a few ms.
- lucaspauker 6y agoMost (high frequency) firms pay for server space next to the matching engine. Wire length is standardized so you don't have these problems.
- andylynch 6y agoNo- it would not work. exchanges and brokerages care about order of arrival rather than transmission, and for good reason. Anything else would be more complicated and much more open to gaming (the resimulation bit you propose would involve effectively cancelling the last transactions, probably quite frequently, and a huge incentive for at least B and probably C to have ‘inaccurate’ timestamps to get the trade they way at someone else’s expense)