algorithmic-trading · Lesson 8

Execution & Market Structure

What happens in the milliseconds after an algorithm decides to trade — and why the price you get is rarely the price you saw on the screen.

6 min readIntermediateSean ShaReviewed by Sean ShaUpdated: July 2026
Execution & Market Structure — illustration of a neighborhood farmer's market where a shopper sends their friend across the sta

Educational purposes only. This content does not constitute investment advice. Read our disclaimer

StockCram is not a broker-dealer, investment adviser, or financial institution. All content is for educational and informational purposes only and should not be construed as personalized investment advice. Consult a qualified financial professional before making investment decisions. Past performance does not guarantee future results.

TL;DR

An algorithm decides to buy at one price, but by the time the order reaches the market the price may have moved — that gap is slippage. Orders travel across a web of exchanges and dark pools through order routing, chasing the best available price, the NBBO. Latency (the delay in getting there) is why a small group of high-frequency firms race for microseconds, an arms race most participants neither win nor need to enter. And a big order costs more because it eats through available liquidity and pushes the price against itself — which is why pros slice large orders into small pieces.

The Gap Between Deciding and Getting Filled

In the last lesson we looked at what strategies decide to trade. This one is about what happens after the decision — the messy, physical business of turning "buy 100 shares" into shares you actually own. What trips up almost everyone is this: the price your algorithm saw and the price it ends up paying are often not the same. The market moves in the fraction of a second your order is travelling, so you get filled a little higher (when buying) or a little lower (when selling) than you expected. That difference has a name — slippage — and it's the everyday tax on being a moment too late.

There's a core trade-off here, covered in depth in the Order Types course. A market order says "fill me right now at whatever the going price is" — you get certainty that it happens, but not certainty of the price. A limit order says "only fill me at this price or better" — you get certainty of the price, but not that it happens at all. At human speed that's a shrug. For an algorithm firing thousands of orders a day, that choice between certainty of execution and certainty of price compounds into real money.

The one-sentence version

The price on the screen is an invitation, not a promise. Between the instant an algorithm decides and the instant the order fills, the market keeps moving — and that gap is where execution costs quietly live.

How the Market Is Actually Wired

When you picture "the stock market," you probably imagine one building where all the trading happens. It isn't one place — it's a web of competing venues. A single stock trades on many exchanges at once, plus private venues called dark pools where large orders can be matched without showing their hand to everyone. When your order leaves the broker, a step called order routing decides which of these venues to send it to, trying to find the best available price.

Execution and market structure infographic: a screen decision routes across exchanges and dark pools to the NBBO, then fills a little worse — the gap called slippage — while big orders are sliced to limit their impact.
An order's real journey: from an on-screen quote, across many venues to the NBBO, to a fill that lands slightly worse. That gap is slippage, and big orders are sliced to soften their market impact.

To keep that fair, U.S. rules define the NBBO — the National Best Bid and Offer — which is simply the highest price anyone is currently willing to buy at and the lowest price anyone is willing to sell at, across every exchange's publicly displayed quotes. Dark pools don't post quotes, so they don't set the NBBO — but they must fill trades at or within it. Think of the NBBO as the single scoreboard stitched together from a dozen scattered games. One common way retail orders get routed is payment for order flow: a broker sends its customers' orders to a wholesale trading firm that pays the broker for that flow and fills the orders. That's simply a description of a routing arrangement that exists — how it's structured, not a judgment about it.

Latency and the Race to Be First

Every order takes time to travel — from the algorithm, through the broker, across cables, to the venue. That delay is latency, and for most of the market it's measured in comfortable milliseconds nobody sweats over. But for a small group of high-frequency trading firms, whole strategies live or die on being a few millionths of a second faster than the next firm. They pay to place their servers in the same building as the exchange's computers (called co-location) and use the straightest possible fibre routes, all to shave microseconds off the trip.

An arms race most people sit out

The microsecond race is a genuine competition — but it's an expensive, specialised arms race that a handful of firms fight over razor-thin margins. The vast majority of trading strategies don't win it and don't need to enter it. If a strategy only works when you're the fastest computer in the room, you've picked a fight against people with far deeper pockets. Most useful ideas historically have an edge that has nothing to do with raw speed.

Why Big Orders Cost More to Execute

At any moment there's only so much stock on offer at the best price. The list of everyone waiting to buy and sell, stacked by price, is the order book, and the sliver between the best buy and best sell price is the bid-ask spread. A small order fills inside that top layer and barely disturbs anything. A large order is different: it eats through the shares available at the best price, then the next-best, then the next — each layer a little worse. This is called market impact, and it means a big order effectively pushes the price against itself as it fills.

How much this hurts depends on liquidity — how deep the order book is. A heavily traded stock has a deep book, so even a big order climbs only a few layers. A thinly traded one has a shallow book, where the same order can move the price sharply. That's exactly why professionals rarely dump a large order in one go: they slice it into many small child orders spread over time, feeding it in gently so it blends with normal trading instead of stampeding the price.

A Worked Example: The 10,000-Share Order

Let's make this concrete with a single stylised order — all numbers here are illustrative, chosen to show the shape of the effect, not real quotes. Say an algorithm wants to buy 10,000 shares of a stock showing $50.00 on screen. Only the first couple of thousand shares are available at $50.00. To buy the rest, the order has to climb the book: the next slice fills at $50.03, then $50.07, and so on, each block a little pricier than the last. To see the effect clearly, the chart below plots the extra each slice pays above that $50.00 screen price, in cents per share:

Each slice pays a little more than the screen price (stylized)

Illustrative only. One 10,000-share buy order filling in five slices as it climbs the order book. Each bar is how much more that slice paid than the $50.00 screen price: the first slice fills right at $50.00 (0¢ extra), the last at $50.20 (20¢ extra). The climbing bars are market impact — the order pushing the price against itself as it eats through liquidity.

Each slice pays a little more than the screen price (stylized)Illustrative only. One 10,000-share buy order filling in five slices as it climbs the order book. Each bar is how much more that slice paid than the $50.00 screen price: the first slice fills right at $50.00 (0¢ extra), the last at $50.20 (20¢ extra). The climbing bars are market impact — the order pushing the price against itself as it eats through liquidity.0491318220Shares 1-2k3Shares 3-4k7Shares 5-6k12Shares 7-8k20Shares 9-10kExtra cost per share vs. $50.00 (¢)

Average all five slices together and the order fills at roughly $50.08 per share, not the $50.00 on the screen — about eight cents of slippage on every share, driven entirely by the order's own market impact. Eight cents sounds tiny, but across 10,000 shares that's around $800, and it happened before the trade could possibly "work." This is the everyday face of the two ideas in this lesson: the screen price was an invitation, and a big order is heavy enough to move the very price it's chasing. It's also why slicing, patience, and honest cost estimates matter as much to a serious system as the strategy that decided to trade in the first place.

Sources & Further Reading

Educational use only

Educational content only. StockCram isn't a broker or adviser, and we have no affiliation with any institution or tool we mention. Nothing here is a recommendation to trade in any particular way.

Key Takeaways

  • The screen price is an invitation, not a promise - Between the moment an algorithm decides and the moment it fills, the market moves. That gap — slippage — is the everyday cost of being a fraction of a second late.
  • The market is a web of venues - Orders route across many exchanges and dark pools chasing the best available price, the NBBO — the combined best bid and offer across every venue.
  • Latency matters most to a tiny few - High-frequency firms fight an expensive microsecond arms race with co-located servers, but most strategies neither win it nor need to enter it.
  • Big orders move the price against themselves - A large order eats through available liquidity and climbs the order book, so pros slice it into small pieces over time to reduce market impact.

Continue Learning

Frequently Asked Questions

Slippage is the difference between the price you expected when you decided to trade and the price you actually got when the order filled. Because the market keeps moving in the fraction of a second an order is travelling, a buy often fills a little higher and a sell a little lower than the price on the screen. It's the everyday cost of being a moment too late, and it grows with order size and thin liquidity.

The price on screen is a snapshot of the best available quote at that instant — an invitation, not a guarantee. By the time your order reaches a venue, other traders may have taken those shares or the quote may have shifted, so you fill at the next available price. For large orders there's a second reason: the order itself climbs the order book, filling later shares at worse prices. Together these produce slippage.

The NBBO — National Best Bid and Offer — is the highest price anyone is currently willing to buy a stock at and the lowest price anyone is willing to sell it at, combined across every U.S. venue. Since a single stock trades on many exchanges at once, the NBBO stitches together every exchange's displayed quotes into one scoreboard so orders can be routed toward the best available price. (Dark pools don't post quotes, so they don't set the NBBO, but they must fill within it.)

For most strategies, no. Chasing microseconds is a specialised, expensive arms race fought by a small number of high-frequency firms over razor-thin margins. If a strategy only works when you're the single fastest computer in the room, you've picked a fight against firms with far deeper pockets. Historically, most durable edges have come from the idea itself, not from raw speed.

At any moment only a limited number of shares are on offer at the best price. A large order eats through that top layer, then the next-best, then the next, each a little worse — an effect called market impact that pushes the price against the order as it fills. How much it hurts depends on liquidity: a deep order book absorbs size easily, a thin one moves sharply. That's why big orders are often sliced into small pieces over time.

Share