Latency-Optimised High-Frequency Financial Trading with VPP

Industry Focus

Introduction

High-frequency trading, or HFT, refers to a type of algorithmic trading that uses systems to execute trades in financial markets at extremely high frequency. In general, trades are quick, and the level of profit gained largely depends on the speed at which the trade is entered and exited. The asset being traded may range from stocks to commodities, with an increasing focus on cryptocurrency markets. 

Latency Optimised HFT

In high-frequency trading, milliseconds can make a big difference in the outcome of a trade. An electronic trading system with low latency can identify a trading opportunity and execute a trade faster than a competing system with high latency. Low latency transaction processing can give trading systems a significant advantage in fast-moving markets.

Additionally, high-frequency trading relies on the system’s ability to process and analyse large amounts of market data quickly. Low latency systems are better equipped to handle this workload and can help trading systems make more accurate predictions in identifying patterns in the market by reacting to changes in market data more efficiently.

Optimising the latency performance of a high-frequency trading application can help gain a significant edge over the competition, and therefore help maximise potential trading profits.

Financial Trading Application Overview

To understand how the latency performance of high-frequency trading applications can be optimised, it is important to understand how these applications function and how they are deployed.

Data Aquisition

Data is typically acquired by the trading application through application programming interfaces, or APIs. These APIs are hosted by financial exchanges and market data providers. The data may include information such as asset prices, order book data and news feeds. This information is critical in decision making on what trades to take. The faster that data is obtained, the more responsive the application can be to changes in this data. Maximising network packet throughput and minimising latency are therefore important goals when acquiring market data.

Data Processing

The acquired data is processed in real-time by the trading application using complex software algorithms to identify potential trading opportunities. The speed at which a decision is made is tied directly to the efficiency of the data processing algorithms. For that reason, data processing can become a critical application bottleneck. Software optimisation of these algorithms is important to improve overall application latency.

Trade Execution

Trades are executed by the trading application through APIs hosted by the financial trading exchanges. Minimising the network latency between the trading application and the API is key to ensure that trades are entered and exited at the desired price. Any delay in placing a trade may result in price movement therefore impacting the profitability of the trade.

Application Deployment

Financial trading applications are generally deployed in the Cloud using Cloud providers such as Amazon AWS or Microsoft Azure. This is not only cost effective but ensures 24-hour execution and availability of the application. By deploying to a cloud-based server, system resources as well as location can be tightly controlled.

Methods to Reduce Latency

There are a number of methods that can be employed in order to reduce latency in high-frequency trading systems.

Co-location of Trading Servers

Co-locating your trading applications with the financial exchange’s systems can have a significant impact on reducing latency. This is because the distance that data has to travel is greatly reduced, resulting in faster transmission times. For example, if an exchange is known to have their API server located in a specific region, simply deploying the high-frequency trading system to a server located in the same region will reduce latency.

Network Optimisation

Network latency can be a significant bottleneck for high-frequency trading applications. Whilst upgrading network infrastructure such as network switches, routers, and cables can help to reduce latency, it is often not an option nor the appropriate option. A bottleneck that is commonly overlooked is the software network stack used by the trading application to interface with the financial exchange’s APIs. When high-frequency trading applications are deployed on Linux-based environments, the standard configuration is to use the Linux Kernel TCP/IP network stack. This configuration is known to have performance limitations impacting network throughput and latency.

fdio vpp latency optimisation

At Netadvia, we specialise in high-performance network technologies that provide a balance of throughput and latency, depending on the required use-case. The Vectorised Packet Processor, or VPP, provided by the FD.io project, provides a highly optimised and efficient software network stack that can be deployed on any Linux-based system. VPP uses the Data Plane Development Kit, or DPDK, to interface with network hardware in a highly optimised way, ensuring that packets are read from, and written to the network as efficiently as possible. VPP also uses Intel AVX and SSE instructions to maximise network packet processing throughput where multiple packets can be handled at any time in parallel.

We have worked with a number of clients to reduce the network latency of their applications by switching to VPP’s network stack and achieved a reduction in latency of up to 90% over the Linux Kernel’s network stack, specifically when interfacing with trading server APIs using TCP/IP connections.

Algorithmic Optimisation

Algorithmic optimisation can also help reduce latency by allowing high-frequency trading applications to perform more calculations in parallel and by reducing the number of steps required to process data. Using techniques such as multi-threading or parallel processing can help reduce latency by allowing the application to process data on multiple cores or CPUs at the same time.

banner_code_servers

At Netadvia, we are experts in the optimisation of software algorithms, specifically when applications are deployed on Intel hardware. Careful attention is paid to the management of available resources, such as CPU cycles, CPU cache and system memory, to ensure that applications not only perform as quickly as possible, but also in a highly deterministic manner. We specialise in processing network packets extremely efficiently by taking advantage of Intel AVX (Xeon) and Intel SSE (Atom) instructions, depending on the CPU architecture on which the application is deployed.

Hardware Optimisation

Using faster CPUs, memory, and storage can help reduce latency by allowing your systems to process and store data efficiently. Additionally, using specialized hardware such as field-programmable gate arrays (FPGAs) or application-specific integrated circuits (ASICs) can help reduce latency by allowing the application to perform complex calculations and data processing in hardware, rather than software.

High-Performance Network Applications - Intel Architecture

At Netadvia, we have experience in identifying the best performing hardware options for a specific use-case. However, we believe that maximising the utilisation of existing system resources, especially network stack software, in an intelligent manner is much more beneficial. This means that often hardware upgrades are not required, therefore saving on overall costs.

Summary

High-frequency trading is a highly specialised industry where latency performance of a trading application is critical in entering or exiting a trade at the optimal price point. In order to minimise the combined latency of a high-frequency trading application, improvements in both network latency and application latency must be considered.

For network latency, a key bottleneck is the chosen network stack software. Integrating with VPP’s optimised network stack provides significant improvement in latency performance over the Linux Kernel network stack. For application latency, the core improvements in latency performance are observed through the optimisation of software algorithms maximising use of system resources.

At Netadvia, we are highly experienced network throughput and latency software experts. If you believe we can assist in giving you the performance edge in this highly competitive industry, please contact us.