Which are the order matching algorithms most commonly used by electronic financial exchanges? Is there a list of order matching algorithms somewhere?
In general, there are two groups of matching algorithms, one for each of the states of the market:
There's quite a variety of algorithms for auction trading, which is used before the market opens, on market close etc. but most of the time, the markets do continuous trading. I'll therefore go into the latter category here.
The most commonly used ones would be Price/Time priority and Pro-Rata. Both have been adapted and extended for various types of products and use cases, but for brevity, I'll only explain the basics here.
all orders at the same price level are filled according to time priority; the first order at a price level is the first order matched.
Say the order book, sorted by price and time looks like this:
Id Side Time Qty Price Qty Time Side
---+------+-------+-----+-------+-----+-------+------
#3 20.30 200 09:05 SELL
#1 20.30 100 09:01 SELL
#2 20.25 100 09:03 SELL
#5 BUY 09:08 200 20.20
#4 BUY 09:06 100 20.15
#6 BUY 09:09 200 20.15
NB: The order for sorting by time is ascending for buy-side orders and descending for sell-side orders, so that the order with the highest priority is always in the center and priorities decrease outwards (up or down, depending on the side).
Now imagine a new limit order to "buy 250 shares at 20.35" comes in, then it will be filled, in this order:
This leaves the order book in the following state:
Id Side Time Qty Price Qty Time Side
---+------+-------+-----+-------+-----+-------+------
#3 20.30 150 09:05 SELL
#5 BUY 09:08 200 20.20
#4 BUY 09:06 100 20.15
#6 BUY 09:09 200 20.15
The fills would be:
Leaving the following order book like this:
Id Side Time Qty Price Qty Time Side
---+------+-------+-----+-------+-----+-------+------
#3 20.30 100 09:05 SELL
#1 20.30 50 09:01 SELL
#5 BUY 09:08 200 20.20
#4 BUY 09:06 100 20.15
#6 BUY 09:09 200 20.15
For more, you might also want to take a look at the "Order matching" related documents on Rajeev's pages.