Latency Arbitrage Monday February 14th, 2022 – Posted in: Arbitrage Software
The fact that there are so many markets in the world has led to the same Commodities/currencies/metals/cryptocurrencies being traded in many places simultaneously. Distributed bidding is due, for example, to geographical location and time zone differences, or to differences in production/production/production locations. In most cases, due to this variation in trading, the price of the same instrument varies between different trading platforms. If you buy a product at one exchange at one price and sell it at another exchange a little more expensive – this trade is called Latency arbitrage. Ideally, buying and selling happen very quickly. Other names are arbitrage delay and high-frequency trading.
High-frequency trading is considered to have started when the SEC authorized the operation of electronic trading platforms in 1998. In the beginning, high-frequency transactions were conducted in a span of a few seconds, but by 2010 this time had decreased to milliseconds, and sometimes hundreds or tens of microseconds. In the early 2000s, high-frequency trading generated less than 10% of market transactions, but its share has increased over time. According to the NYSE, the volume of trade increased by 2.6 times between 2005 and 2009, and part of the growth was provided by high-frequency traders. At present, Latency arbitrage accounts for more than 80 percent of all trading in financial markets. It is likely that large banks and other financial companies are also engaged in high-frequency trading in addition to traditional trading. As high-frequency trading strategies become more widely adopted, it becomes more difficult to profit from them. Frederi Viens (Purdue University) estimates that the profits from all HFT trading in the United States fell from $5 billion in 2009 to $1.25 billion in 2012. And yet, despite intensifying competition, Latency arbitrage still remains one of the most lucrative forms of earnings in financial markets. There are cases when trading algorithms from this area have not had a single day of losing over the years.
Latency arbitrage is a form of trading in which one player has an advantage over other players by connecting more quickly to a source of quotes. That is, its order sending point is physically closer than the same points of other players.
How it works on your fingers
Suppose two people come to the fruit market and see two peaches sellers. Let’s assume that the price for peaches at the first 20 rubles, at the second 22 rubles. Suppose that peaches are absolutely the same to exclude the choice of goods by quality, which means that buyers will usually first buy peaches for 20 rubles until they are finished and only then go to the seller with the price of peaches for 22 rubles. The first buyer is sent with the intention of buying peaches for 20 rubles. And suddenly, the second buyer runs from the other side ahead of him, quickly buys all the peaches for 20 rubles, and immediately on the spot puts them for sale at the price of 21 rubles for example. Here it is important that the sale price should be greater than the purchase price, but not more than the price of the next seller. If more – the buyer will buy 22 rubles, if less – then where is the profit?
How it works technically
The mechanism is the same – if there is a good price on the market, you need to buy it as quickly as possible to immediately resell at a more expensive price. This is achieved through various technical and geographic devices. Special software and equipment are used to get such a short-term but practically 100% reliable advantage. High requirements for communication networks are also applied. Only the most advanced technologies from the field of fiber are used. And of course, the decisive factor is the location of the equipment for trading. No matter how high-quality and technological it is, the speed of light cannot be overcome, namely with such speed data are transmitted through the cable. In pursuit of profit, financial institutions listed by Forbes enter into costly contracts with stock exchanges to locate their servers in the same building as the exchange’s servers. This is the principle of positioning equipment for trading is called collocation. As such a service may be available to anyone who enters into a contract, it is not uncommon for this to lead to clashes over the equality of conditions for all tenants. For example, the cable length from each participant’s equipment to the exchange servers must be identical for all. No matter if the equipment is located 5 meters from the server or 100 meters away.
The equipment for trading algorithms is used highly specialized, very expensive, not rarely made to order. These chips are typically DMA (direct memory access) and high-frequency chips. Only low-level programming languages such as assembly language are used to write algorithms.
In addition to the cable connection method, there are methods for transferring market data by air. These are usually the special main radio links in the telecommunications world. These private microwave radio networks are stretched for hundreds of kilometers and cost tens of millions of dollars. Used in cases when the exchange – source of quotes is at a considerable distance from the center of trading. In this case, pulling the cable before it is not cost-effective and not effective in the end. The cable will inevitably follow the topology of wells, tunnels, bridges, highways, railways, etc. In this case, the radio relay lines can be built almost in a straight line between the destinations, placing the line nodes on hills or roofs of buildings. As a result, the distance that the signal travels on the cable will inevitably be several times the distance through the radio relay lines elementary because of the landscape. And there are also more routers on this cable path than the radio, and this puts an extra delay on each router.
These microwave radio networks use special radio relay equipment designed to transmit signals with minimal delays. For example, a typical Low Latency radio bridge has a delay of 50 ns (50 nanoseconds), whereas a typical commercial radio bridge has a delay of 1,000 times greater, about 50 μs (microseconds). The throughput of such networks reaches Gigabit per second.
If in the case of co-location in a stock exchange building, the goal is to beat the players trading on the same site using the same source of quotes, the high-speed connection to the remote exchange has a slightly different goal. It is not uncommon for unexpected events to occur in the market, such as an unforeseen decision by the Fed or the ECB, a crash, or unusually high trading performance in other cities and countries. As mentioned above, it is not uncommon for the same instruments to be traded on different exchanges. It is also not uncommon for a tool to be a product of one exchange, and at the same time trading on another. Suppose that Germany’s most important stock index, the DAX, is traded on the Frankfurt Stock Exchange. The London Stock Exchange is also a trading platform. In this case, having a colocation on the London Exchange and a direct radio relay network to the Frankfurt Exchange, it is possible to react faster to the acute events in the German economy.
Latency arbitrage for ordinary people
One can try to profit from this market inefficiency without having a few million in your pocket. From a technical point of view, this possibility is the same. Two terminals need to be modified. Choose two brokers, one main – the source of quotes, the second dependent – the one where the trading orders will be sent. In order for quotation checking and opening to occur instantaneously without the loss of precious milliseconds, the entire system must be implemented in one of the faster, statically typed, and compiled programming languages. For this purpose, such languages as C/C++, Java, C# are suitable. So we get one working system from two terminals with just two brokers and different accounts. It is obvious here that it will not be possible to compete with those who have collocations on the largest stock exchanges, or with those who arbitrate between them. In these markets, high-frequency traders have been working for more than twenty years and have invested tens and even hundreds of millions of dollars in their systems and algorithms. You can’t beat them. You can try your hand at small exchanges, which rarely pay attention to institutional funds, forex brokers, and cryptocurrency exchanges. The two main points are the most important:
Your location and ping from you to the broker
What equipment do you have? If for manual trading even a home computer of average power is suitable, then for other types you need to purchase something fancier.
When optimizing the first point, you need to find out where the server of the broker is, where we will send applications, and rent the server as close as possible to it. It is better to rent a dedicated server, as this ensures that you can use the full capacity of the resources given to you. The difference between a dedicated server and a virtual server is that in the first case you will have direct access to the hardware, and in the second access is through the so-called virtual machine. In the second case, almost all server owners do oversell. That is, let’s say they installed a server with a processor of 50 cores of the processor and 100 GB of RAM. With virtualization software, they cut these resources into 30 virtual servers, each of which is allowed to have 2 cores and 4 GB of RAM. But how is this possible, you ask? After all, it comes out 60 cores and 120 GB of RAM? Virtualization software allows you to do this, and create virtual servers as many as you want. Vendors of this kind of service take advantage of the fact that, as a rule, most of their customers do not load their leased capacity 100%, at least counting on the fact that this happens at least not often. And where someone has underloaded their server, another will have a few resources to run its extra virtual server. In this case, if your software at some point requires the full capacity of the resources allocated to you, they may simply be insufficient, as the sold capacity, in reality, is more than physically available. The program will not hang because of this and in any case, will make a calculation, but will get its power a little later, having released it from someone else, less busy. This way your algorithm can lose valuable time for timely calculation and decision making.
It is further desirable to have direct access to the exchange or API, to both exchanges in case of arbitrage between them. This is typically either the FIX protocol or PLAZA2. If there is no such direct connection, you will have to use trading terminals from a particular exchange, or there will be a combination of one direct access and one terminal. It is not uncommon for a broker to not have an API connection, but have an API to their trading terminal. Each case is individual. The most difficult case is when the exchange has neither a terminal nor an API, but only a web interface for trading. Automation of such trading is more difficult, it will be necessary to parse and automate actions on web pages. And this makes sense only with a fairly significant delay in quotes. If a broker has neither a connection API, an API to its terminal, nor any interaction of trade through the web interface – most likely to automate such trade will not succeed, and it is better to continue searching for a more suitable broker.
Latency Single Exchange Strategy
The point is to place your server as close as possible to the exchange server. Then, taking advantage of the speed, buy bids at the best prices faster than others and resell with little profit. To receive data and send trade orders you can use:
– Trading terminal if it supports trading of automatic algorithms. Many have Vendors of trading software have support for their language for scripting and automated systems. Examples:
- TradeStation – EasyLanguage language
- Quik – QLua language
- Transaq – ATF language
- NinjaTrader – NinjaScript language
- JForex – Java language
You will need to find or purchase software for a specific platform, or pay for the services of a programmer so that he will write you the software for your task for a specific terminal.
– Third-party software designed specifically for Latency arbitrage. It is not rare if a broker provides a direct connection service to the exchange, there are also firms that write the necessary software under one or another kind of connection, or even under a special broker if it is quite popular.
– Self-signed software written and optimized for a special algorithm for your trading strategy. If you are not a programmer, then you will have to hire him for this job.
Latency Inter-Exchange Strategy
Can be divided into 2 more parts:
The first option is to use the quotes of a faster broker and send trading orders to a slower broker. In this case, the trading server is also better located as close as possible to the broker server. We get quotes from the faster ones, compare them with quotes from the slower ones, if there is a big difference – we send a trade order to the slow broker towards the difference between instruments.
We trade on two exchanges simultaneously. In this case, the account is opened at both brokers and the accounts are replenished by the same amount, and the trading server is located somewhere in between. If there is a necessary difference in prices on any instrument on one of the exchanges, where the price is lower – we buy, on the second sell. Depending on the strategy, you can trade in both directions. Once the price is level on both exchanges – you need to buy/sell the asset back. In a while, there will be a difference between the two exchanges’ balance sheets. The total amount of deposits should be greater than the amount of the original deposits, which will speak about the strategy’s profit. With a larger deposit, you need to transfer to an exchange with a smaller deposit so that they become equal again.
Latency Stock Exchange Arbitrage
In this category of brokers, it is difficult to compete in a trade of this kind. The niche has been occupied for quite a long time and has received huge investments. Among the exchanges are the so-called aggregator exchanges. They take quotes from a lot of exchanges and put them together into one glass of bids. At the same time, such exchanges do not combine the applications of their clients with each other but only serve as an intermediary between the client and the exchange, the volume of which the client buys. If you spend a large enough volume on a market in such an exchange – it can be different shares of different brokers. Applying Latency arbitrage to such exchanges is not possible, as trading through it involves inevitable delays and you will lose all advantages.
Latency Forex Arbitrage
About liquidity providers in the forex market
The FX market is decentralized and usually takes its liquidity from the suppliers. There are about two dozen liquidity providers for forex in the world. At the same time, forex brokers may rarely be liquidity providers themselves. That is, a larger broker sells its applications to a smaller broker. In the end, forex brokers may have a completely different composition of suppliers, but to some extent overlapping with the suppliers of other brokers. Let’s say a broker takes liquidity from one supplier, mixes the liquidity of his clients with it, and resells it to the next broker.
However, if the liquidity provider provides an API, it can be used as a faster source versus a smaller broker.
Choosing a broker to trade in the forex market
At the moment, three models of the work of forex brokers are known:
A forex broker takes from some source the prices of quotes instruments, but at the same time act for you as the second part of the transaction, that is, is a market-maker. At the same time your full loss – it’s a full win. Such brokers are famous for not paying money to their clients and for the fact that they like to put sticks in the wheels when trading, in the form of slips, props, etc. It is not rare for such brokers to have a very strange statute in the form of prohibition of peeping, frontrunning, arbitrage, requirements to find in the transaction at least a few minutes, etc.
The broker is completely not a counterparty in transactions with the client and outputs all transactions to the liquidity provider. This option is the most preferred, as the broker is just an intermediary in the transaction and is not interested in your loss. But such brokers are rare because their main income is a small transaction fee. It can be included in the price or charged separately, letting the customers work at the prices of the liquidity provider. At the same time, when the broker makes a deal with the counteragent – he pays him a commission. Since the broker’s commission is a little bigger, that’s what he earns.
A mixed system where a broker brings a part of the transactions to the counterparty, and a part closes itself, being the second party to the transaction. Most “normal” brokers operate under this scheme. Presumably, the transactions of all new clients such brokers initially close themselves. In case they see that the customer mainly wins – his transactions begin to output further on the counterparty. Thus, brokers do not risk being won and do not have to engage in fraud and damage the trading of clients.
The choice of broker should start with the fact that it should be under the jurisdiction of a good financial regulator. At the moment, these are:
- FCA – UK
- BaFin – Germany
- NFA – USA
- FINMA – Switzerland
This is needed to eliminate non-trade risks. In history, there are many cases when a forex broker simply disappeared with all the money of his clients. Then it turned out that its registration is offshore, and the offshore regulator is not responsible for anything. With the above-mentioned controls, the client gets two important things:
- Segregated accounts. The money of clients and the broker are kept in separate accounts. The broker does not have the right to withdraw and appropriate them but can make transactions on your behalf for your money.
- All customer deposits have insurance for a certain amount. In the event of a broker’s bankruptcy, clients will receive a refund on the number of their deposits or on the insurance amount if the deposit amount was greater than it.
- The broker is obliged to have an authorized liquidity provider and does not have the right to act as a second party to the transaction with the client.
These three facts make the broker’s dishonest work meaningless, and the presence of deposit insurance forces the regulator to closely monitor the work of the brokers under its control.
Latency Arbitrage on the Cryptocurrency Exchange
Most cryptocurrency exchanges have web trading and an API connection. Typically, the API is a WebSocket connection for market information and the rest for market information trading functions. The first connection is fast, the second is slow. It is not known why this is so, but it has happened historically. Perhaps cryptocurrency trading is a fairly young industry, and cryptocurrency exchange datacenters have not yet made such a powerful infusion into their trading infrastructure to make quotation and trading algorithms as fast as stock exchanges. The plus is that the API is generally not complex and allows you to create trading algorithms in any programming language.
- Trading on one exchange and having our server as close as possible to the exchange server
- We trade on some two or more exchanges at the same time, creating a deposit on each of them for an equal amount.
In the second case, we cannot use one exchange as faster and the other as slower, because we do not know in advance which of them will be the first to make a difference. In contrast to forex, trading on crypto-exchange is done on their servers, and transactions are not submitted to the counterparties, so we cannot use direct access to the provider as a faster one. In this respect, all cryptocurrency exchanges are equal. But since there are many of them, we can not put 1 trading server with equal ping up to all. So the strategy will have to be used only by a couple of two exchanges. If you want, you can scale the system to the others, but only consider systems from a pair of exchanges with a server in between.