What is the order matching and execution process on the stock exchanges?
Order matching and execution on the stock exchanges take place on a First In First Out (FIFO) basis; orders placed first are executed first, depending on the bid price. Also known as the Price-Time Priority principle, the order book is sorted first by price and then by time; buy orders at higher prices are automatically prioritised over those at lower prices, and orders placed at the same price are executed in the order of their timestamp (order placement time).
For example, there are 2 buy orders for IDFC First Bank at Rs. 40 per share- one at 10:00 a.m. for 100 shares and another at 10:05 a.m. for 50 shares. Since both bids are at the same price, the order placed at 10:00 a.m. will be matched with sell orders first (can be over multiple sell offers). After this is executed, order matching for the next bid placed at 10:05 a.m. for 50 shares will begin.
In addition, the highest bid (buy order) is matched against the lowest offer (sell order). This is because the system views all buy orders from the point of view of a seller and all sell orders from the point of view of a buyer. Since a buyer would want to buy at the lowest price possible and a seller would want to sell at the highest price possible, the best buy order (highest price) is matched with the best sell order (lowest price).
To conclude, though the order book may show counter orders that match your bid/ask price, your order might not get executed if there isn't enough counter offers as per the price-time priority order matching system.