Saturday 7 July 2012

Low Latency Arms Race

Electronic exchanges and algorithmic trading have made low latency a big business. At all levels servers, switches, network, OS, applications etc there is a race to achieve lower and lower latencies.  A 1-millisecond advantage in trading applications can be worth $100 million a year to a major brokerage firm(ref). This was an estimate in 2007. In 2012 people are talking in terms of microseconds and nanoseconds.
For same trading strategy, market and instrument, competing algotrading software in two trading firms, the firm that gets the market data first and executes its order first in the market will beat the other firm in trading profits. 
Not all financial IT products require ultra low latencies, for example back office products for fees calculations etc no one cares about latencies, while front office products like market gateways have very "low latency" reqirements. The latency requirements for a product is derived from the business context.


Even for the front office products requirements for institutional investors and high frequency trading are quite different. For long term investment  to create a large position institutional invester may choose to use algorithmic trading to break large orders into small trades but here instead of market orders, limit orders will be used to buy at desired price. Order is late or fast does not matter much.

In the middle are short term manual traders. Minimum human reaction time to read a market depth and click a trade is between 100 - 250 milliseconds. So a normal trader will not try to aggress market opportunities that vanish in milliseconds but will trade on strategies that will be from minute to hours to a day to multiple days. So 1 millisecond here or there is not a big deal 

At the other extreme high frequency trading(HFT) is all about speed. HFT employs computerized algorithms to analyze incoming market data and implement proprietary trading strategies. High-frequency traders compete on a basis of speed with other high-frequency traders. By 2010 high-frequency trading accounted for over 70% of equity trades in the US (ref). One of the HFT strategy is to exploit arbitraging price discrepancies in some particular security trading simultaneously in different markets. This requires ultra low latencies and between the competing firms one with the lowest latency will win.

"Trading mostly with their owners money,they scoop up hundreds or thousands of shares in one transaction,only to offload them less than a second later before buying more.They can move millions of shares around in minutes,earning a 10th of a penny off each share.As a group,they earned $12.9 billion in profit in the past two years,according to the TABB Group,a specialist on the markets.TABB expects their earnings to slow this year as Wall Streets big brokerage firms fight back with their own faster computerised trading" NY Times 10 Oct 2011

With these kind of stakes there are big budgets and many buyers for low latency products.

Two important latencies are market data latency and order to market latency. The market data latency includes time from event in exchange till data is available to algotrading software or visible to human on trading GUI. This will include latencies on wire(exchange to trading center), latencies of internet gateway, latencies of switches/hub, latencies of router. At software level latencies of middleware, OS context switches, protocol libraries like FIX, TCP latencies etc will come into picture. 

Distance between algorithmic trading server and market exchange is a very important factor. There is roughly a delay of 5 microseconds per KM in fiber optic cable. If trading center is 200 km away 1 millisecond delay will be added to latencies
Co-Location is used to solve this problem.Trading firms can place computers containing their trading algorithms in special data centers close to or in the exchange. CME Co-Location Services is one example of Co-Location provided by exchange. 

Providing lower latency is a much bigger challenge than providing higher throughput. Over past few decades the bandwidth and size of RAM has increased exponentially but the latencies of RAM have decreased linearly. Even for very high end servers and fast RAM the latencies of memory access is 30 to 100 nanoseconds.Low latency requirements are nearly approaching hardware limits.

Quoting Kevin Slavin

"It takes you 500,000 microseconds just to click a mouse. But if you’re a Wall Street algorithm and you’re five microseconds behind, you’re a loser."