46

Say a security has been trading at under $20.10, and there are limit orders selling at $20.10 and $20.21. Then Simon issues a limit order to buy at $20.21. According to this explanation, Simon would end up buying shares at $20.10.

Why does the exchange favor the buyer here? I.e., why does the transaction execute at the seller's limit of $20.10 instead of the buyer's limit of $20.21? (I.e., why don't Inara/River get to sell at $20.21 / above their limit, but Simon gets to buy at $20.10 / below his limit?) Is the example flawed?

If it makes a difference, I'm mainly curious about NASDAQ and NYSE. I tried Googling for specs (e.g. this), but couldn't find anything. Only found that some random limit order book implementation executes the average of the buy/ask. Just curious how the system works.

xyz
  • 775
  • 2
  • 7
  • 10

2 Answers2

52

The Limit Order are matched based on amount and time. The orders are listed Highest to Lowest on the Buy Side. The orders are listed Lowest to Highest on the Sell Side. If there are 2 Sell orders for same amount the order which is first in time [fractions of milliseconds] is first.

Buy-Sell

The above is an example of how the orders would look on any exchange. Now the highest price the buyer is ready to pay is 20.21 and the lowest price a seller is ready to sell for is 20.25. Hence there is no trade.
Now if a new Buy order comes in at 20.25, it matches with the sell and the deal is made.
If a new Buy order comes in at 20.30, it still matches at 20.25.
Similarly if a Sell order come in at 20.21, it matches and a deal is made.
If a Sell order come in at 20.11, it still matches 20.21.

In case of market order, with the above example if there is a Buy order, it would match with the lowest sell order at 20.25, if there is not enough quantity , it would match the remaining quantity to the next highest at 20.31 and continue down. Similarly if there is a Sell market order, the it would match to the maximum a seller is ready to buy, ie 20.21, if there is not sufficient buy quantity at 20.21, it will match with next for 20.19

If say there are new buy order at 20.22 and sell orders at 20.24, these will sit first the the above queue to be matched.

In your above example the Lowest Sell order was at 20.10 at time t1 and hence any buy order after time t1 for amount 20.10 or greater would match to this and the price would be 20.10.
However if the Buy order was first ie at t1 there was a buy order for 20.21 and then at time later than t1, there is a sell order for say 20.10 [amount less than or equal to 20.21] it would match for 20.21.
Essentially the market looks at who was the first to sell at lower price or who was the first to buy at higher price and then decide the trade.

Edit [To Clarify xyz]:
Say if there is an Sell order at $10 Qty 100. There is a buyer who is willing to pay Max $20 and is looking for Qty 500. Your key assumption that the Buyer does not know the current SELL price of $10 is incorrect.
Now there are multiple things, the Buyer knows the lowest Sell order is at $10, he can put a matching Buy order at $10 Qty 100, and say $11 Qty 100 etc. This is painful.
Second, lets say he puts a Buy order at $10 Qty 100, by the time the order hits the system someone else has put the trade at $10 and his order is fulfilled. So this buyer has to keep looking at booking and keep making adjustments, if its a large order, it would be extremely difficult and frustrating for this Buyer. Hence the logic of giving preference.
The later Buy order says ... The Max I can pay is $20, match eveything at the current price and get the required shares.

bill
  • 1,027
  • 4
  • 11
  • 19
Dheer
  • 57,348
  • 18
  • 89
  • 170
4

The total limit book is a composite of all the orders on all of the exchanges.

While it's uncommon for a limit order posted beyond the NBBO to fill outside of the NBBO, it does occur.

For example, the best ask may be on exchange X, but for some reason the smart order routing algorithm may select exchange Y if it judges the net trade to be less costly, malfunctions, etc, and HFTs will immediately arbitrage the order between two exchanges, or the best order on exchange X disappears causing the order to fill above the NBBO.

The system isn't perfect because there are multiple exchanges, but that eventuality is extremely rare with equities since nearly every exchange will have orders posted at the NBBO because exchange equity fee and rebate schedules are extremely competitive, nearly identical. It is however more common with options since less exchanges as a percentage of the total will have orders posted at the NBBO because of very wide exchange rebate and fee schedules.

How a single exchange handles a new order that crosses an existing limit order is already addressed here: How do exchanges match limit orders?