Optimization techniques for FIX-based trading applications

By Axon Trade CEO Serg Gulko

Our team has about 20 years of experience with FIX API, with the last six years primarily in crypto (or digital assets, if you will).

During this period, we accumulated particular experience and knowledge of what is good and what is not when it comes to using FIX protocol. Some of our know-how I will share in this short article.

These techniques are general and can be applied to digital assets, FX, equities, etc. It also will work (with some exceptions) with REST/WebSockets APIs.

General optimization methods

Never run on operating system default settings

By default, your OS is pre-configured to run on average hardware profile, and it has no idea how much memory (and what type) you have, what sort of network cards you’ll use, what storage devices are installed, and how they are configured. We don’t know much about Windows or Mac OS, but Linux offers a great set of different configuration mechanisms for tuning. It’s like a free lunch — you can get additional performance by configuring your hardware correctly.

Tune your 10Gbps NICs for better performance

Increase TCP/IP buffers

For example, the default buffer size for Linux is 8kb. This value works perfectly for web browsing but might create problems for applications that work with market data intensively.

If possible, consider changing threads priorities

Again, Linux-specific — you can increase threads priority for specific processes.
In addition to this — bind your application to specific CPU cores (threads affinity)

If possible, choose the proper disk scheduler

Again… Linux has multiple disk I/O schedulers, each with its benefits and drawbacks.
If you run on SSD/NVME then consider using none. (https://access.redhat.com/solutions/109223)

Keep the number of threads as low as possible

This tip is more on the software development side rather than system configuration.
Try to reduce the number of working threads to a bare minimum — context switching comes with a price, and with two or three threads it might be ignored. But with hundreds or thousands of threads competing for resources, the overall impact becomes meaningful.

Market Data sessions optimization

Increase receiving buffers

Pretty straightforward.

Properly plan your processing architecture

Make an informed decision on how and where to process market data — update books, run calculations, send orders, or do anything else.

if these operations take some time, performing them in a separate thread is a good idea. This way, you can ensure that a FIX engine is busy emptying, receiving buffers, and not being part of the Monte Carlo calculation. Otherwise, there is a chance that you will become what we call a “slow consumer” and will be disconnected. Do not try to subscribe to all Binance, Coinbase, OKX, and Deribit instruments, and keep complex processing in a single thread.

On the contrary, if the number of instruments is low, algo is pretty straightforward (e.g. price checks), properly debugged, and profiled, you can always save extra time on context switching by placing your business logic inside FIX messages handlers. For example, the latency arbitrage system we built some time ago works precisely like this.

Turn off logging for market data sessions unless it is required

If you are not in the business of reselling historical market data, then turn off logging provided by FIX engines. Yes, we optimize market data streams, and our FIX-based feeds contain fewer data(in bytes) than native OKX, Huobi, ByBit, or GATE.IO formats. But it still will keep your disk system busy. And it takes some space too. A lot of space.

Trading sessions optimization

Increase receiving and sending buffers

Unlike market data sessions, where you mainly receive data, trading sessions have usually utilized both ways. This means that both sending and receiving buffers should be adequately increased.

Never turn off logging for trading sessions

Based on our experience, we always keep logging on for trading sessions. To mitigate I/O penalty, use asynchronous logging adapters.

If your FIX engine doesn’t have such a thing from scratch, it’s usually a good idea to invest some time to build it by yourself.

Use pre-cached messages

Use pre-cached messages instead of creating e.g. NewOrderSingle or ExecutionReports (in our case) every time you need it.

If your FIX engine supports this, run warm-up procedures before hitting the gas with actual trading. Sometimes developers use lazy-load initialization, and creating particular objects might happen only when you send an actual message. Pity if this message is your NewOrderSingle when you are chasing a price.

Use pre-cached timestamps

If you profile your code, you will be surprised at how long it takes to transform timestamps from long (data format) into strings. It might be beneficial to pre-populate formatted strings into memory. This task is challenging (populate, update), but the performance gain is significant.

How to build your next trading system using Axon Trade OEMS

We are pleased to invite you to our upcoming webinar How to build your next trading system using Axon Trade OEMS. We will guide you through the extensive functionality of our FIX API for trading and market data, as well as provide an in-depth explanation on how to seamlessly integrate with our Management REST API. We look forward to sharing our knowledge and insights with you.

Agenda:

  • What is OEMS for digital asset trading
  • FIX API for trading: balances, positions, orders
  • FIX API for market data: streams, books, symbols
  • Management API: accounts, connectivity

Axon Trade OEMS is Now Available in Equinix HK2

We are happy to announce that Axon Trade’s OEMS for digital asset trading is now available in the Equinix HK2 location – Hong Kong!

We have connectors with 40+ exchanges, including these ones:

  • Binance
  • Bybit
  • OKX
  • Huobi Global

API Updates: January 2023

Our API has been extended with several new messages:
– Order Cancel/Replace Request
– Trading Session Status Request

Order Cancel/Replace Request

This message helps modify existing working orders (states New or Partially Filled). It can be used to change price and/or outstanding size.

The command is exchange-agnostic and works for all supported LPs, disregarding that some exchanges don’t support change/amend/update requests.

Trading Session Status Request

This message uses to subscribe to real-time updates about your outgoing connectivity statuses.
It is no secret that connections to crypto exchanges are unstable. Our system monitors connectivity statutes and disables trading operations on problematic destinations until a link is up and all orders, positions, and trading history are synchronized.

By using Trading Session Status Request your trading system also can receive notifications when your outgoing connection with, e.g. Binance or Deribit goes down or back online again.

See messages specification here: https://docs.axon.trade/

BJF Trading Group Partners With Axon Trade

FX Software development company BJF Trading Group, announces today its partnership with Axon Trade, OEMS for digital asset trading.

This partnership will allow customers to use sophisticated trading algorithms created by BJF Trading Group, across the entire spectrum of cryptocurrency exchanges supported by the Axon Trade OEMS.

“Digital asset space is still full of different inefficiencies that might be exploited to gain a certain profit. Of course, there is no free lunch, and to get positive results, you must be properly equipped and educated. BJF Trading Group did tremendous work discovering small operational nuances of traditional and crypto markets and turning them into algos.
Axon Trade provides you with the tools that you can use to “test the digital water”, said Serg Gulko, Co-Founder and CEO at Axon Trade.

Founded in 2000, BJF Trading group is a boutique Forex and Cryptocurrencies software development company that provides solutions for FX trading, specializing in Expert Advisors, Forex indicators, Forex and Cryptocurrencies software and programming for different types of platforms. Their cutting-edge software development skills allow for them to create creative software solutions to any inquiry traders may have. By utilizing market and programming knowledge, BJF provides both product and support solutions for clients. For more information, please visit BJF Trading Group blog.

Founded in 2017 by financial markets trading experts, Axon Trade is introducing a new infrastructure to allow banks, hedge funds, and large institutional traders easy, reliable access to any cryptocurrency market they choose. By building a low-latency infrastructure with a unified FIX API across multiple liquidity points, Axon Trade is taking an industry-standard technology used within global financial markets – namely FIX – for over 25 years and introducing it to the cryptocurrency market.

Lessons after FTX collapse

By Axon Trade’s CEO Serg Gulko

With FTX collapse, you might notice a growing number of voices that DEFI is a solution. It is not. You’ll replace one risk with another.

A balanced approach – that’s the answer.

  • Never put all eggs into a single basket.
  • Rule of thumb on reducing risks with crypto – check for interconnections. By trading on FTX using the money you borrow on BlockFi you expose yourself to potential chain effects.
  • If you don’t have the time/money/willpower to do proper due diligence, one of the solutions is to use brokers (I never thought I’d say something like that…) instead of direct market access. 
  • But if you do have time, resources, and willpower to invest in robust trading infrastructure that helps you to diversify and manage risks – consider using Axon Trade OEMS.

Do not lock yourself with other FTXs.

Latency arbitrage on crypto markets using Axon Trade OEMS

By Axon Trade’s CEO Serg Gulko

In addition to our order and execution management system for crypto trading, our company provides integration and custom software development services. In this article, I would like to showcase one such project – a latency arbitrage trading system. 

The main concept besides latency arbitrage is straightforward. Due to some market fragmentation, different market conditions, jurisdictions, and even trading hours, the selling price for an asset (BID) on one exchange could be lower than the buy price on another (ASK). This means you can buy in one place and sell in another, pocketing the difference. 

Latency arb is very similar to what market-makers do, except for the fact that they prefer to rest somewhere in the order book. In our case, the system performs as a pure taker, scooping liquidity from the top of books. As a measure of self-protection, we only used LIMIT orders with minimal resting time (so if an order was not filled, we had to cancel it).

“Simplicity on paper” comes with a price during implementation – everything should be fast. VERY FAST. Price discrepancies appear for just a moment, and you have a limited amount of time to do the following:

  • Receive market data
  • Detect arb opportunity 
  • Shoot two orders (to BUY on one exchange and to SELL on another) at the same time

Do not forget about error handling because bad things always happen. For example, one leg gets filled, and the second – is either rejected, partially filled, or stuck in a book. 

For obvious reasons, we choose Axon Trade OEMS for digital asset trading as a market data source and an entry point for all orders. This allows changing trading pairs and exchanges easily without adjusting any of the trading logic. 

Here is a simplified application architecture. 

Our end goal was to keep the number of elements as low as possible, so we came up with the following topology:

  • Two independent FIX sessions – one for market data, one for trading
  • Trading FIX session connected to BuySideOMS, a component to manage order stages 
  • BuySideOMS acts as a hub to receive trading commands and return execution confirmations to the business logic component 
  • Brain is more like a complex events processing (CEP) loop that decides what the next step would be based on current market conditions (received through market data FIX session) and order statuses. 
  • To control and monitor the Brain behavior, we added a REST-based API and a user interface on top of it; the main trick here is that REST API is set aside from the central communication circle – Brain/OMS/Market Data Session/Trading Session.

During development, our team faced several challenges:

  • Market data processing procedures 
  • Error handling
  • Asset settlement and rebalancing across exchanges 

Axon Trade market data dissemination services don’t apply any throttling or batching to outgoing data. This means a recipient must process the data at an extremely high speed to avoid the situation called “slow consumer” when messages start to pile up in outgoing buffers causing memory overuse. Our servers react simply to it – slow sessions will be terminated after some time. An approach to solve this problem is complex and might include the following:

  • Reduce network travel time by locating as much as possible close to our servers 
  • Increase operation system network buffers on your side – never, never run on a default operating system settings. 
  • Increase the buffer size on the FIX engine. Most FIX engines allow manually setting the size of a queue 
  • Avoid mixing market data processing and business logic in the same thread unless the logic is super simple

As long as there is no centralized clearing in crypto (yes, 2022…), you have to maintain a sizable inventory on both exchanges and settle as infrequently as you can. Your main enemy here is the exchange’s trading and withdrawal fees. Withdrawal fees might include direct fees, applied by exchange, and network fees, so watch out for this. From a distance, these numbers might look small, but the profit from arb is also not that big, so you have to perform multiple successful trades. If you do not have enough inventory, you have to rebalance it, and this is the point where withdrawal commissions can erode your trading profit. If you have big books on both sides, you can enjoy the ride! 

Asset transfer itself is a challenge. Initially, our client was planning to do crypto vs. fiat arbitrage. To rebalance fiat, we planned to use a solution from a company that is exceptionally aggressive on the marketing side, promoting things they do not have. This is an untrustworthy company, so to speak. Only one step away from production, we realized it had a gap. The solution – switch to stablecoins.

For crypto rebalancing, we were in a position to buy vs. build. A top candidate here was Fireblocks. It certainly has a working product, but the price(access + API) was far beyond our allowed budget. The solution – we built a simple exchange to exchange rebalance. 

Now pride time (technological, not coming out) – the system was able to hit the top of the book prices on Kraken and OKCoin in most cases, even when located in Equinix NY4 data center. It was a double pride – the trading app we built was fast, and Axon Trade OEMS was blazing fast. During the course of development, we navigated multiple technological, jurisdictional, and organizational challenges that our team successfully resolved. 

As a footnote, does latency arb still exist in crypto? Yes, it does. Can you exploit it? Possibly. But aside from latency arbitrage, many other trading ideas can be implemented on top of Axon Trade OEMS. 

If you have any questions (OEMS itself, custom software development services, etc) – feel free to reach out, and we will do our best to assist you. 

Axon Trade to integrate with Brokeree Solutions

Brokeree Solutions, a turnkey solutions developer for multi-asset brokers, has just announced the integration of its flagship Liquidity Bridge with Axon Trade – orders and execution management system (OEMS) for digital asset trading with a strong focus on low-latency and high-throughput execution.

Multi-server Liquidity Bridge is a comprehensive solution that combines advanced A/B book order execution, smart liquidity aggregation, and risk management. With this integration, brokers may introduce new crypto instruments for their clients on MetaTrader 4 and 5 platforms via the market data and liquidity provided by Axon Trade.

“We provide access to major US, Asia, and Europe exchanges. By leveraging our stack, clients can easily increase their liquidity offering by adding new LPs from the management panel without spending weeks for integration followed by neverending maintenance,” said Serg Gulko, CEO of Axon Trade. “I came to the digital asset space from FX and am familiar with the challenges market participants are facing. Our common effort with Brokeree pivoted toward helping MT4/MT5 brokers reduce their costs,  increase profit margins, and help them keep the competitive edge by providing new trading instruments to their clients without investing a fortune in R&D.”

Axon Trade is an institutional-grade OEMS for digital asset trading. It provides a unique combination of services, such as FIX API for digital asset trading, real-time normalized market data feeds, low-latency execution services, and a secure environment inside Equinix data centers.

“In the liquidity aggregation field, especially in volatile markets such as crypto, it’s crucial to use comprehensive technologies with robust risk-management features. By integrating with brands like Axon Trade, we can deliver our clients with accessible high-grade technology,“ shared Brokeree in the press release.

Brokeree Solutions is a technology company specializing in solutions development for multi-asset brokers running MetaTrader 4 and 5, trading platform servicing, and consultation. 

Established in 2013, the company has developed over 50 products, including liquidity management software, investment systems, and a wide range of plugins to automate and optimize certain internal processes of financial brokerages.

KuCoin is now available through Axon Trade FIX API

We are pleased to announce that KuCoin is now available through our FIX API. Axon Trade OEMS for digital assets trading allows receiving normalized market data and actively trading on KuCoin’s markets using unified FIX 4.4 end-point. 

Launched in 2017, KuCoin is a crypto exchange headquartered in Seychelles. Since its founding, it’s grown to be one of the largest global exchanges by trade volume, and it now has over 10 million users and a presence in more than 200 countries. 

KuCoin offers a huge selection of cryptocurrencies and relatively low fees compared to other crypto exchanges. It also supports staking and margin, futures, and P2P trading, which may appeal to more experienced users. 

Bitget partners with Axon Trade to offer seamless trading corridor for institutional investors

Enabling institutional traders to easily access and trade Bitget’s products

Axon Trade is pleased to announce its partnership with Bitget, one of the leading derivatives exchange, to enable institutional traders to easily access Bitget’s products and trade with programme trading, benefiting the expansion of user base with more institutional users.

Commenting on the cooperation, Managing Director of Bitget, Gracy Chen said, “We are glad to partner with Axon Trade, an expert in building trading corridors between institutional users and exchange platforms. This partnership will enable us to better meet investors’ demands for fast transaction, precise and timely data and asset security.”

“Institutions are in a constant search for quality liquidity and solid product offering and we believe that Bitget will fully fulfill their expectations. Bitget is very dynamic and we are happy to have them as an integral part of our OEMS for digital asset trading,”said ​​Serg Gulko, CEO of Axon Trade.

“As the crypto market matures with increasing institutional participation, demand for crypto derivatives trading is huge. We are better positioned to extend our services and products to a new user base and attract more institutional investors. Looking forward, we will make persistent efforts to hone our products and cooperate with more partners specialised in different fields to benefit from their expertise,” said Gracy.

According to a recent report by BCG, Bitget and Foresight Ventures, the quarterly crypto derivative trading volume expanded twelvefold to $6.3 trillion in the two years to the first quarter of 2022. Institutional investors come to derivative trading for different benefits, such as flexibility to apply more trading strategies and higher capital efficiency.

Equipped with innovative futures trading products and social trading services, Bitget has become one of the world’s largest crypto derivatives and copy trading exchanges, ranking top five in the globe according to CoinGecko. Its flagship product, One-Click Copy Trade has amassed over 55,000 professional traders and around 1.1 million followers with its copy trading products. Recently, the exchange also launched its protection fund to rebuild the trust of investors in a gloomy market.

About Bitget

Established in 2018, Bitget is one of the world’s leading cryptocurrency exchanges with a core focus on social trading. Currently serving over two million users in more than 50 countries around the world, Bitget accelerated its mission to promote decentralised finance with a 600-strong workforce. 

Since Bitget’s official launch in the crypto derivatives market in June 2019, the platform has now become one of the world’s largest crypto copy trading and derivatives exchanges, and is ranked in the top five globally by CoinMarketCap and CoinGecko for derivatives trading by volume. The leading exchange focuses on transforming the way people connect and trade with social trading. Its flagship offering, One-Click Copy Trade, is nothing short of a pioneer in social trading, and has amassed over 55,000 professional traders, with approximately 1.1 million followers, innovating the experience for crypto derivatives traders worldwide.

Adhering closely to its philosophy of ‘Better Trading, Better Life’, Bitget is committed to providing comprehensive and secure trading solutions to users globally, aiming to be the portal that transcends Web2 and Web3, that connects CeFi and DeFi, resulting in an expansive bridge to the vast web of crypto. In September 2021, Bitget announced its sponsorship of world-renowned football team Juventus as its first-ever sleeve partner and PGL Major’s official esport crypto partner soon after. Partnerships with the leading esports organisation, Team Spirit, and Turkey’s leading and long-standing football club, Galatasaray, were also announced in early 2022.