How to Build a Quantitative HFT Forex-Shop

How to Build a Quantitative HFT Forex-Shop

Introduction

Building a Quant HFT on the forex market could be much more challenging than with other markets. Why? Because of the fragmentation, the need for high-quality data sources you will need, and the cost involved in the overall operation.

Of course, all those challenges can be offset by the number of different trading opportunities you can find on the forex markets.

In this article, I want to go through all the pieces to build a successful quantitative high-frequency trading shop in the forex market and all the best practice recommendations.

Prime Brokerage (PB)

Foreign exchange prime brokerage (PB) allows a client to source liquidity from a variety of executing dealers while maintaining a credit relationship, placing collateral, and settling with a single entity: the prime broker.

The advantages of using PBs are endless in the forex market. Allows using margins more efficiently, positions can be netted (even if they are between multiple counterparties). In addition, traders can access pricing and liquidity from a greater number of sources, improving the execution quality.

Some of FX Prime Brokerages:

· Deutsche Bank FX Prime Brokerage (FXPB) https://corporates.db.com/solutions/investment-bank-solutions/Foreign-exchange/fx-prime-brokerage

· Saxo Bank https://www.home.saxo/institutional-and-partners/solutions/fx-prime-brokerage

· FXCM Pro https://www.fxcmpro.com/prime/

· IS Prime https://www.isprimefx.com/en/

Hardware

Collocation

The “arms race” in this area never stops, with market players continuously investing in more powerful solutions that can trade securities, derivatives, and other financial instruments in a matter of nanoseconds. Only HFT firms that are always at the forefront of technology will be able to stay ahead in the future.

The fragmentation of the foreign exchange markets means that connectivity solutions are critical to the success of trading operations, and colocation services, where specialist service providers host traders’ servers as close as possible to matching engines, are critical for this type of operation.

Depending on where your data services and ECN’s are located, you can collocate your hardware next to them. The most important centers are New York (NY4), London (LD4), Tokyo (TY3), Singapore (SG3)

Server

Choosing the right hardware is the most important piece. This is where your trading system will reside and operate. These servers will run at their highest capacity, usually running at maximum CPU clock frequency, so they must have a very good cooling system to ensure massive airflow and cool down their internal components.

Another key part when choosing these servers is how many CPU cores must have. Depending on how your trading system has been designed, it could need to have dedicated CPU cores for certain processes. The bigger the trading system, the more CPU cores you will need. The usual is that it must have at least 8 CPU cores (i.e.: Server Intel Xenon (or any x-86 based) with more than 12 cores & 32Gb of RAM)

Additionally, the configuration needs to be as reliable as possible, with these characteristics:

· High Availability: automatic fault detection with 24×7 network monitoring. Must have 100% up-time guarantee.

· Elimination of single points of failure and automatic failovers.

Network Cards

Now that you have the physical place to put your server next to the ECNs, you need to choose your network devices to directly connect to them (cross-connection).

High-frequency trading in the forex market (just like any other market) is characterized by having microbursts (short time periods, typically nanoseconds). These may cause packet delays or even drop. For these reasons, the design of the network is to oversize the bandwidth, to minimize the possibility of overflowing the buffer capacity.

SolarFlare has led the market in accelerating server-side networking for electronic trading and is the leader when trying to reduce network latencies by providing the best NIC cards. They provide a wide range of specialized NICs to have the best connectivity possible.

Cross connection available in Forex

Now that the hardware is there, you and your Prime Broker need to decide to whom to connect. The offer in the forex market is endless but these are some of the best ECNs + platforms + sources:

Euronext | Currenex | FXCM | 360T | Integral | CBOE | PrimeXM | Saxo Bank | LMAX | FastMatch | FXAll

Specialized hardware: FPGAs

Due to the need to further decrease latencies, designing application-specific hardware accelerators started to gain more attention in the HFT domain, especially FPGA-based accelerators due to their flexibility and re-programmability. FPGA-based systems proved to achieve under nanoseconds latency, often with more deterministic response times.

Usually, you use FPGAs to handle network connections, data feeds, and even order book reconstruction.

The only disadvantage of using FPGAs is the cost of development and maintenance. You need to get specialized resources to do the new development and that is expensive, hard to maintain, and it will take double the time that it takes to do the same thing with software. Of course, the speed it can be reached is way higher than doing it with plain software.

Software

How to Build a Quantitative HFT Forex-Shop

Quant Traders

If you are serious about doing high-frequency trading on the forex market, you probably already choose to build your own software, custom made and with the flexibility that will allow you to make changes as you need in this dynamic environment.

The most important thing to build these kinds of software is to choose the right language and have the right architecture. My suggestions always go with C++ which is widely used in this industry. And the main reason is the abundance of available resources (libraries, developers, etc).

Why not off-the-shelf software platforms? Because most of the time, they’re targeted for a wider range of audiences, and that certainly will make that product heavier and slower than having your own custom software. And on top of all, you will depend on third party companies to run this sensitive operation.

But, whatever you decide, there are certain features that must be available at any cost:

Low Latency: above all, any feature, any process, and any characteristics of your software must be built with the highest performance in mind. If one small part fails to have the performance required, the whole system will be compromised. So, how the software is built, and its architecture is key!

Real-time & concurrency: if we need low-latency processes, then the system must be able to handle concurrency. It is the execution of multiple processes or instructions at the same time while maximizing hardware resources. In general, writing concurrent programs is extremely difficult because the multiplicity of possible operations among threads means that program execution is non-deterministic. For this reason, program bugs may be difficult to follow and reproduce. Experienced developers can overcome all these difficulties, but keep in mind that is not as simple as any other type of software.

Direct Market Access (DMA): doing high-frequency trading means having access to the market as fast as possible, hence, direct access is needed. Most of the forex ECNs and execution platforms offer DMA.

FIX Engine: FIX is the protocol that most electronic exchanges and ECNs use to send and receive data, and this engine will be the heart of your system. Keep in mind that also is used more advanced protocols like ITCH/OUTCH with much better performance, but the idea is the same: your system must encode and decode messages. Developing such an engine could be very challenging and time-consuming, so in this case I highly recommend using specialized libraries available in the marketplace which are very well known to have very good latencies.

Data normalization: your system, likely, will connect to more than one source (i.e.: different ECNs), and these sources may have different data specifications. For example, one ECN could define pairs like “EURUSD” and the other as “EUR/USD”. Moreover, some may have different quantity definitions, multipliers, also LMAX uses number codes to identify pairs, etc. Your software needs to have a well-designed way to normalize all this data and make it internally unique.

Limit-Order-Book reconstruction: every ECN will send their limit order book updates in different ways. Some of them will send them as a snapshot (with all the levels involved) and some others will send just the deltas (any order cancelation/update or addition to their centralized system). Your trading system must be able to stay up to date on the state of their LOB. For this, a special process to reconstruct the LOB must be in place and able to process each and every update received. Keep in mind that if you miss processing just one update, it could invalidate all the consecutive updates, making you stay out-of-synch with that ECN.

FX Aggregator: once your system can keep each ECNs’ Limit Order Book, you can aggregate them into a one single “Internal Limit Order Book”. The advantages for having such an aggregated view are endless. To start, your system will have a broader view of the market, knowing how the liquidity is present in each ECN and execute accordingly. You could aggregate different ECN in groups, and have custom liquidity pools, etc.

Order-Management-System (OMS): when sending orders to all the venues, your system must know their status at any given time. Are your orders correctly sent? Accepted by the venue? Or they have been rejected? What about the executions made and their PnL? Do you have a clear picture of what has been executed and how? All these scenarios must be handled by the OMS.

Smart-Order-Router (SOR): this Is a module that analyzes the state of venues and place orders in the best way possible, according to your defined rules, configurations, and algorithms. They’re configured with a specific objective in mind. Your SOR could be smart enough to know where execution Is best to send (even If they are not with the best price). For example, if your strategy wants to hedge a position, it will look for the most secure execution rather than price. Your SOR may know who’s the venue with the best execution times.

Monitoring and Analytics

You must ensure the availability of proper monitoring systems to control the operation, triggering alarms in situations where needs to be escalated. Imagine what would happen if a human realized that some strategy is not doing what it should, or if any venue is not providing prices as it should. When you realize this, you must stop the system, but unrecoverable losses may already be made.

How many minutes will it take for a human person to shut the system down? 5 minutes? 1 minute? You can have more than thousands of wrong opened orders within that time frame. Scary! That’s why any HFT operation needs to put monitoring systems in place, and to check some of the following:

Overall PnL: if there is, let’s say, a flash crash, the system must be able to close all open positions and shut it down itself.

Connectivity between venues: making sure that no one has been disconnected, activating reconnection systems in place.

Monitoring latencies: let’s say some network switches start to fail, and you start to receive data with some delays. You will never realize that until you start to analyze some logs. We need to monitor latencies between venues, to ensure data delivery and alert us in the case of any issue.

Trading Cost Analysis (TCA): lowering the cost could be the most important thing of any business. This is not different when trading on the forex market. A proper analysis of how trades were made (post trading analysis) could give you insights that otherwise would not have been seen.

Research

Usually, trading strategies and models in the forex market that exploit market microstructure deficiencies could be very profitable. However, most of them are short lived. What works great today, it could not work at all next week or month. That’s why those funds who are heavily relied on research are the ones who last the most.

Research in the finance industry will have a huge impact on the core business, developing new ideas and testing different hypotheses will allow you to stay one step ahead all the time.

Not only to generate new models and strategies, but to monitor existing ones and see how they perform over time, and most importantly, recognizing when it is time to shut down certain models.

Managing the research team has its challenges. But we need to demystify the actual role. The biggest myth is that researchers do rocket science math or invent new fields of math or physics. But work is much simpler than that. Of course, they will need to use their background in statistics + math + physics and apply them into actionable trading strategies.

Resources

At this point you should have a better idea of what kind of resources you will need to operate this business.

Portfolio Manager: you will need somebody to handle the overall operation, from handling the accounts with the Prime Brokers and the setup of liquidity pools with all the different venues. Also, it will need to oversee the strategies being executed, giving direction to the research team, and everything else related to the trading side.

IT Tech support: one or more professionals to setup and handle all servers, network connectivity, security access, etc.

Software Engineers: all the software needed must be handled by this group. They must not only know the technical part, but also specifics like venue’s protocols, how they get connected, market microstructures for the forex market, and an overall idea of all the modules listed above. This is probably the most sensitive position to fill in.

Quant Researchers: this group will be the math wizards that will come up with the ideas, so the academic level must be as high as possible. This goes from PhD’s to MScs as requirement. There is no limit to how many you need. Think of it as if they are the fuel your high-frequency trading firm needs. A clear advantage could be for those who are experts in machine & deep learning applied to markets. It is very important that members of this group have some knowledge of computer languages like Python or C++. They will need to build prototypes, before giving them to the software engineers.

High Frequency Trading Strategies

The strategies that this kind of operation can execute in the forex market are those that require quick responses, calculations and execution.

The list of possible strategies in the forex market is endless, but we will list the most common and well known here:

Arbitrage

Using arbitrage algorithms means that the system will be constantly monitoring for price discrepancies, and it is well known that these discrepancies will be short lived, so our system will need to act as fast as possible. Some types of arbitrage strategies in the foreign exchange market are:

· Triangular arbitrage between different pairs

· Covered interest arbitrage (spot vs forwards)

· Latency arbitrage (between venues)

· Event based arbitrage (news base)

Statistical

Statistical trading strategies are based on mathematical and statistical models to identify opportunities. These models are driven by quantitative analysts, using data-based models to determine the probability of a certain outcome happening. Unlike other forms of trading, it relies solely on statistical methods and programming to do this.

Passive — Market Making

It is the strategy that continuously buys and sells a currency pair acting as a counterparty to liquidity takers. This model has no intention of predicting the direction, and trades as often as possible, constantly filling buy and sell orders around the market price.

The market maker’s strategy is to post passive orders on both sides of the book: bids and offers at certain price levels. The profitability of this strategy is when it gets enough execution on both sides, collecting the spread between them. In practice, this is not always the case, leaving the strategy exposed. These exposures could be hedged into other ECN’s and take advantage of the market fragmentation.

Toxic flow

Let’s define toxic flow. You send an order through your strategy, and it will likely be matched against a liquidity provider. Once the liquidity provider processes your execution, it will continue to check how the market price evolves from there. If in the next 100ms (or any other metric they may utilize) the price, and the overall market abruptly moves against them (and in your favor), means that you have sent a “toxic order”. For example, when you execute arbitrage in the forex market, you are sending toxic flow to your counterparty.

Why is this important? Toxic flow is how your counterparty sees your orders. If they see that your orders are toxic to them, they will switch your liquidity pool to a poorer pool. Meaning that you will start to see worser prices, wider spreads, and lower-quality executions. Moreover, nowadays, every ECN will have speed-bumps to those who send toxic flow, hence, worsening your trading experience.

That’s why when designing high-frequency trading strategies in the forex market, it is very important to design them with this in mind.

How can we help

If you are not sure how or where to start, we, at SiS Software Factory have two different products that help many hedge funds and investment institutions setup and/or improve their electronic trading operations.

Technical Advisory: we help to stay within the best practices in the industry and have all the technical processes covered. We plan, maintain, optimize, and track deployments, timelines, and project lifecycles. Defining KPI and performance checks for the technology set-up for maximum value on investment. But mainly, our strong experience in the financial industry will allow you to gain a competitive advantage over your competitors. With this service, our customers saved more than 60% of their development costs. Taking the right decisions and avoiding common pitfalls. More info here.

HFT Platform: this is our ready-to-use low latency platform with the best performance and fully customizable will allow any Electronic Trading operation to run with a clear edge over competitors. Our unique and proprietary system architecture allows for achieving the lowest latencies in the market, offering integration with different open-source solutions, and allowing us to provide the best-in-class institutional trading platform. More info here.

Conclusion

The operation of a Quantitative HFT operation in the forex market is a capital-intensive operation, and highly technical.

It is imperative to be surrounded by highly-minded people with specific skills in each area.

Software is the engine and research is the fuel.

One thought on “How to Build a Quantitative HFT Forex-Shop

Leave a Reply

Your email address will not be published. Required fields are marked *