I have a doubt which is haunting me since several days. I hope somebody with clear basics can help me out.
This is regarding limit orders and order matching. As I see, limit order is defined online from several sources as "An order to buy or sell stock at a specified price. The order can be executed only at the specified price or better."
I will ask this question with an example
Lets consider the following limit order book
----BID ---------- ASK----
(buyer 1)105.0 (seller 1)103.5
(buyer 2)104.0 (seller 2)105.0
(buyer 3)103.0 (seller 3)106.0
(buyer 4)102.0 (seller 4)107.0
(buyer 5)101.0 (seller 5)108.0
(for simplicity sake assume order quantity is same for all buyers & sellers)
Now here goes my questions. Please try to answer all 3 of them since they all are very closely related and each answer affects the answer to another question
1. How will the order matching happen. Will it be (buyer 1 with seller 2) or (buyer 1 with seller 1)
2. If you say matching will be (buyer 1 with seller 2) then why does a limit order definition says order can be executed at your limit price or better? In what scenario can this execution at better price exactly happen?
3. if you say matching will be (buyer 1 with seller 1) then at what price will the trade be executed- 105 or 103.5. if you are saying 103.5, then wouldn't it eventually imply that any limit sell order practically can never be executed at higher prices even though its definition says so?
To answer this question one has to understand how the order matching is done.Any orders which get matched result into a trade and then they are not part of the order book. In order book only unmatched orders are stacked. So the orderbook shown by you is not possible as it has sell and buy matching orders which will get matched, result into a trade and then removed from the orderbook and gets reflected in the trade book.
To understand ordermatching I have removed some orders as under :
----BID ---------- ASK----
(buyer 1)105.0 ********
(buyer 2)104.0 ********
(buyer 3)103.0 (seller 3)106.0
(buyer 4)102.0 (seller 4)107.0
(buyer 5)101.0 (seller 5)108.0
(for simplicity sake assume order quantity is same for all buyers & sellers).
This orderbook is possible as the unmatched orders are stacked.
Remember that the order matching has a price and time priority but in that order ie first price priority and then time priority..
Now a sell limit order to sell @ 103.50 enters the system. It will get matched with the buyer standing at 105 though the limit order was to sell upto 103.50 The new order entering the system therefore got sold at 105 ie at Rs 1.50 advantage. If another order comes in to sell at 105 limit, it will straight away gets matched with buyer at 105.00
Now I have removed 2 orders from the bid ( buy) side as under :
----BID ---------- ASK----
*********** (seller 1)103.5
*********** (seller 2)105.0
(buyer 3)103.0 (seller 3)106.0
(buyer 4)102.0 (seller 4)107.0
(buyer 5)101.0 (seller 5)108.0
(for simplicity sake assume order quantity is same for all buyers & sellers)
In this orderbook a new order enters to buy at 105 and this order will get matched with a seller standing at 103.5 so the order is executed at an advantage if Rs 1.50 After this order gets matched, suppose next order comes to buy at 104 but as now the best seller is at 105, this order will go into the stack of bid. But suppose before the order matching we did above this order to buy at 104 enters, then it gets matched with seller at 103.5who is standing in ASK stack so the buyer gets matched at 103.5 though his order was limit 104 ( meaning 104 or better.) He got a better price of 0.50 in this case.. The newly entering order always gets the advantage of ( or better ).The advantage is from the point of view or the newly coming in order. If there is no matching order in the opposite side, then the order goes and sits in the stack and now it looses the price advantage.So after it sits as a limit order to buy at 104 then new order comes to sell at 103.5 the trade will be at 104 and not at 103.5...so advantage to the newly entering order.
Smart_trade