A matching engine or trade engine is a software component and a significant part of any trading system, exchange, or dark pool. The matching engine is an algorithm or a sum of algorithms that match market transactions. It also holds an order book in the form of a summary table with all buy or sell orders.
In the early 1980s, US market participants such as investors, brokers and traders launched a matching engine in order to add auction trading in an open format. Thus, computers had changed the flow of capital and finance. Chicago Stock Exchange was a pioneer who got the matching engine rolling.
Since 2010, the procedure of matching orders has become exclusively automated. It helps the market to manage the interactions between buyers and sellers.
Functions of the Matching Engine
There are different functions the matching engine accomplishes, such as:
- ensuring transaction integrity for a marketplace, an electronic trading venue, or exchange,
- using various algorithms such as pro-rata algorithm to facilitate work with spreads and to implement files with large limit orders,
- fulfill a variety of orders,
- ensure full reserve of balance at the end of working hours.
Orders, Events and Order Book
Electronic trading networks are built on a diversity of order types and all transactions occur within the order matching engine. Thus, work with matching orders is obligatory for brokers and other market participants, and it serves to ensure the output of similar sell and buy orders simultaneously.
The matching engine as a software component accepts orders, such as “NewOrder” and “CancelOrder” in the form of inputs and outputs. There are also events, and the execution of orders depends on them.
Thus, working with the matching engine, the broker has to be aware of several notions:
1) Orders. Every matching engine provides traders with a variety of orders, the most popular of them being:
- Market orders are orders that are filled immediately at the best current price. In this type of order, there are two strategies that concern volume. The first one is to buy all that is available at the current price. The second one is to buy only the requested volume or to cancel.
- Limit orders are orders that set a price. After a limit order is placed, a trade can be performed if the market price reaches the client’s limit price or the best price.
- Stop orders are activated after the price reaches a particular level. Then they are automatically transformed into market orders.
2) Order Book. It looks like a list of buy or sell orders. They are categorized by volumes and prices. To identify the correct choice under the intended conditions, the matching engine checks every new order against the order book.
Algorithms of the Matching Engine
Market participants work in different conditions: basically in working trading hours, or in market opening or closing hours. Matching mechanisms play an enormous role in the efficiency of financial markets and good liquidity. Thus, it is very important to choose the relevant matching algorithm.
Market members use different algorithms to trade in Forex. A Czech mathematician and entrepreneur Martin Kabrhel and a professional poker player Karel Janecek in their article defined the most commonly used algorithms, which are:
- Pro-Rata algorithm. It allows to execute a file with large limit orders and minimize the spread in the natural mode.
- Price/Time or First-in-First-out (FIFO) algorithm. It allows to reduce the spread and prompts other orders to become a part of the queue with large limit orders. In comparison with Pro-Rata algorithms, FIFO algorithms can require more processing power.
Thus, these algorithms fulfill such important functions as:
- order matching,
- storage of records of open orders executed in a market.