Latency arbitrage on crypto markets using XTRD OEMS

By XTRD’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 XTRD 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 

XTRD 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 XTRD 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 XTRD 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. 

XRTD 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 XTRD – an 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 XTRD.

“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 XTRD. “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.”

XTRD 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 XTRD, 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 XTRD FIX API

We are pleased to announce that KuCoin is now available through our FIX API. XTRD 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 XTRD to offer seamless trading corridor for institutional investors

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

XTRD 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 XTRD, 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 XTRD.

“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.

WhiteBIT is now available through XTRD FIX API

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

Launched in Dec 2018, WhiteBIT is a European centralized exchange that offers crypto-to-crypto and crypto-to-fiat transactions with 0.1% trading fees.

With European Exchange and Custody licenses, WhiteBIT meets KYC and AML requirements. It claims to have 150,000+ users from the EU, South America, and Asia registered on the platform.

WhiteBIT offers instant transactions with P2P codes, possibility of staking, private and public API & a number of trading tools: limit, market, stop limit and stop market orders. Quick deposits and withdrawals are carried out with InstantSend by Dash.

CoinFLEX is now available through XTRD FIX API

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

CoinFLEX (Coin Futures and Lending Exchange) is a physically delivered cryptocurrency futures exchange, developed for investors to hedge cryptocurrency exposure with low index or price settlement risk.

The platform offers innovative solutions such as flexUSD — the world’s first interest bearing stablecoin — and AMM+, the most capital–efficient automated market maker for today’s investors. CoinFLEX is backed by crypto heavyweights including Roger Ver, Mike Komaransky, Polychain Capital, and Digital Currency Group, amongst others. The exchange is dedicated to providing an easily accessible venue for users to earn and trade crypto with minimal friction.

XTRD Opens Up in TY8 Data Center

We are happy to announce that XTRD’s OEMS for digital asset trading is now available in the Equinix TY8 location – Tokyo, Japan!

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

  • Binance
  • FTX
  • Bybit
  • OKX
  • Huobi Global

XTRD OEMS for Crypto

Article by Serg Gulko, Co-Founder & CEO at XTRD

In this article, I would like to address the most common questions we received about XTRD OEMS for digital assets trading.

What is the OEMS for crypto trading?

OEMS, sometimes O/EMS, stands for Order and Execution Management System. Initially, it was two separate software types – OMS and EMS which were merged into a single system over time. We live in a time of consolidation and modern OEMS systems are capable (sometimes) of doing much more than before, including positions management orchestrating the settlement process. 

OEMS is in charge of many things – orders entry and execution through different liquidity providers, analytics, market data streaming and charts, transactions cost analysis, and so on. The system can be accessed by humans as well as programmatically through APIs such as FIX. 

Unlike its peers from established markets like FX, a big part of crypto OEMSs is dedicated to connectivity management. Almost every liquidity provider in the FX space understands FIX; specifications have not changed for years and a TCP/IP connection established on Monday can be disconnected in about one week. This does not happen in crypto which adds some “spice” to the process and extra complexity. 

How is OEMS different from libraries?

There are many different open source and proprietary libraries that can act as a normalization layer between your system and exchange(s). This is really a wrapper from general purposes languages like Java, Python, PHP, or JavaScript into widely used in crypto REST/WebSocket calls. Libraries can help you send orders but leave you alone with more complex problems like different symbols’ names, monitoring session states, and performing systems synchronization. Even accessing trading history can be tricky – some exchanges do not store more than 90 days of orders (and in the most extreme cases – only the last 1000 orders). 

Of course, you can link the database layer, implement your own mechanisms to deal with dead WebSockets, tune connectors code (in many cases, the quality is far from ideal and many things can and should be improved), add accounts support, and so on. Good job! You just built your own OEMS system. 

I see libraries as bricks, while OEMS is an unfinished house. Add hardwood floors, furniture, doors, lights, and a fence – and you’ll get a trading platform, market-making algo, or something different but something that can be used by people. Bricks are important but you can’t live surrounded by just them.

Disclaimer: in XTRD OEMS we do not use any third-party normalization libraries to communicate with crypto exchanges. Everything is built in-house to ensure the best performance. 

When should I use OEMS for crypto?

In most cases, it’s beneficial to integrate ready-to-use OEMS unless you would like to build your own and become a vendor. 

Of course, there are many factors to consider, such as flexibility, functionality, latency, geographical location, support, prices, and even team behind the scene but I can assure you that it’s always possible to find a compromise. There are many solutions on the market, some good, some bad but they can save the most valuable resource – time. 

What functions are available from the shelf?

Different systems offer different sets of functions. Below is what XTRD OEMS offers to accelerate crypto trading.

Normalized FIX API for trading and market data

We use FIX 4.4 for both market data and trading sessions. It means that, for example, quotes from Binance will look the same as quotes from Coinbase Pro. The trading process also will look identical although exchanges are completely different.

Simultaneous access to multiple crypto exchanges

XTRD OEMS is interconnected with major crypto exchanges in the US, Europe, and Asia. All trading operations on different venues can be done through a single TCP/IP connection (or can be spread).

Active orders management

Information about clients’ orders is replicated and constantly updated on our servers. Each trade confirmation or/and cancellation dynamically changes the representation of orders which we store in memory.

Access to trading history

We store every order sent through our system and every execution report received. There is no ‘data retention period,’ everything that gets in, remains there. Information about trading activities includes exchange-assigned IDs, timestamps, trade prices and sizes, and also fees paid.

Multitenant design

XTRD OEMS for crypto is designed in a way that allows a single organization to have multiple independent resources, for example, trading desk accounts with their own connections to exchanges, balances, and separated FIX sessions for trading. 

Such separation also helps build trading platforms on top of the XTRD stack – accounts are segregated and do not interact with each other.

Normalized Symbology

There is no common standard for naming convention. Each exchange lives to create something new and unique (and they have a wild imagination), so we built and maintain our own directory that covers spot and derivatives markets.

Connectivity Management

We carefully monitor outgoing connectivity statuses, and if something goes wrong (and this happens relatively often, unfortunately, due to current infrastructure development) we notify clients, disable trading on a particular destination, and start checking once it returns to normal. Once we connect again, we handle complicated synchronization procedures that include checking all open orders, trading history, and position changes. 

Demo Environment

XTRD OEMS has a dedicated demo environment that can be used to test integration without putting real money at risk. The Demo Environment fully replicates our production services, including market data streams and management API.

Management API

In addition, to FIX API for trading and market data, we offer REST-based API to manage assets of your organizations – accounts, connectivity to exchanges, FIX sessions, and access rights. This API also can be used to fetch trading history, positions, and even open orders.

Renko-based Scalper for Binance Using XTRD FIX API

Binance Overview

Binance is one of the largest cryptocurrency exchanges in the world, responsible for $7.7 trillion crypto exchange volume in 2021. It was founded in 2017 by Changpeng Zhao, who previously worked for and as CTO of OKCoin.

XTRD Overview

XTRD is an institutional-grade OEMS for digital assets trading. We provide access to major crypto exchanges through the unified FIX API.

In this article, we would like to demonstrate how to build a small yet powerful scalping application that trades on the leading cryptocurrency exchange – Binance. 

The bot will be connected to Binance through XTRD FIX API to receive real-time normalized market data and to place/cancel orders. 

You can reuse this source code in your projects free of charge. 

Disclaimer: the bot is not a ready-to-use solution because it lacks risk controls and proper positions management. Although our R&D shows promising performance, do not expect to achieve the same results. 

Before we dive into the technical part, it’s worth explaining the logic behind the given trading bot. 

Scalping is a momentum-based trading style where positions hold for minutes or even seconds and then sell for profit (or small loss… a sacrifice to Mr. Market). When performed manually, it requires self-discipline, the ability to handle stress, make quick decisions, and act accordingly. 

Renko chart is one of the technical analysis tools that help reduce market noise and identify market trends more precisely. One of the authors of this article was introduced to Renko about 15 years ago and fell in love with it. 

To construct a single brick on a chart we should perform several simple steps:

  • Define a brick size e.g. 10 points
  • Define the price type to track. It can be bids, asks, trades, an average between the bid and ask, etc.
  • Start tracking prices in real-time
  • If the price changed more than 10 points, then form a new Renko brick in the corresponding direction. It is possible that the single price change can form more than one Renko brick.

Here is our trading logic:

  • Wait for a new Renko brick to be formed
  • If it is an UP brick, then place a limit order to SELL with a price at the level of UP + 1 brick
  • If it is a DOWN brick, then place a limit order to BUY with a price at the level of DOWN – 1 brick

  • Continue monitoring the market for changing course or for execution
  • If a newly formed brick changed its direction (this means that the price changed at least 2x of a brick size in the reverse direction), we should cancel our existing limit order and place another one with a new price and reversed direction.
  • If the market moved in the direction we predicted, then our order gets executed and we should start over.

Simply put, it is the good old “buy low, sell high” principle computerized and applied to crypto markets through XTRD FIX API. 

The bot itself contains several main components:

  • Market data connector 
  • Trading connector
  • Market data processor/Renko generator
  • Simple OMS/EMS system

To make this technical-enough material more fun, we decided to build a small user interface to plot Renkos bricks and executions.

Since all high-level details of implementation were discussed, let’s get started with the implementation part.

To build Renko charts we need to establish a connection to a service called XTRD MD Feeder. It is responsible for disseminating real-time normalized market data from Binance (and other crypto exchanges) using FIX protocol. In comparison with WebSockets, FIX is faster and more reliable because it runs on top of a pure TCP/IP stack and has no additional intermediary layers. 

Using FIX protocol, you can easily subscribe to receive updates for one or many trading instruments available on Binance such as BTC/USDT, ETH/USDT, and so on. It is possible to specify what sort of information you’ll need – bids, asks, and/or trades. Another big advantage is that market data itself comes in incremental updates. This means that you receive only actual changes of the entire orders book (like 3-4 levels) but not a full book every time. This is not a big issue with Binance which already streams data as a delta (difference between the previous and current state) but can be extremely helpful with other crypto exchanges XTRD supports. 

There are three major messages defined by FIX standard and implemented inside XTRD that help manage your crypto market data streams – MarketDataRequest, MarketDataSnapshotFullRefresh, and MarketDataIncrementalRefresh. As it is easy to understand from their names, MarketDataRequest is used to manage your subscription (start or stop data streams), MarketDataSnapshotFullRefresh is used by the server to transmit the entire book, and MarketDataIncrementalRefresh is sent by the server when data (price or side) in the particular orders book changed. 

The market data management workflow is simple – once the application established a connection to XTRD OEMs over the FIX, it sends MarketDataRequest to subscribe to all updates on BTC/USDT (or another selected symbol) on Binance. 

If the request was successfully processed, XTRD OEMS for digital assets trading responds with a MarketDataSnapshotFullRefresh message that contains all levels for BTC/USDT orders book. The application uses this data to initiate the book and starts waiting for incoming MarketDataIncrementalRefreshes that carry small (and sometimes not very small) delta changes. These changes have to be applied to the book (delete levels, update sizes on a particular level, add new prices). Once a book is updated, the component responsible for Renko’s generation will check if the conditions to create a new brick are met or if the price is still within the interval. 

Now, when we have a working market data connection and Renkos charts, it’s time to start trading on Binance using FIX API. 

FIX specification contains plenty of different messages (commands and responses) that cover pretty much everything in a typical trade lifecycle starting from initiation to ending with trade confirmation and settlement. XTRD OEMS system allows managing orders (get all, place, cancel, replace) and viewing positions through the unified FIX API. 

When it comes to trading, there are three major messages – NewOrderSingle, OrderCancelRequest, and ExecutionReport.

NewOrderSingle is used to initiate an order. The message allows specifying different order characteristics, such as side (e.g. BUY), size, type (e.g. LIMIT), symbol, time in force (e.g. Good Till Cancel), among others.

Below is a textual representation of the raw FIX request to buy 0.001 BTC for USDT at Market on the Binance.

In many cases, the server interacts with clients over ExecutionReports. This message is used to indicate changes of your orders over time – was it accepted or rejected, canceled, or executed, and if executed, what are the price and size? 

Each message has clear status, a clear ID, and a timestamp associated with it. 

Many exchanges have their own workflows. XTRD OEMS for digital assets trading helps normalize these statuses and make them identical across all supported platforms:

Our demo application utilizes only two simple commands – NewOrderSingle (to place a new order) and OrderCancelRequest (to cancel an order we don’t need anymore). 

Another useful command is OrderCancelRequest. It is used to initiate the cancellation of a pending order or the outstanding amount of a partially filled order. 

Below is a sample of FIX-based OrderCancelRequest to cancel a pending order on Binance:

Our demo application will send requests to open an order (using NewOrderSingle) and to cancel it (using OrderCancelRequest) over the FIX to Binance. The server will notify us (using ExecutionReports) in real-time about any status changes of our order(s). 

In real life, it’s always a good idea to separate business logic that makes decisions about entering or exiting the market from orders management. This component is usually complex and covers a vast array of scenarios of what can happen with orders starting from regular behavior when everything goes as expected and ending with different doomsday scenarios. 

For the sake of simplicity, in this sample, we decided to use oversimplified orders management which also handles incoming market data-related events ( 

Below is the video of the working system (replayed with 50х speed):

Building a successful trading system is a challenging task where you must overcome many obstacles. Our goal is to make sure that the connectivity between your application and target exchange (or exchanges) will not become one of these blocking factors. By using XTRD OEMS for digital assets trading, you can easily build a reliable system that can operate around the clock. Connect to our FIX API to trade on Binance or many other exchanges and/or to receive real-time normalized market data. Focus on your business and let XTRD be your ‘pipes and plumbing’ provider! 

How to use XTRD FIX API from JavaScript/node.js

We published a small demo on how to use XTRD FIX API from JavaScript/node.js. 

Simple clients that show different aspects of XTRD FIX API – market data, orders routing etc.

jspurefix v1.3.0

Any feedback is highly appreciated!

Conclusion: FIX is a truly cross-platform/language way to build trading systems. You can use C++, Java, Python, JavaScript, and many other languages to integrate with XTRD OEMS for digital assets trading. Trade with ease on Binance, OKEx, FTX, ByBit simultaneously through our FIX API.