Blockchain & Cryptocurrency Glossary

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

  • search-icon Clear Definitions
  • search-icon Practical
  • search-icon Technical
  • search-icon Related Terms

Order Matching Algorithm

1 min read
Pronunciation
[awr-der mach-ing al-guh-rith-uhm]
Analogy
An order matching algorithm is like the set of rules a dating app uses to match people. The app might prioritize matches based on shared interests (price) and then by who signed up earlier (time). Different apps (exchanges) might have slightly different rules for making a match (executing a trade).
Definition
A set of rules or procedures programmed into an exchange's matching engine that determines how buy and sell orders are paired together to execute trades. Common algorithms prioritize orders based on price and then time of submission (Price-Time Priority).
Key Points Intro
Order matching algorithms are the rules an exchange uses to pair buy and sell orders and execute trades.
Key Points

Defines the logic for how buy and sell orders are matched.

Commonly uses Price-Time Priority (best price first, then oldest order at that price).

Ensures fair and orderly execution of trades.

Implemented within the exchange's matching engine.

Example
An exchange uses a Price-Time Priority matching algorithm. If there are buy orders for BTC at $50,000 (placed at 10:00 AM) and $49,990 (placed at 9:59 AM), and a sell order comes in at $50,000 or lower, it will first match with the $50,000 buy order because it has the best price. If multiple buy orders exist at $50,000, it will match with the one placed earliest.
Technical Deep Dive
The most common order matching algorithm is Price-Time Priority (FIFO - First-In, First-Out at a given price level). Sell orders are matched against the highest bid, and buy orders against the lowest ask. If multiple orders exist at the best price, the one submitted earliest gets priority. Other variations might include Pro-Rata matching (where orders at the best price are filled proportionally to their size), especially in futures markets. The choice of algorithm impacts market fairness, speed, and the incentives for different types of traders (e.g., market makers).
Security Warning
While the algorithm itself is usually transparently defined by the exchange, its implementation within the matching engine must be robust and secure to prevent errors or manipulation. For on-chain order matching, the smart contract code defines these rules.
Caveat
The specific implementation details of an order matching algorithm can have subtle effects on trade execution, especially for high-frequency traders. Understanding the matching rules of an exchange is important for optimizing trading strategies.

Order Matching Algorithm - Related Articles

No related articles for this term.