Order Matching Engine: Everything You Need to Know

18 min read

Order matching engines are the backbone of modern financial markets, facilitating the seamless execution of trades. Understanding their function and significance is crucial for each market participant.

In this article, we’ll give you an insight into what an order matching engine is, the mechanics behind it, and what to pay attention to when choosing one for your exchange or dark pool.

Price discovery at a glance

Trading venues, including exchanges and over-the-counter markets, are crucial for the frictionless exchange of assets like stocks, commodities, and cryptocurrencies, as well as derivatives such as futures, options, and more.

Their purpose is to create a level playing field on which market participants can access price information to buy and sell securities. The willingness of traders to buy or sell an asset at a predefined volume and price is logged by these venues, forming public “order books” for each tradable symbol.

As traders enter and exit the market, buying and selling at the current best price (the top of the order book), their “market” orders are filled from these “limit” orders stored in the order book.

Every time a trade is made, the balance between the best available buy/sell prices and volumes thereof is altered as liquidity is removed, thus setting a new prevailing market price. This is what market participants mean when they talk about price discovery.

What is an order matching engine?

An order matching engine (OME) is a software system that matches buy and sell orders from market participants to facilitate the execution of trades.

In other words, the matching engine enables price discovery, leading to the creation of efficient global markets where vast amounts of liquidity can change hands daily.  All other exchange systems can be regarded as peripheral to the matching engine because, without it, there is effectively no market to speak of.

Regardless of the asset class your business specializes in, you’ll require a matching engine to fulfill incoming market orders for immediate execution with liquidity from limit orders in the order book.

At the heart of the system, the matching algorithm performs most of the heavy lifting in order execution. The matching algorithm follows predefined rules that determine which orders are prioritized in their execution and how.

An example of such rules is Price-Time Priority. This is one of the most popular order matching rulesets, where orders are matched based on their price and the time they were placed. Also known as FIFO (first in, first out), the oldest order at a particular price level will be prioritized in this ruleset over newer orders at the same price.

Pro-Rata is a different set of matching rules under which the matching algorithm prioritizes larger orders, providing them with a proportionally larger share of the available liquidity at a given price level.

Launch a high-performance exchange with DXmatch

Build your exchange with a matching engine offering sub-100-microsecond latency and scalable segments, each processing 100,000+ orders per second.

What to keep in mind when choosing a matching engine?

Choosing the right matching engine is a critical decision that requires careful evaluation. Let’s have a look at some factors you need to consider.

Asset classes

Right off the bat, it’s important to know which asset classes your trading venue will be offering.Not all matching engines are compatible with every asset class. Of course, there are multi-asset matching engines, like DXmatch, that are completely agnostic to the underlying assets they work with. That’s why they can be easily used on all conventional markets and even some unconventional ones, like prediction markets.

Order Matching Engine - DXmatch

Order types

Ensure that the matching engine supports common order types like Limit, Stop, Stop Limit, and Market orders. Verify if specialized order types, such as Trailing Stops, One-Cancels-the-Other (OCO), and Iceberg orders, are currently available or slated for future implementation.

Determine if a prospective provider can offer these features or if they have a plan to add this functionality in the future.

Latency considerations

Another crucial aspect of your matching engine, which your clientele will also determine, is its performance characteristics.

How important is latency to your business? For example, institutions deploying high-frequency trading strategies require as close to zero latency as the laws of physics will allow.

In these applications, bare metal systems that are co-located in exchange data centers are essential. In these cases, even the length of the cables used to connect client servers to exchange matching engines can confer a minuscule advantage on one participant over another.

Throughput and availability

On the other side of the spectrum, we have venues such as cryptocurrency exchanges, which are far less concerned with latency. Retail clients overwhelmingly use these venues, so the allowances for this type of trading venue are radically different from the HFT example above.

Retail exchanges generally favor throughput over latency due to their extensive client bases, which may all want to enter positions at certain times, such as during the frenzy of a crypto bull market.

In our own DXmatch solution, we use clusters of independent order processing units (replicated state machines), all equal copies of one another, in order to maintain high availability in a cloud environment. In the case of throughput, we employ horizontal scaling by splitting the venue’s available instruments into multiple segments, each with its own copy of the matching engine.

Our DXmatch engine can be installed in both a bare metal server setup or deployed on the cloud for businesses whose latency requirements are not as strict, and that value the flexibility and cost-effectiveness of cloud computing over bare metal.

It’s important to note that while high availability and throughput can be maintained with a cloud-based setup, achieving order processing latency under 100 milliseconds with a cloud deployment is extremely challenging.

As mentioned above, this is just not viable in certain applications. Using an advanced bare metal setup, our own DXmatch engine can deliver wall-to-wall latency of under 100 microseconds via FIX API.

Connectivity

This brings us to connectivity protocols, which bring together different parts of the exchange infrastructure and allow it to connect to external third parties.

Evaluate the connectivity protocols offered by the matching engine to enable seamless integration with external third parties like market data providers, custodians, clearing agents, regulators, settlement systems, and both custodial and non-custodial crypto wallet management providers. REST and FIX APIs are industry standards.

Admin features

Finally, we have user-facing administration software for monitoring and manually intervening when necessary.

Ensure that the matching engine provides user-friendly administration software for monitoring and intervention. This software should enable easy visualization of activities on the exchange and include controls such as a kill switch to cancel orders or mass cancel features.

For example, a kill switch to cancel existing orders and prevent new ones from a participant that has been identified as a bad actor, or a mass cancel feature, allowing administrators to cancel all open orders about an individual symbol, or an entire asset class.

Order Matching Engine - DXmatch

Experience DXmatch, a matching engine by Devexperts

DXmatch is Devexperts’ proprietary order matching engine designed for ultra-low latency and high throughput applications. It is trusted by regulated securities exchanges, dark pools, and other alternative trading systems, cryptocurrency exchanges, and OTC venues worldwide.

With DXmatch, you can build an exchange from scratch and offer a wide range of underlying assets, including stocks, bonds, futures, options, cryptocurrencies, and non-standard assets like NFTs, real estate, and prediction markets. It ensures regulatory compliance and supports swap contract execution.

Advantages of DXmatch

Ultra-low latency engine

DXmatch ensures high-performance order matching with sub-100 microseconds latency. This level of speed allows for faster execution of trades, making it suitable for high-frequency trading strategies that require near-zero latency.

Scalable engine

The DXmatch engine is designed to scale horizontally, meaning that its throughput increases linearly with horizontal scaling. This scalability ensures that the engine can handle a growing number of transactions without compromising performance.

DXmatch supports multi-segment setup, allowing for efficient management and execution of multiple trading segments simultaneously. With a capacity of 30,000 matches per segment, DXmatch can handle high volumes of trades across various segments.

Engine to deploy anywhere

DXmatch can be easily deployed on various platforms, including bare metal servers and cloud platforms such as AWS and Google Cloud. This flexibility allows trading venues to choose the deployment option that best suits their needs and infrastructure.

Migrate hassle-free to a new engine

DXmatch provides a guided path for migrating working orders from legacy engines to its platform. This migration process ensures a smooth transition and minimizes disruptions during the switch to DXmatch.

“In the ever-expanding world of financial markets, DXmatch stands out as the ultimate solution. Our experience with clients is a clear demonstration of our unwavering commitment to innovation and adaptability.”

– Sergey Samushin, Project Manager of DXmatch

Engine for trading derivatives

DXmatch supports derivatives trading, enabling trading venues to expand their offerings beyond spot assets, such as crypto and stocks. This capability enables the inclusion of derivative products in the exchange’s portfolio.

Multi-leg trading

DXmatch enables the execution of multi-leg trading strategies, allowing users to create complex strategies within the engine itself. This feature enhances trading flexibility and efficiency.

Enterprise-grade APIs

DXmatch offers high-quality APIs, including the FIX 5.0 protocol, that provide market access with sub-100 microsecond latency. These APIs also support mass cancellations and mass quoting, catering to the needs of market makers. 

Risks mitigation

DXmatch is a modular platform equipped with advanced risk management features. These include price slippage limits, built-in fat finger protection, kill switch, self-trade prevention, message throttling, min/max quantity validation, and min/max price validation. The features safeguard your customers and protect your business, adding value to your clients and ensuring that your business remains protected even in worst-case scenarios.

In summary, DXmatch offers several advantages, including ultra-low latency, scalability, multi-segment setup, deployment flexibility, a smooth migration process, support for derivatives, multi-leg trading, and enterprise-grade APIs. These features make DXmatch a powerful and reliable choice for trading venues and exchanges seeking an efficient and high-performance order matching engine.

The main components of the matching engine

Console UI

The Console UI application within DXmatch provides a user-friendly interface for monitoring and administering orders on an exchange. It offers several functions that assist exchange administrators in managing and overseeing trading activities.

Market data

The market data feed service provides real-time updates on trading information, including quotes, last traded price, volume, and more. Common usages of this API include web-based trading systems (widgets like Watchlist or Market Depth) and public websites.

The information distributed by this service is not personalized, and there is no way to link events from the market data feed to a specific market participant.

FIX API

The DXmatch FIX Port application operates in two functional modes:

  • Trading mode. Gives access to the DXmatch exchange market for placing and managing orders.
  • Drop copy mode. Allows the distribution of real-time copies of order execution reports.

REST API

This API provides endpoints for trading and exchange management:

  • Trading: placing, modifying, and canceling orders via the Matching Engine.
  • Historical data: requesting historical orders data, related execution reports, and fills from the data warehouse.
  • Instrument management: listing new tradable instruments and managing instrument parameters.

Matching engine FAQs

What are matching engines, and what do they do?

Matching engines are central to the functioning of securities exchanges. They essentially match orders between buyers and sellers, leading to efficient markets in which price discovery can take place. 

Matching engines receive inputs from traders in the form of orders and produce outputs in the form of market updates as orders are filled, available liquidity changes, and a new current market price is set. 

In computer science, matching engines are known as a state machine; new inputs alter the internal state and generate new outputs. 

These systems must be incredibly quick to meet the demands of modern markets and handle high volumes of concurrent orders. 

Due to the low latency demands placed on these systems, they must run exclusively in RAM, which means that all record keeping of matching engine interactions must take place in peripheral systems outside of the matching engine itself. 

What is a central limit order book (CLOB)?

In trading, a central limit order book is a repository of all the orders expressing the desire of market participants to buy or sell a given quantity of a security at a certain level.

Order books contain lists of buy limit orders, which define how many units and at what level below the current market price each trader would like to buy, and sell limit orders, which define how many units and at what level above the current market price each trader would like to sell. 

Also known as working orders, these instructions sit passively in the central limit order book, providing liquidity to a market. The top of the order book refers to the buy and sell orders that are closest to the current market price; they are filled when active traders choose to buy or sell at the current best price.

How do market orders interact with working (limit) orders?

Market orders are executed at the current best market price when traders choose to buy or sell a given quantity of a security at the present moment. Limit orders are instructions to buy that security at a lower level, or to sell it at a higher level than the current market price, when and if the price drops or rises to that given level.

The way these two order types interact is that market orders are filled from the best available limit orders in the order book (top of the book). Each time a trade is executed, liquidity is removed from the order book, and a new best buy and sell price is made available.

The current price refers to the level at which the last known trade was executed. For example, $225 for Apple stock. If the next best buy limit order is at $224.5, and the next best sell limit order is at $225.5, then the next market buy order to come in will receive the price of the best limit sell order at $225.5, and the next market sell order will receive the price of the best limit buy $224.5. 

Keep in mind that each price level also has a limited amount of liquidity available. For instance, the best limit sell order for $225.5 may only be for 10 shares of Apple stock. If a market buyer purchases 20 shares of Apple stock, they will receive the first 10 shares at the current best price of $ 225.50 and the next 10 at the next best available price, which will be slightly higher.   

What different types of working (limit) orders are there?

Limit orders enable market participants to ensure trades are executed if the current market price reaches a predetermined level.

A buy limit order is an instruction to buy when the current price drops to a certain level, and a sell limit order is an instruction to sell when the price rises to a given level. 

Buyers would ideally like to purchase the security in question at a lower price, whereas sellers would ideally want to sell at a higher price. Limit orders enable traders to input instructions that can be executed if the price reaches their desired level, even when they are not actively using their trading platform. 

Stop orders, in contrast, are instructions to buy at a higher level or to sell at a lower level than the current market price. These orders are placed by traders as a failsafe, so that if the market moves against them (higher for buyers and lower for sellers), they can still enter the market, albeit at a slightly worse price. 

What are matching engine execution rules?

For a matching engine to efficiently match the orders of buyers and sellers, it has to follow a set of execution rules, also known as execution priorities. These rules tell the matching engine how to match incoming market orders with existing limit orders in the central limit order book (CLOB).

The most popular of these rules is known as price-time priority, or first-in, first-out (FIFO). In this ruleset, the matching engine prioritizes earlier orders, ensuring that the first orders at each price level are filled first when a market order is placed at that price.  

Pro-rata is another execution priority ruleset that favors larger orders over those placed earlier. In this case, the largest limit order at a given price level will be filled before smaller orders at the same price level. 

Why do financial exchanges run multiple copies of their matching engines?

Matching engine replication is primarily performed for two main reasons: resilience and scalability.

Financial markets require uninterrupted uptime to run efficiently. To ensure resilience to technical difficulties, replication is employed as a strategy. By maintaining redundant copies of all system components, financial exchanges can switch to these backup systems in the event of technical difficulties. 

Since matching engines are state machines that generate outputs according to inputs, if you “play” the same inputs in the same order, the matching engine will arrive at the same state. Some exchanges run multiple copies of their matching engines, using consensus algorithms to ensure that they are all in agreement as to the current state. In the event of a failure, they can switch to a functioning copy of the matching engine without interrupting market activity. 

In the interests of scalability, exchanges can divide their instrument lists between different instances of their matching engine, ensuring that each instance has enough capacity to handle the volume of incoming orders. This is called horizontal scaling.

Contact us for an in-depth demonstration.