From The Management

Radical drive at FX speed race

15 August 2017 Paul Sweeny, Chief Technology Officer, BidFX

Foreign exchange trading platforms are pitted against each other in a competition to provide best liquidity for their users. It is a race contested under demanding market conditions. The course involves endless high-speed laps comprising:

  • consumption of executable quotes from many sell-side liquidity providers,

  • streaming quotes in real-time from sell-side to buy-side,

  • waiting to receive buy-side order instructions,

  • return delivery of orders for execution before the quote expires.

There are lots of tight twists and turns en route, plus the occasional hairpin, to intensify the challenge. The parallels with motorsport are apt and we can gain invaluable design inspiration from race engineering. To be competitive, teams in either discipline need to understand the impediments to success and apply radical technical solutions to overcome them. The obstacles in forex are as follow.

The race is crowded. FX is the world’s largest financial market, so publication rates are huge. Platforms disseminate billions of price ticks per day. The volume is uneven, with many peaks and dips that build to a crescendo during the overlap of London and New York trading. Traffic is particularly high during news events, such as non-farm payroll, when it can surge tenfold.

We are up against the clock. Quotes are valid only for a limited time. Orders placed against stale prices are routinely rejected at last-look. The lifetime of an executable quote is ephemeral, and grace periods have narrowed over the years from seconds to fractions of a second.

The road is long. FX dealers are clustered in London, New York and Tokyo but the buy-side clients are globally distributed, necessitating lengthy Round-Trip-Times (RTT). We can shave off milliseconds by keeping to the racing line, and selecting the most direct network routes, but the benefits gained are negligible.

Too much weight is carried at the outset. The FIX protocol is the standard for financial information exchange. Most dealers adopt FIX for both transactions and quote streaming, although it is verbose and too bulky for pricing. Exacerbating this problem are additional fields mandated by MiFID-II.

The infrastructure has bottlenecks. TCP is the principal transport layer for FIX. The maximum throughput of a TCP socket is inversely proportional to RTT, irrespective of how much bandwidth is provisioned (long fat pipe problem). It is therefore impractical to drive high-volume FIX traffic over long distances.

FIX pricing is sustainable only over short hops, so it is essential to ride local links. That requires datacentre collocation with the sell-side price engines. Any solution lacking a setup in LD4, NY4 and TK3 will fail to qualify for the main event. To get smartly over the starting line, forgo leased lines and opt instead the gigabit bandwidth and sub-millisecond latency offered by cross-connects.

The speedway is no place for general purpose vehicles. No one would race a Grand Prix in an SUV, and likewise, no one should contest FX with a message bus or text-based format. The professional racer opts for a light-weight, carbon fibre, monocoque chassis around a turbocharged, fuel injected drive system. FX EMS adopt bespoke binary protocols and processes designed specifically for driving FX data. We might be obliged to use FIX connectivity with brokers but we convert FIX to binary straight off of grid. The binary protocol is the powertrain that delivers momentum through the long sections of the circuit.

Precise handling and control are equally essential to attain poll position. Successful teams custom engineer effective software for streamlining message flows. The common publish and subscribe model fails to cut muster in today’s revved-up market as it is prone to overflow during volatile trading, causing congestion and packet collisions. It also lacks the feed-back that EMS Ops need to analyse real world usage. BidFX engineers developed a real-time price synchronisation algorithm that solves these issues. Rather than driving quotes, hammer-down into stationary traffic, it models the live state of the market and continually synchronises its state with clients. The synch frequency is independent of the quote reception rate. The algorithm uses adaptive conflation to fine-tune its handling for each client and to changing load characteristics. Critically, it also provides all of the telemetry that we need to accurately monitor system performance.  

Race drivers slow down and queue as they negotiate a chicane. Messages queue up when there is network congestion. Whereas chicanes are laid intentionally to enhance the enjoyment of the spectacle, data-queues are often the result of bad programming. Queues are amongst the most misused data structures in computing. They are intended to smooth flows to constrained resources, but we often find them sat inappropriately between real-time components. A queue is a time machine. A DeLorean, if you like, with its transmission stuck in reverse, presenting a moving window onto past events. Old quotes have no value to traders and can result in the ultimate race penalty: order rejection. BidFX use queue-free algorithms to reduce lag and improve fill rates.

Car mechanics fine tune engines to boost their power. FX EMS engineers tune data to improve network utilisation. Best throughput is gained by using fewer, larger network packets. To shed load, we strip unnecessary fields, eliminate duplication and compress aggressively. BidFX apply a slipstreaming technique that aids compression. Just as racers reduce drag when bunching up, so do quotes. Packing several quotes in a single structure gives it the properties of a peloton, where the effort exerted by followers is eased by the leaders. The redundancy found in a large pack of competing quotes, for a subset of currency pairs, is considerable and it affords excellent compression. As a measure of the power of this strategy, BidFX price streams use 80 times less bandwidth than equivalent FIX traffic. Eighty times more throughput puts us on the inside line to a top podium spot.

Further gains can be had by running multiple concurrent synchronisations. If the buy-side is in Singapore and the sell-side, 3300 miles away, in Tokyo then the RTT will be near 80ms. If we waited for the packed peloton to complete a full lap before the next resync, then we could only update the trader’s display twelve times per second. Instead, we could run with five equally-spaced packs, giving 60 refreshes per second. Our engine needs plenty of torque to cope with variable conditions. Course length and capacity differ by client, and congestion changes over time. So, we added the flexibility to adjust the resync interval dynamically as needed to ensure all clients see the latest prices refreshing at the highest rate their infrastructure will bear.

These techniques place significantly less load on networks, improve throughput and keep everyone at pace with the market. Consequently, all clients cross the line to take the chequered flag on the BidFX EMS. To see for yourself, buckle up and take us for spin.