Skip to main content

How a Stock Exchange Matches Buyers and Sellers

How an exchange matches orders: the order book, bid and ask, market versus limit orders, and why your fill can differ from the quote.

October 13, 2026AAdmin7 min read
How a Stock Exchange Matches Buyers and Sellers

Photo: Ehren TheBrandBuilder / pexels

Alpha Sentinel is a software platform, not a registered investment adviser. This article is educational, not investment advice. Full disclaimer at the end of this post.

You place an order from a hospital break room and wonder, a little absurdly, who is actually on the other end. A stock exchange matches buyers and sellers by collecting their orders in an electronic order book and pairing a buy order with a sell order whenever their prices are compatible, following published priority rules. There is no single person deciding. Understanding the mechanism helps you choose order types sensibly and explains why the price you see and the price you get can differ. The questions below walk through the process from order to trade.

Key Takeaways

  • Exchanges collect buy and sell orders and match them electronically according to price first and then time.
  • The bid is the highest price a buyer will pay and the ask is the lowest price a seller will accept.
  • A market order prioritizes execution, while a limit order prioritizes price, and each carries a trade-off.
  • Your broker routes your order, and the venue where it executes can vary.
  • Prices can move between the moment you decide and the moment your order executes.

What is an order book?

An order book is a running list of all the buy and sell orders waiting at an exchange for a particular security. Buy orders, called bids, are ranked from the highest price to the lowest. Sell orders, called asks or offers, are ranked from the lowest price to the highest. The best bid and the best ask sit at the top of each side.

The gap between them is called the spread. If the best bid is slightly below the best ask, no trade occurs until someone is willing to cross that gap, either a buyer raising their price or a seller lowering theirs. Securities that trade heavily usually have narrow spreads, while thinly traded ones can have wider spreads.

The book changes constantly as participants add, change and cancel orders. What you see on a quote screen is a snapshot of the top of that book and the price of the latest trade.

How does a match actually happen?

When a new order arrives, the exchange's system checks it against the opposite side of the book. If a buy order is priced at or above the best ask, it can be matched immediately with that sell order, and a trade occurs. If it is priced below the best ask, it joins the book and waits.

Exchanges follow priority rules to decide which orders match first. A common principle is price-time priority: orders at better prices go first, and among orders at the same price, the one that arrived earlier goes first. Specific rules vary by exchange and by order type, and they are published by the exchanges.

All of this happens electronically, usually in a tiny fraction of a second. Most investors never see the process. They see the result: a confirmation that their order was filled at a certain price.

What is the difference between a market order and a limit order?

A market order tells your broker to buy or sell right away at the best available price. It prioritizes getting done. The price you receive is usually close to the quote, but it can differ, particularly in fast-moving or thinly traded conditions.

A limit order sets a maximum price you will pay when buying, or a minimum you will accept when selling. It prioritizes price. If the market does not reach your limit, the order may not execute, or may execute only partly.

Neither is better in every situation. They trade one uncertainty for another: a market order is more likely to fill but has uncertainty about price, while a limit order controls price but has uncertainty about whether it fills. Understanding that trade-off is more useful than memorizing a rule.

Who decides where my order goes?

Individual investors do not usually send orders directly to an exchange. They send them to a brokerage, which routes them to a venue where they can be executed. That may be a national exchange, an alternative trading system or another type of market participant. Brokerages must follow regulatory requirements about handling customer orders, and they publish information about their routing practices.

If you want to know how your own brokerage handles orders, its disclosures and help pages are the right place to read.

Why does the price I see sometimes differ from the price I get?

Quotes are a moment in time. By the time your order travels from your device to your brokerage to a venue, the best bid or ask may have changed. In a calm, active market the difference is usually small. In a fast or thin market, it can be larger.

Order size matters too. If you place an order larger than the quantity available at the best price, part of it may be filled at the next price level, and then the next. A limit order protects you from paying more than your chosen price, though it may fill only partly or not at all.

Time of day also plays a role. Trading during extended sessions is typically thinner than during regular hours, which can widen spreads and make prices less predictable. Your brokerage will describe which order types and sessions it supports.

What does the process look like in a normal week? An illustrative example

The following is an illustrative example, not a recommendation. Imagine a surgeon who decides during her weekend review to adjust a long-term holding. On Monday she enters a limit order from her phone during a short break. Her brokerage routes it to a venue, and the order joins the book because it is priced below the best ask. It does not execute that morning. By afternoon, a seller meets her price and the trade is filled, and she receives a confirmation.

She did not need to understand every step to complete the transaction. But knowing what a limit order does let her accept that no fill is a normal result, not a malfunction. Had she used a market order, she would have been filled quickly at the then-current price, which might have differed slightly from the quote she saw when she decided.

Frequently Asked Questions

How does a stock exchange match buyers and sellers?

It collects buy and sell orders in an electronic order book and matches them when prices are compatible, using published priority rules, typically price first and then time. The process is automated and usually occurs in fractions of a second.

What is the bid-ask spread?

It is the difference between the highest price a buyer will pay, the bid, and the lowest price a seller will accept, the ask. A narrow spread usually indicates active trading, while a wider one is common in thinly traded securities.

Is a market order or a limit order better?

Neither is better in every case. A market order is more likely to execute but may fill at a slightly different price, while a limit order controls price but may not fill. The choice depends on what matters more to you for that trade.

Can I choose where my order is executed?

Usually your brokerage chooses the venue, according to its routing policies and regulatory duties. Its disclosures explain how orders are handled, and some brokerages offer additional routing options.

How The Shield works

On weekdays from 4:00 AM to 8:00 PM ET, The Shield checks the stocks on your watchlist every few minutes, using prices delayed about 15 minutes. When one of them moves into downward momentum below its moving average, it emails you what changed and the price. Alerts are informational, not recommendations, and may be delayed or missed.

If your schedule leaves little time to track your orders and holdings, a 7-day pass for The Shield from Alpha Sentinel is a practical place to begin. We watch. We alert. You decide.

The ShieldYour watchlist, watched during market hoursStart your 7-day pass$29 today. Your subscription renews automatically at $249/month after the 7-day trial unless canceled before renewal. Cancel in account settings.

FULL DISCLAIMER: Alpha Sentinel is a software platform that provides informational tools, including market scans and position-monitoring outputs. Alpha Sentinel is not a registered investment adviser, broker-dealer, certified public accountant, financial planner, or law firm. Nothing on this page or produced by the platform constitutes investment, tax, legal, or accounting advice; an offer or solicitation to buy or sell any security; or a personalized recommendation of any kind. The platform is not a substitute for the services of qualified professionals, and nothing in this article should be read as a recommendation that any reader manage their portfolio without professional guidance. All investments involve risk, including the risk of total loss of principal. Tax treatment depends on the user's individual circumstances and applicable law; consult a qualified tax professional regarding any tax-related question. The output of any software filtering or monitoring rule is not a prediction of future market behavior, and no software tool can be relied upon to warn users in advance of losses or to prevent losses. Past performance, whether of any security, strategy, or software signal, does not guarantee future results. Alpha Sentinel does not publish or warrant any hit rate, win rate, or similar performance metric, and users should not infer any such metric from the platform's outputs.

Frameworks, examples, schedules, and references to user types in this article are illustrative only and are not representations of typical results. Notification delivery times and service availability depend on third-party systems and may be subject to delays, errors, or failures.

SharePost on X