TL;DR Key takeaways
- A matching engine applies market rules to order-book state. Matching does not itself supply liquidity or complete settlement.
- Acceptance is not a fill. Order instructions govern any remainder, and a cancellation request cannot undo an executed trade.
- Compare execution rules, recovery and realistic workloads before headline speed or price. Building, buying or using a managed engine changes who performs the work, not whether it exists.
A trading platform can acknowledge an order almost instantly and still leave its customer unsure what happened. Was the order merely received, accepted into the market, partly filled, or cancelled before the next trade? A matching engine must produce an unambiguous answer—and the surrounding platform must preserve it.
Matching engine software turns eligible buying and selling interest into executions under a market’s rules. Speed matters, but it is not the starting point for evaluation. First establish what those rules promise, how the software applies them, and whether the resulting orders and trades remain accountable under load or during a failure.
The engine applies the rules; the order book holds the state
An order matching engine determines which orders can trade, at what price and in what quantity. It updates the remaining orders and produces execution events. The order book is the state it acts on: outstanding buying and selling interest for an instrument, organized according to the venue’s rules.
The publicly displayed book is a view of that state, not necessarily a complete copy. A market-data feed may aggregate quantities at each price, omit non-displayed interest where supported, or reach a subscriber after the internal book has changed. A price visible on screen is therefore not a promise that a newly submitted order will execute there.
Several neighboring responsibilities should remain distinct:
- Liquidity providers and other participants supply trading interest. Matching does not itself create liquidity.
- Routing and aggregation find or direct orders toward available execution sources. A local engine does not automatically search other venues for a better price.
- Account and risk systems track balances, available funds or credit, and reservations used in pre-trade controls.
- Settlement systems discharge the cash or asset obligations resulting from trades. Producing a fill is not the same as completing settlement.
These functions may be packaged together, but they answer different questions. An engine can match correctly while a platform has insufficient liquidity, stale market data or a downstream reconciliation problem.
Follow one order through the book
Consider a hypothetical continuous order book using price-time priority: better prices take precedence, and earlier orders go first at the same price. Prices below are dollars per unit of a fictional asset; fees are ignored.
The sell side contains:
- Seller A: 2 units at $100, entered first.
- Seller B: 3 units at $100, entered later.
- Seller C: 4 units at $101.
A buyer submits a good-till-cancelled limit order for 6 units at $100.
The request enters through a gateway. Validation checks its format, instrument and permitted instructions; pre-trade controls check whether the participant may place it. The exact division of work varies by architecture, but gateway receipt alone need not mean engine acceptance. The authoritative processing sequence determines where the order takes effect relative to other orders, amendments and cancellations. Invalid or ineligible requests are rejected rather than added to the book.
Assuming the buyer’s order passes the required checks and the book has not changed, it buys A’s 2 units first, then B’s 3 units. That is five units bought for $500. Seller C cannot supply the sixth unit because $101 exceeds the buyer’s limit.
The remaining unit rests as a bid at $100 because this order’s instructions allow it to stay open. Execution reports communicate the fills and remaining quantity. The platform should now show five units bought and one unit still open—not six units bought, and not a failed order.
Later, the buyer requests cancellation. If that cancellation takes effect before another eligible sell order, the remaining unit is removed. If a seller’s order takes effect first and fills it, there is nothing left to cancel. Sending a cancel request does not reverse a completed fill.
This simple sequence exposes two essential distinctions: acceptance is not execution, and a cancellation request is not a confirmed cancellation. Interfaces, account updates and customer support all depend on preserving those distinctions.
Order instructions decide what may happen next
A limit order sets the highest permitted purchase price or lowest permitted sale price. It can execute immediately when eligible opposing interest exists, but it can also remain unfilled because prices do not cross, earlier orders consume the available quantity, or other eligibility rules prevent a trade. A limit controls price; it does not guarantee execution.
A market order seeks execution against available eligible interest without specifying a limit price. It may consume several price levels. It may also be rejected or fail to fill completely if liquidity is insufficient or venue protection rules intervene. The handling of any unexecuted quantity must be explicit; a market order should not be assumed to become a resting limit order.
Time-in-force determines how long an order remains eligible and what happens to its remainder:
- Good-till-cancelled: a limit order can leave an unmatched remainder resting until filled or cancelled, subject to the venue’s duration rules.
- Immediate-or-cancel: execute whatever quantity is immediately available within the order’s constraints, then cancel the remainder.
- Fill-or-kill: execute the full quantity immediately under the applicable rules, or execute none.
Where supported, a stop instruction activates an order when a defined trigger occurs. The trigger source and resulting order type matter: a triggered stop-market order and a triggered stop-limit order have different price and completion risks. Triggering is not itself a fill.
Allocation rules are part of the market’s product
In the example, A trades before B because it arrived earlier at the same price. Under price-time priority, queue position matters. Changing an order’s price or quantity may change that position; the venue’s amendment rules determine which changes preserve or lose priority.
Pro-rata allocation answers the same allocation question differently. At an eligible price level, it distributes incoming quantity in proportion to qualifying order sizes. A larger order generally receives a larger share; it does not simply receive everything before smaller orders.
A usable specification must explain which quantities qualify, how minimum trading units and rounding work, and what happens to leftover allocation. Some rule sets combine proportional allocation with time priority or other preferences. The label “pro-rata” is not a complete algorithm.
These principles apply when evaluating either a traditional stock-exchange order book or a crypto exchange matching engine. The asset class alone does not establish the execution model. Auctions collect interest for a separate clearing process, while quote-driven and request-for-quote markets require different handling. Start with the intended market rules, not the assumption that every market uses a continuous book.
Architecture should preserve one authoritative outcome
A matching engine architecture diagram is useful only if it makes responsibility clear. Gateways handle participant connections and request validation. Pre-trade controls enforce trading permissions and risk constraints. Sequencing establishes the authoritative order of competing changes. Matching applies the allocation rules to book state. Reporting tells participants what happened, persistence supports recovery, and market-data publication exposes the appropriate public view.
These are logical responsibilities, not a requirement for a particular number of servers or services. The consequential question is whether every component agrees on the outcome of the buyer’s order.
Deterministic processing means that the same starting state and ordered inputs, under the same rules, produce the same results. This makes replay useful for recovery and investigation. The recorded inputs must include relevant state-changing events—not just new orders, but cancellations, amendments and any rule changes or time-driven events needed to reproduce the result.
Determinism also gives a precise answer to a cancel-versus-fill race. The outcome follows the authoritative sequence, not which message a client believes it sent first. Competing changes to the same book need a defined ordering even if surrounding work runs in parallel. Independent instruments, connections and suitable validation work can be processed concurrently; dependencies across books still need coordination.
Identifiers make those decisions traceable outside the engine. Order, request and execution identifiers need clear uniqueness and lifetime rules, including across restarts. If a connection drops and a client retries a request, duplicate handling should prevent an unintended second order. If an execution report is delivered again, downstream systems must recognize the same execution rather than book another trade.
Ask what “accepted” means when something fails
Return to the buyer’s six-unit order. Suppose the client receives an acceptance acknowledgement, then loses its connection before receiving the fills. On reconnect, it needs to discover the existing order and its executions—not submit a replacement blindly.
Now suppose the engine process or server fails instead. The platform needs a documented answer to a different question: which acknowledged events survive? Distinguish gateway receipt from engine acceptance, then establish whether accepted work is persisted locally or replicated before acknowledgement. Any failure boundary at which acknowledged work can be lost must be understood before launch.
Recovery tests should reconstruct the actual trading state. A snapshot provides a known starting point; replay applies the subsequent surviving event history. Together they should restore open quantities, completed executions, cancellations and relevant priority—not merely produce a book with plausible totals. Replay cannot recover inputs that were never retained.
Failover also needs one recognized authority. A replacement engine must not become active while an isolated former engine can still produce conflicting executions. Test that protection during network partitions as well as clean shutdowns.
Finally, recovery must extend beyond the engine. Clients need a way to recover missed execution reports. Market-data consumers need a defined way to detect gaps and resynchronize. Account systems and downstream trade records need reconciliation against authoritative executions without applying duplicates.
Test process failure, server loss and connection interruption separately. A system that restarts successfully has not necessarily preserved every promise made to its participants.
Measure speed without disguising the workload
Correctness, resilience and performance require separate evidence. A fast benchmark does not prove that allocation is correct or failover is safe. Equally, a correct engine may still be unsuitable if its queues grow faster than it can drain them.
Core matching time measures a narrowly defined part of processing. Gateway-to-report latency measures a wider path, potentially including validation, risk checks, queuing and report generation. Neither should be presented as client round-trip latency unless the relevant network and client-facing boundaries are included.
Averages conceal the requests that wait longest. Tail latency describes the slow end of the distribution—for example, the threshold within which 99% of measured requests complete. Sustained throughput measures what the system can keep processing; burst capacity also depends on how much work queues up and how quickly the backlog clears.
For a meaningful comparison, use a workload resembling the intended market: new orders, amendments and cancellations; orders that rest and orders that execute; realistic book depth; and concentrated activity in hot instruments. Distributed activity across many quiet books is not equivalent to contention in one busy book.
Run those tests with the intended risk controls, persistence and reporting enabled. Observe what happens at saturation: does the system apply backpressure, reject requests clearly, or accumulate delay? Include reconnect and recovery traffic. A useful performance result states its workload, configuration, measurement boundaries and failure behavior—not just one headline speed figure.
Build, buy or use a managed engine?
The delivery model should follow from the rules and operating requirements. Choosing it first can leave a team adapting its market to software it has already committed to.
Building fits when distinctive execution rules or integration requirements justify owning the implementation. That ownership includes the continuing work of testing, recovery engineering, monitoring, upgrades and incident response. Writing the initial matching algorithm is only part of the commitment.
Buying matching engine software fits when an existing product closely matches the required rule set and interfaces. The important word is “closely.” Integration code can translate messages, but it should not be expected to repair a fundamental mismatch in allocation, priority or acknowledgement semantics.
A managed engine can move agreed infrastructure and operating tasks to a provider. The platform still needs to define its market rules, validate outcomes, oversee the service and ensure that client, account and downstream systems agree. Contracts and runbooks should identify who diagnoses an incident, authorizes failover and communicates with participants.
Compare options using the same acceptance scenarios before comparing prices. The worked example in this article is a starting point: verify its fills, resting remainder and cancellation, then repeat it with retries, failures and competing messages. Extend those tests to the actual instruments and rules the platform needs.
Total cost includes integration, testing, operating staff, support, upgrades and migration—not just licence or hosting charges. Assess change control too: which configuration changes can alter execution behavior, who approves them, and which tests must run again? Establish data-export and exit arrangements early. Moving to another engine requires more than an exported list of prices; it needs a controlled treatment of open orders, history, identifiers and downstream reconciliation.
For FX, settle the execution model before issuing the RFI
An FX matching-engine RFI should first establish whether the platform needs a continuous order book, streamed-quote execution, RFQ handling or a combination. Otherwise, vendors may be answering different questions under the same product label.
Clarify whether prices are firm or indicative, when quotes expire, and which conditions make a price executable for a particular participant. Credit limits and counterparty eligibility can prevent execution even when an attractive price is visible. If last look applies, specify the provider’s opportunity to accept or reject an attempted trade, including timing, rejection rules and the meaning of acknowledgements before final execution.
Then connect that model to order handling, participant connectivity, required audit events and downstream trade handoff. The decisive issue is not whether software can compare two prices quickly, but whether it can correctly represent when those prices create an executable trade for those counterparties.
Conclusion
A matching engine is best evaluated as an implementation of market rules, not as a speed claim. Follow an order from validation to execution, remainder and cancellation; then ask whether the same outcome stays traceable through retries, load and failure. Once those answers are clear, performance figures and build-or-buy choices become meaningful comparisons.
For requesting more information about how we can help reach out to us. We're here to help and answer any questions you may have.