How does order matching happen in stock exchanges?
But how does the quantity matching happen? For example, if I want to buy 1000 shares at $100, but there is only one seller to sell 10 shares at $100, what happens then? This depends on the type of order you've placed. If you placed a fill-or-kill order, your order to buy or sell a certain number of shares is routed to the trading floor for immediate execution. If the order cannot be immediately filled, it is cancelled (killed) automatically. Note that the order must be filled in its entirety. Partial fills are not allowed. In your example, your buy order wouldn't be filled because it couldn't be matched to a sell order of the same volume. This is similar to an all-or-none order, which is an order that contains  A condition instructing the broker to fill the order completely or not at all. If there is insufficient supply to meet the quantity requested by the order then it is canceled at the close of the market. In this case, if your order wasn't matched to an order of the same volume by the time the market closes, it's cancelled. If you simply placed a market/limit order, and (in the case of the limit order), part of your order was matched to another order with the right price, that part of your order will be filled, while the rest will remained unfilled. To answer your question in its entirety there's more information we need (exchange, session, traded security, order type, etc.). Most exchanges support partial fills, that is your order will be partially executed and modified.  In your example, you'd get an execution of 10 shares at $100, and your order ticket will be modified to $100 for 990 shares. Like John Bensin explained, there are ways to prevent partial filling through order modifiers (e.g. Fill-or-Kill). My addition here is, there are also ways to prevent the other bit, i.e. do the partial fill but don't keep a modified order in the system.  You'd have to mark the order Immediate-or-Cancel (IoC).  In your case you'd be partially filled (10 @$100) and that's it.  For the remaining 990 shares you'd have to enter a new order.
That is mostly true, in most situations when there are more buy orders than sell orders (higher buy volume orders than sell volume orders), the price will generally move upwards and vice versa, when there are more sell orders than buy orders (higher sell volume orders than buy volume orders), the price will generally move downwards. Note that this does not always happen, but usually it does. You are also correct that for a trade to take place a buyer has to be matched with a seller (or the buy volume matched with the sell volume). But not all orders get executed as trades. Say there are 50 buy orders in the order book with a total volume of 100,000 shares and the highest buy order is currently at $10.00. On the other side there are only 10 sell orders in the order book with total volume of 10,000 shares and the lowest sell order is currently $10.05. At the moment there won't be a trade unless a new buyer or seller enters the market to match the opposing side, or an existing order gets amended upper or lower to match the opposing side. With more demand than supply in the order books what will be the most likely direction that this stock moves in? Most likely the price will move upwards. If a new buyer sees the price moving higher and then looks at the market depth, they would most likely place an order closer to the lowest sell order than the current highest buy order, say $10.01, to be first in line in case a market sell order is placed on the market. As new buy orders enter the market it drives the price higher and higher until the buy orders dry up. 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.  The about is the example as to how the orders would look like 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.   Incase 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. "I may be underestimating your knowledge of how exchanges work; if so, I apologize.  If not, then I believe the answer is relatively straightforward. Lets say price of a stock at time t1 is 15$ .  There are many types of price that an exchange reports to the public (as discussed below); let's say that you're referring to the most recent trade price.  That is, the last time a trade executed between a willing buyer and a willing seller was at $15.00. Lets say a significant buy order of 1M shares came in to the market. Here I believe might be a misunderstanding on your part.  I think you're assuming that the buy order must necessarily be requesting a price of $15.00 because that was the last published price at time t1.  In fact, orders can request any price they want.  It's totally okay for someone to request to buy at $10.00.  Presumably nobody will want to sell to him, but it's still a perfectly valid buy order. But let's continue under the assumptions that at t1: This makes the bid $14.99 and the ask $15.00.  (NYSE also publishes these prices.) There aren't enough people selling that stock. It's quite rare (in major US equities) for anyone to place a buy order that exceeds the total available shares listed for sale at all prices.  What I think you mean is that 1M is larger than the amount of currently-listed sell requests at the ask of $15.00. So say of the 1M only 100,000 had a matching sell order and others are waiting. So this means that there were exactly 100,000 shares waiting to be sold at the ask of $15.00, and that all other sellers currently in the market told NYSE they were only willing to sell for a price of $15.01 or higher.  If there had been more shares available at $15.00, then NYSE would have matched them. This would be a trigger to the automated system to start increasing the price. Here is another point of misunderstanding, I think.  NYSE's automated system does not invent a new, higher price to publish at this point.  Instead it simply reports the last trade price (still $15.00), and now that all of the willing sellers at $15.00 have been matched, NYSE also publishes the new ask price of $15.01.  It's not that NYSE has decided $15.01 is the new price for the stock; it's that $15.01 is now the lowest price at which anyone (known to NYSE) is willing to sell.  If nobody happened to be interested in selling at $15.01 at t1, but there were people interested in selling at $15.02, then the new published ask would be $15.02 instead of $15.01 -- not because NYSE decided it, but just because those happened to be the facts at the time. Similarly, the new bid is most likely now $15.00, assuming the person who placed the order for 1M shares did not cancel the remaining unmatched 900,000 shares of his/her order.  That is, $15.00 is now the highest price at which anyone (known to NYSE) is willing to buy. How much time does the automated system wait to increment the price, the frequency of the price change and by what percentage to increment etc. So I think the answer to all these questions is that the automated system does none of these things.  It merely publishes information about (a) the last trade price, (b) the price that is currently the lowest price at which anyone has expressed a willingness to sell, and (c) the price that is currently the highest price at which anyone has expressed a willingness to buy. ::edit:: Oh, I forgot to answer your primary question. Can we estimate the impact of a large buy order on the share price? Not only can we estimate the impact, but we can know it explicitly.  Because the exchange publishes information on all the orders it knows about, anyone tracking that information can deduce that (in this example) there were exactly 100,000 shares waiting to be purchased at $15.00.  So if a ""large buy order"" of 1M shares comes in at $15.00, then we know that all of the people waiting to sell at $15.00 will be matched, and the new lowest ask price will be $15.01 (or whatever was the next lowest sell price that the exchange had previously published)." "During the day, market and limit orders are submitted at any time by market participants and there is a bid and an ask that move around over time.  Trades occur whenever a market order is submitted or a limit order is submitted that at a price that matches or exceeds an existing limit order.  If you submit a market order, it may consume all best-price limit orders and you can get multiple prices, changing the bid or ask at the same time.  All that stuff happens during the trading day only. What happens at the end of the day is different.  A bunch of orders that were submitted during the day but marked as ""on close"" are aggregated with any outstanding limit orders to create a single closing price according to the algorithm established by the exchange.  Each exchange may handle the details of this closing event differently.  For example, the Nasdaq's closing cross or the NYSE's closing auction. The close is the most liquid time of the day, so investors who are trading large amounts and not interested in intraday swings will often submit a market-on-close or limit-on-close order.  This minimizes their chance of affecting the price or crossing a big spread.  It's actually most relevant for smaller stocks, which may have too little volume during the day to make big trades, but have plenty at the close.  In short, the volume you see is due to these on-close orders. The spike in volume most likely has no special information about what will happen overnight or the next day.  It's probably just a normal part of the market for illiquid stocks." "Market orders do not get priority over limit orders.  Time is the only factor that matters in price/time order matching when the order price is the same. For example, suppose the current best available offer for AAPL is $100.01 and the best available bid is $100.00.  Now a limit buy for $100.01 and a market buy arrive at around the same instant.  The matching engine can only receive one order at a time, no matter how close together they arrive. Let's say that by chance the limit buy arrives first.  The engine will check if there's a matching sell at $100.01 and indeed there is and a trade occurs.  This all happens in an instant before the matching engine ever sees the market buy.  Then it moves on to the market buy and processes it accordingly. On the other hand, let's say that by chance the market buy arrives first.  The engine will match it with the best available sell (at $100.01) and a trade occurs.  This all happens in an instant before the matching engine ever sees the limit buy.  Then it moves on to the limit buy and processes it accordingly. So there's never a comparison between the two orders or their ""priorities"" because they never exist in the system at the same time.  The first one to arrive is processed first; the second one to arrive is processed second." Also important to keep in mind is the difference in liquidity. The stock could be very liquid in 1 exchange but not in another. When times get bad, liquidity could dry up 1 one exchange, which results in a trading discount. "Yes when I place an order with my broker they send it out to the exchange. - For individual investors, what are some cons and pros of trading on    the exchanges directly versus indirectly via brokers? I may be mistaken(I highly doubt it), but from my understanding you cannot trade directly through an exchange as a retail investor. BATS allows membership but it is only for  Your firm must be a registered broker-dealer, registered with a Self Regulatory Organization (SRO) and connected with a clearing firm. No apple (aapl) is listed on the NASDAQ so trades go through the NASDAQ for aapl. Caterpillar Inc (CAT) is listed on the NYSE so trades go through the NYSE.  The exchange you trade on is dependent on the security, if it is listed on the NYSE then you trade on the NYSE. As a regular investor you will be going through a broker. When looking to purchase a security it is more important to know about the company and less important to know what exchange it is listed on. Since there are rules a company must comply with for it to be listed on certain exchanges, it does make a difference but that is more the case when speaking about a stock listed Over the Counter(OTC) or NYSE. It is not important when asking NYSE or NASDAQ? Selecting a broker is something that's dependent on your needs. You should ask your self, ""whats important to me?"", ""Do I want apps(IE: iPhone, android)?"" ""Do I need fancy trading tools?"". Generally all the brokers you listed will most likely do the trick for you. Some review sites: Brokerage Review  Online Broker Review 2012 Barron's 2012 Online Broker Review" Yes, the ADR will trade on a separate exchange from the underlying one, and can (and does) see fluctuations in price that do not match the (exchange corrected) fluctuations that occur in the original market. You are probably exposing yourself to additional risk that is related to: