Unit 2 · Markets & Instruments — Session 01 of 07

Market Anatomy & the Life of an Order

Your strategy ends in one line of code that sends an order. After that, half a dozen firms touch it — a broker, a venue, a clearing house, a depository, a custodian — and each one takes a risk off your hands and charges for it. Learn the path once and you know where every cost and every failure lives. The core move: follow the order hop by hop, and put a price on each one — the fees you are billed, the spread you are not, and the risks the plumbing carries for you.

DURATION 1.5 h + lab LEVEL Foundations TRACKS QR · QT · QD · IND HANDS-ON Walk an order book; fire stops on 20,000 gapping paths; net 10,000,000 trades

2.1.1 Who touches your order

Between your submit() call and shares that are legally yours stand at least five firms. None of them is there by accident: each removes a risk you could not carry alone.

In Session 1.1 you met the buy side, which decides what to own, and the sell side, which sells it the service of trading. This session follows what happens when the buy side acts: one order, from your code to a line in a ledger — every intermediary, what it charges, and what breaks when it fails. Realistic backtests, execution algorithms and live systems all sit on this plumbing.

The cast: an exchange is a regulated venue that runs a public order book and matches buyers with sellers under published rules; only its members may send it orders. A broker is the member that does so for you: it accepts, checks and routes your orders, reports fills and holds your account. After the trade a clearing house confirms, nets and guarantees it; when it becomes buyer to every seller and seller to every buyer it is a central counterparty (CCP). Settlement — securities delivered against cash — happens in the books of a central securities depository (CSD), and a custodian holds the securities for you, apart from its own assets.

WHO TOUCHES YOUR ORDER — and the problem each one solves for you 1 · BEFORE THE TRADE 2 · WHERE IT TRADES 3 · AFTER THE TRADE YOU · YOUR CODE decides what to trade and sends an order to the broker BROKER checks, routes, reports fills; rents you its venue access REGULATORS · RULES, FEES SEC, FINRA (US); FCA (UK); national regulators, ESMA (EU) LIT EXCHANGE public book of bids and asks; matches buyers with sellers DARK POOL · ATS orders hidden until they trade, often crossed at the mid WHOLESALER · INTERNALISER a dealer fills you itself, off-exchange, from inventory CLEARING HOUSE · CCP buyer to every seller and seller to every buyer; nets CSD · SETTLEMENT delivers shares against cash: DTC, Euroclear, Clearstream CUSTODIAN holds your securities, kept apart from the broker's own Each hop takes a risk off your hands, and each one is paid for it.
fig 2.1.1 — the participants map: your broker routes the order to one of several kinds of venue, and everything after the match runs through a clearing house, a depository and a custodian
ParticipantUS exampleEU / UK exampleThe risk it takes off you
Brokera registered broker-dealeran authorised investment firmneeding your own exchange membership
ExchangeNYSE, Nasdaq, CboeEuronext, Xetra, London Stock Exchangefinding someone to trade with
Clearing house (CCP)NSCC (part of DTCC)LCH, Eurex Clearingthe other side failing to pay or deliver
Depository (CSD)DTC (part of DTCC)Euroclear, Clearstream; CREST in the UKpaying cash and never getting the shares
Custodiana custodian bank or the broker's custody armthe sameyour assets vanishing with a failed broker
📌 Key idea — every intermediary sells a risk transfer

The broker sells access, the exchange a counterparty, the clearing house certainty that the counterparty pays, the depository finality, the custodian safekeeping. Even the market maker quoting on the exchange is selling something: immediacy. Every cost in trading is the price of a risk someone else agreed to carry for you.

2.1.2 The life of an order, hop by hop

Seven hops, two clocks. The trade itself takes well under a second. Making it final takes until the next business day in the US (two in the EU and UK until October 2027) — and most of the plumbing exists to make that gap safe.

THE TRADE · on trade date T, in well under a second 1 · YOUR CODE an order: side, size, type, price, time in force 2 · BROKER CHECKS logs it in the OMS, runs pre-trade risk checks 3 · ROUTE the order router picks an exchange, pool or dealer 4 · MATCH the venue fills it; a fill report flows back to you AFTER THE TRADE · from the evening of T to settlement 5 · CLEAR the CCP becomes the other side (novation), nets, calls margin 6 · SETTLE shares move against cash at the CSD: delivery versus payment 7 · CUSTODY the shares sit in your account, held by the broker's custodian A fill is an acknowledgement; settlement is the commit.
fig 2.1.2 — the life of an order: four fast hops on trade date, then clearing, settlement and custody, which take until the settlement date

Your code sends the order — side, quantity, type, limit price, time in force (§2.1.5) — through the broker's API. The broker's order management system tracks its state (new, acknowledged, partly filled, filled, cancelled, rejected), and pre-trade risk checks ask whether you can afford it, whether it breaches a limit, and whether its price is absurd; in the US the SEC's Market Access Rule requires them. A smart order router then picks the venue (§2.1.3). There an order that can trade does; one that cannot waits in the book, and each execution comes back as a fill report. Now you own a promise, not yet a position: the clearing house nets it and holds margin against it (§2.1.6), and on the settlement date the depository swaps shares for cash.

HopWhoWhenWhat can go wrong
1 · orderyour codet = 0a bug sends the wrong size, twice, or forever
2 · checksbroker OMSmicroseconds to millisecondsrejection; a broker outage
3 · routebroker's routermillisecondsa venue that suits the broker, not you
4 · matchvenuemicroseconds, or never (resting limit)partial fill; a price far from the one you saw
5 · clearCCPtrade date, into the eveninga margin call, passed on to you
6 · settleCSDT+1 in the US; T+2 in the EU and UK until October 2027a failed delivery
7 · custodycustodianfrom settlement onthe broker fails
🧭 Margin note — the systems view

Read fig 2.1.2 as a distributed transaction: the fill is the acknowledgement, settlement the commit, the depository the database of record — and the clearing house guarantees the commit even if one side crashes.

💡 Looking ahead

Each hop returns as engineering: the order state machine in Session 15.1, the broker API and the FIX protocol in Session 15.3, pre-trade checks and the kill switch in Session 15.4, and the data every hop emits in Session 4.1.

2.1.3 Where orders trade

"The stock market" is dozens of venues competing for your order. Which one fills it decides your price — and a US retail order is often filled by no exchange at all.

A lit venue displays its orders: anyone can see the best bids and offers, and the exchange matches them by price, then by time of arrival (price-time priority, Session 14.1). But a fund showing a two-million-share sell order tells everyone a seller is coming. A dark pool hides orders until they trade, often crossing them at the midpoint of the public quotes; in the US such systems operate as alternative trading systems (ATSs) and disclose their workings on Form ATS-N (SEC 2018), while EU dark trading runs on venues under capped waivers from pre-trade transparency.

The third route is a dealer trading against you from its own inventory. US retail brokers send most orders to a handful of off-exchange market makers, the wholesalers; off-exchange activity, a partial proxy for retail trading, first passed 50% of US equity volume on a single day on 23 December 2020 (SEC staff report, October 2021). The EU cousin is the systematic internaliser, a firm dealing on its own account with client orders outside a venue "on an organised, frequent systematic and substantial basis" (MiFID II, Article 4(1)(20)).

VenueWhat others seeWho is on the other sideWhy you would use itWhat it costs you
Lit exchangeyour order, while it restsanyone: market makers, funds, algorithmsthe public price; the deepest poola taker fee; leakage for big orders
Dark pool / ATSnothing, until the trade printsother hidden orderssize without moving the priceuncertain fills; better-informed traders
Wholesaler / SInothing beforehandthe dealer itselfsmall orders filled at oncea conflict if the dealer pays your broker

Payment for order flow: the debated practice

Why would a wholesaler pay to trade with you? Small retail orders are on average uninformed, so filling them carries little adverse selection (Session 1.1). The wholesaler shares that value with the broker as payment for order flow (PFOF), which is how many US brokers charge zero commission. Critics see a conflict; defenders point to price improvement. Execution quality does differ: Battalio, Corwin and Jennings (2016) found limit orders did worse on venues paying the highest rebates, and Schwarz, Barber, Huang, Jorion and Odean (2025), sending 85,000 simultaneous market orders through six accounts at five brokers, found mean round-trip costs from 0.07% to 0.46%, excluding commissions — the same wholesalers gave different prices to different brokers, and differences in PFOF did not explain the gap.

🧭 Margin note — the rules, dated and by jurisdiction (as of September 2026)

PFOF. US: legal, with quarterly routing disclosure (Rule 606); the SEC's proposed Order Competition Rule, which would have sent certain retail orders to auctions before internalisation, was withdrawn on 12 June 2025. UK: effectively banned since the FSA's 2012 guidance (FG12/13). EU: banned by Regulation (EU) 2024/791, Article 39a; the last national exemption (Germany's) expired on 30 June 2026.

Order protection and best execution. US: Regulation NMS's Order Protection Rule (Rule 611, 2005) bars trading centres, wholesalers included, from trading through better protected quotes elsewhere, which ties prices to the national best bid and offer (NBBO); the SEC proposed rescinding it on 11 June 2026, still pending as of September 2026. Best execution itself is a broker's duty of "reasonable diligence" under FINRA Rule 5310. EU: MiFID II, Article 27 (from 3 January 2018), requires "all sufficient steps" towards the best result. Best execution as a duty is Session 15.6's.

2.1.4 The book: bid, ask & the price of now

Every lit venue shows two numbers first: the most anyone will pay and the least anyone will accept. The gap is what it costs to trade right now — and it grows with the size you want.

The bid is the highest price at which someone will buy right now, with the size; the ask (or offer) is the lowest price at which someone will sell. The bid-ask spread is ask minus bid; halfway between sits the mid price. Behind the best prices sit worse ones, level by level: the limit order book. A limit order — trade at a stated price or better — that cannot trade at once joins the book and provides liquidity; a market order — trade now at the best prices available — takes it.

The lab builds a small synthetic book for a $50 stock quoted in one-cent ticks (illustrative sizes, not market data). The top five of its 20 levels a side:

LevelBid sizeBidAskAsk size
best1,00049.9950.011,100
21,20049.9850.02600
31,70049.9750.031,200
42,60049.9650.041,400
52,20049.9550.051,500

The spread is $0.02 around a mid of $50.00: 4.0 basis points. A market buy takes the best ask first and, when that level runs out, the next — it walks the book. Measured against the mid, the cost of its volume-weighted average price splits exactly in two. With ask aa, mid mm, and qkq_k shares filled at price pkp_k on level kk, for an order of Q=∑kqkQ = \sum_k q_k shares:

p‾(Q)=1Q∑kpkqk,p‾(Q)−mm=a−mm⏟half-spread+p‾(Q)−am⏟walking the book\bar p(Q) = \frac{1}{Q}\sum_k p_k\, q_k, \qquad \frac{\bar p(Q) - m}{m} \;=\; \underbrace{\frac{a - m}{m}}_{\text{half-spread}} \;+\; \underbrace{\frac{\bar p(Q) - a}{m}}_{\text{walking the book}}

For a sell, the bid replaces the ask and the signs flip. The lab's sweep is three lines of array arithmetic:

size = levels["size"].to_numpy()
before = np.concatenate([[0], np.cumsum(size)[:-1]])      # shares resting ahead of each level
take = np.clip(qty - before, 0, size)                     # shares taken at each level
COST OF A MARKET BUY AGAINST THE MID, BY ORDER SIZE IN SHARES (SYNTHETIC BOOK) 0.0 bp 5.0 bp 10.0 bp 15.0 bp 20.0 bp 100: 2.0 bp 2.0 bp 100 1,000: 2.0 bp 2.0 bp 1,000 2,500: 3.8 bp 3.8 bp 2,500 5,000: 6.0 bp 6.0 bp 5,000 10,000: 9.1 bp 9.1 bp 10,000 25,000: 15.6 bp 15.6 bp 25,000
fig 2.1.3 — the cost of a market buy grows with its size: small orders pay only the half-spread, big ones also pay for every level of the book they empty

An order of 1,000 shares fits on the best ask and pays only the half-spread, 2.0 basis points. One of 10,000 shares ($500,000) reaches 7 levels (emptying 6), pays up to $50.07, averages $50.0457 and costs 9.1 basis points — $457 above the mid. At 25,000 shares the cost reaches 15.6 basis points. Twice the distance from the mid is the trade's effective spread — 18.3 basis points here — which Session 14.2 explains as the price of adverse selection.

Treat the walk as a first estimate of slippage: hidden orders may add depth, but others also see you coming and the book does not refill for free — market impact, which Session 14.3 measures.

📌 Key idea — the spread is the fee for immediacy

A market order buys certainty and pays in price; a resting limit order saves the price and pays in uncertainty. The cost of a market order is half the spread plus the depth it eats, and neither appears on any bill. Measure every fill against the mid when you decided to trade.

2.1.5 Order types & the gap

Order types are not a menu of features. They are one trade-off — certainty of execution against certainty of price — asked twice, and then given a lifetime.

A stop order is dormant until the market trades at or through its stop price; then it becomes a market order (FINRA). A sell stop below the market is the classic "stop-loss". A stop-limit order becomes a limit order instead, so it may not trade at all. Fig 2.1.4 puts the four together; a time in force then says how long the order lives.

CHOOSING AN ORDER TYPE — one trade-off, asked twice YOU WANT TO TRADE TRADE NOW, OR ONLY IF A TRIGGER IS HIT? now on a trigger MUST IT FILL, WHATEVER THE PRICE? MUST IT FILL, WHATEVER THE PRICE? yes no yes no MARKET ORDER fills now, best price first; pays the spread and depth risk: the price you get LIMIT ORDER your price or better, or it waits in the book risk: it never fills STOP ORDER dormant until the stop price trades; then a market order risk: gaps blow through it STOP-LIMIT ORDER dormant until the stop price trades; then a limit order risk: gaps leave it unfilled THEN SAY HOW LONG IT LIVES: DAY · GTC · IOC · FOK · AT THE CLOSE (MOC / LOC) Every order type trades certainty of execution against certainty of price.
fig 2.1.4 — the order-type decision: blue orders are certain to execute at an uncertain price, green ones certain of their price but not of executing; then a time in force says how long the order lives
Time in forceThe order lives…Typical use
DAYuntil the end of today's session, then expiresthe default for most orders
GTC — good till cancelleduntil it fills or you cancel it (brokers often cap how long)a limit or stop you want to leave working
IOC — immediate or cancelfor an instant: fills what it can now, cancels the resttaking liquidity without leaving a visible order behind
FOK — fill or killfor an instant: fills in full now, or not at allwhen a partial fill is worse than none
MOC / LOC — market / limit on closeuntil the closing auction, which sets the official closing price (a LOC trades only within its limit)funds that are valued at the close; the closing auction is Session 14.1's

In US equities your stop usually lives at your broker, not the exchange: NYSE stopped accepting new stop and GTC orders on 26 February 2016 (NYSE client notice, November 2015). The broker watches the trigger and sends the market order — one more system that must be up when it matters.

The gap: a Monte Carlo

You buy at $100 and place a sell stop at $95, believing your loss is capped at 5%. The lab tests the belief with a Monte Carlo simulation: 20,000 paths of a stock with 30% annual volatility and no drift, watched every five minutes for 63 trading days. Overnight, news arrives 12 times a year on average, gapping the price up or down by an exponentially distributed amount with mean 3% (log terms; all parameters illustrative). The stop fills at the first price at or below $95, before any spread.

Theory checks the simulation twice. An intraday trigger overshoots by part of one small step: for a Gaussian random walk the expected overshoot of a distant barrier is about βσΔt\beta\,\sigma\sqrt{\Delta t}, with β=−ζ(1/2)/2π≈\beta = -\zeta(1/2)/\sqrt{2\pi} \approx 0.5826 (ζ is the Riemann zeta function) — Siegmund's (1985) overshoot result, which is the Broadie–Glasserman–Kou correction for daily monitoring used in Session 2.4. Gaps are different: exponential gaps are memoryless, so given that one crossed the stop, the distance it went past, OO, is again exponential with mean η\eta. A stop-limit whose limit sits a log distance dd below the stop therefore fails to fill with probability

ℙ(O>d)=e−d/η.\Prob(O \gt d) = e^{-d/\eta}.
Within one quarterTriggered intradayTriggered by an overnight gap
Share of all triggers92%8%
Average fill below the stop price0.12% (theory 0.12%)2.98% (theory 2.91%)
Worst 5% of fills: below the stop by at least0.34%9.0%
Average loss from the $100 entry5.1%7.8%
Stop-limit at $93: not fillable at the opennever49.5% (theory 49.2%)
FILL VS STOP PRICE AFTER AN OVERNIGHT GAP (1,222 PATHS) — CORAL: STOP-LIMIT UNFILLED −15.0% −10.0% −5.0% 0.0% −16.0% to −15.7% −15.7% to −15.4% −15.4% to −15.1% −14.8% to −14.4% −14.4% to −14.1% −14.1% to −13.8% −13.8% to −13.5% −13.2% to −12.8% −12.8% to −12.5% −12.2% to −11.9% −11.9% to −11.6% −11.6% to −11.2% −11.2% to −10.9% −10.9% to −10.6% −10.6% to −10.3% −9.9% to −9.6% −9.6% to −9.3% −9.3% to −9.0% −9.0% to −8.7% −8.7% to −8.3% −8.3% to −8.0% −8.0% to −7.7% −7.7% to −7.4% −7.4% to −7.1% −7.1% to −6.7% −6.7% to −6.4% −6.4% to −6.1% −6.1% to −5.8% −5.8% to −5.5% −5.5% to −5.1% −5.1% to −4.8% −4.8% to −4.5% −4.5% to −4.2% −4.2% to −3.9% −3.9% to −3.5% −3.5% to −3.2% −3.2% to −2.9% −2.9% to −2.6% −2.6% to −2.2% −2.2% to −1.9% −1.9% to −1.6% −1.6% to −1.3% −1.3% to −1.0% −1.0% to −0.6% −0.6% to −0.3% −0.3% to 0.0% theory (memoryless gap) theory (memoryless gap)
fig 2.1.5 — where stops fill after an overnight gap: the histogram follows the memoryless theory curve, and the coral tail is every case in which a stop-limit at $93 could not have sold at the open

Three lessons. A 5% stop on a 30%-volatility stock sits inside ordinary noise: it fired on 75% of paths within a quarter, with no drift at all. Gaps are rare but decisive: 8% of triggers produced 68% of all the slippage past the stop, each landing on average 24 times further away than an intraday fill. And the stop-limit swaps one risk for another: after 50% of gaps it could not sell at the open — it rests at $93 while the stock trades below it, and a day order may expire unfilled, leaving you holding the stock you wanted out of.

The extreme case came on 6 May 2010: in the "flash crash", sell orders "including many retail stop-loss orders" met vanishing bids, and over 20,000 trades in more than 300 securities executed more than 60% away from their values moments before, some at a penny or less; the exchanges and FINRA later cancelled them (SEC & CFTC 2010).

⚠️ Pitfall — "my stop caps my loss at 5%"

A stop fixes where your exit starts, not where it ends: in the lab, positions stopped out by a gap lost 7.8% on average and one in twenty lost more than 13.6%. Cap risk with position size, assuming the gap will happen, and treat a stop as an exit rule, not insurance.

2.1.6 After the fill: clearing, settlement & custody

A fill is a promise — shares against cash, one business day later in the US (two in the EU and UK until October 2027). Clearing makes the promise safe, settlement keeps it, custody guards what you received.

Without a clearing house, every firm is exposed to every firm it traded with until settlement. With one, the contract between buyer and seller is replaced by two — buyer with CCP, CCP with seller — a step called novation. In US equities the CCP is NSCC, which in DTCC's words "becomes the legal counterparty to every trade, guaranteeing settlement and mitigating counterparty risk". Your clearing broker's counterparty risk becomes risk on one institution, backed mainly by its members' margin and a mutualised default fund — you still face your broker — and a web of promises becomes a star, which, crucially, can be netted.

NOVATION — the clearing house steps into the middle of every trade WITHOUT A CCP — everyone faces everyone FIRM A FIRM B FIRM C FIRM D n(n−1)/2 exposures · at best netted pair by pair WITH A CCP — one counterparty for all FIRM A FIRM B FIRM C FIRM D CCP nets · margins n exposures · one net amount per member per security Novation turns a web of promises into a star — and a star can be netted.
fig 2.1.6 — novation: without a CCP each pair of firms carries its own exposure; with one, each firm faces only the clearing house, which nets everything a member did into one obligation per security

Netting: why the plumbing batches

The lab simulates 200 days of one stock traded among 20 clearing members: 50,000 trades a day between random buyers and sellers, 500 shares on average. Netting pair by pair (bilateral) leaves 6.6% of gross volume to settle; netting each member against the CCP (multilateral) leaves 1.51%.

The theory is the central limit theorem: a member's net position is a sum of many signed trades, so it grows like the square root of the number of trades while gross volume grows linearly. For NN clearing members (here NN counts firms), MM trades a day and trade size ss:

multilateral netgross≈1𝔼[s]N𝔼[s2]πM,bilateral netgross≈1𝔼[s]N(N−1)𝔼[s2]πM\frac{\text{multilateral net}}{\text{gross}} \;\approx\; \frac{1}{\E[s]}\sqrt{\frac{N\,\E[s^2]}{\pi M}}, \qquad \frac{\text{bilateral net}}{\text{gross}} \;\approx\; \frac{1}{\E[s]}\sqrt{\frac{N(N-1)\,\E[s^2]}{\pi M}}

which predicts 1.51% and 6.6%: multilateral netting beats bilateral by a factor of N−1\sqrt{N-1}, about 4.4 here. Real markets agree: DTCC's chief executive told Congress that on 3 March 2020 over $3.5 trillion of shares moved through NSCC, but netting cut the money that had to settle by over 98%, to $80.3 billion (Bodson 2021). Netting has limits, though: a CCP that clears only one asset class can net less than bilateral netting across all of a firm's trades (Duffie & Zhu 2011).

Why not settle every trade instantly? Because real-time gross settlement "would eliminate the substantial efficiencies of netting" (same testimony): every trade would need its cash in advance. Batching buys capital efficiency at the price of time — and time is risk, which the CCP covers with margin. DTCC estimated that moving from T+2 to T+1 could cut NSCC's value-at-risk charges by as much as 40%. US equities have settled T+1 since 28 May 2024 (SEC rule adopted 15 February 2023); the EU moves on 11 October 2027 (Regulation (EU) 2025/2075), and HM Treasury published a draft statutory instrument on 20 November 2025 for the UK to move the same day, subject to approval by Parliament (status as of September 2026). Until then both settle T+2.

When the plumbing bites: January 2021

Margin is how the CCP's safety becomes your problem. As "meme stocks" such as GameStop swung wildly, on 27 January 2021 NSCC made intraday margin calls totalling $6.9 billion on 36 clearing members, bringing total required margin to $25.5 billion, and some brokers with mainly retail customers restricted trading in the most volatile stocks (SEC staff report, October 2021; the squeeze itself is in Session 2.2). The CCP protected the system by demanding cash; its members passed the squeeze on to customers. Session 2.4 shows the same machine in futures, where it runs every evening as variation margin.

Settlement and custody

At settlement the depository moves shares and cash together — delivery versus payment — so neither side can hand over its half and get nothing. Sellers must deliver on time, which is why a short seller borrows shares first (Session 2.2). Then your shares sit at the custodian, usually held in the broker's or custodian's name for you and segregated from the firm's own assets. If a US broker fails, SIPC protects customers up to $500,000, including $250,000 of cash, but "does not protect against the decline in value of your securities"; the UK's FSCS covers investments up to £85,000 per person per firm, and EU law sets a minimum of €20,000. Crypto venues often bundle broker, exchange and custodian into one firm, which is why custody risk gets its own treatment in Session 2.6.

📌 Key idea — clearing turns counterparty risk into liquidity risk

Once a trade is cleared you no longer worry whether the other side can pay; you worry whether your side of the chain can meet tonight's margin call. Central clearing doesn't make risk disappear; it pools it, prices it as margin and bills it in cash, on the days cash is scarcest.

2.1.7 Where every fee and risk sits

Put the whole path on one bill. The explicit fees are the line items you read; the spread and the book are the ones you actually pay.

EVERY HOP ON ONE BILL — what you pay there, and what can go wrong there HOP WHAT YOU PAY WHAT CAN GO WRONG BROKER commission — or zero, paid by order flow instead outages, rejects, the broker failing VENUE a fee to take liquidity, a rebate to make it halts, glitches, a worse price elsewhere THE BOOK half-spread + the depth you eat — never billed slippage; stops filling past their price CLEARING clearing fees; cash locked up as margin margin calls on the worst days REGULATORS SEC and FINRA fees on US sales rules change: date every fact SETTLEMENT settlement and depository fees fails; DvP removes principal risk CUSTODY custody and account fees broker failure: segregation, SIPC (US) Explicit fees are billed per share; the spread and the depth scale with your size and the day.
fig 2.1.7 — the fee and risk stack: every hop of fig 2.1.2 charges something and can fail somehow; the row that is never billed, the book, is usually the largest cost

The lab prices one round trip — buy 2,000 shares with a market order, later sell them the same way — in two $50 stocks: the liquid book of §2.1.4 and a thin one with a 20-basis-point spread and 13,400 shares displayed on its ask side against 68,600. Billed rates: a commission of $0.0035 a share and a clearing fee of $0.0002 a share (both illustrative); an exchange fee of $0.003 a share for taking liquidity, the Regulation NMS cap on fees for trading against a protected quote (a 2024 SEC amendment lowering it to $0.001 has been postponed to November 2027, as of June 2026); and, on the sale only, the SEC's Section 31 fee of $20.60 per million dollars (from 4 April 2026) and FINRA's Trading Activity Fee of $0.000195 a share, capped at $9.79 a trade (2026).

Round trip, 2,000 shares, $100,000Liquid large cap (bp)Thin small cap (bp)
Commission1.41.4
Exchange fees1.21.2
Clearing + regulatory0.320.32
Spread (half on each side)4.020.0
Walking the book2.239.9
Total9.1 ($91)62.8 ($628)
ONE ROUND TRIP OF 2,000 SHARES AT $50: COST BY COMPONENT, IN BASIS POINTS liquid large cap thin small cap 0.0 10.0 20.0 30.0 40.0 50.0 commission · liquid large cap: 1.4 1.4 commission · thin small cap: 1.4 1.4 commission exchange fees · liquid large cap: 1.2 1.2 exchange fees · thin small cap: 1.2 1.2 exchange fees clearing + regulatory · liquid large cap: 0.3 0.3 clearing + regulatory · thin small cap: 0.3 0.3 clearing + regulatory spread · liquid large cap: 4.0 4.0 spread · thin small cap: 20.0 20.0 spread walking the book · liquid large cap: 2.2 2.2 walking the book · thin small cap: 39.9 39.9 walking the book
fig 2.1.8 — one round trip, cost by component: the billed fees are identical for both stocks, while the spread and the book decide the total

The billed fees, mostly per share, come to 2.9 basis points in both stocks. The unbilled spread and depth are 68% of the liquid stock's cost and 95% of the thin one's, which costs 6.9 times as much to trade. In Session 2.3's terms, a round-trip cost cc is a simple return surrendered on every trip, so a fully invested strategy making nn round trips a year multiplies its wealth by (1−c)n(1-c)^n:

yearly cost drag=1−(1−c)n≈ncwhen nc is small.\text{yearly cost drag} \;=\; 1-(1-c)^n \;\approx\; n\,c \quad \text{when } n\,c \text{ is small.}

At 50 round trips a year — turning positions over about weekly — that is 4.5% a year in the liquid stock and 27.0% in the thin one (the linear shortcut would say 31.4%), before the strategy has earned anything. A backtest without costs is fiction; Session 6.5 gives transaction costs and capacity a session of their own, and slicing a large order to pay less of them is Session 14.4's subject.

⚠️ Pitfall — "zero commission means free trading"

The commission is a small line on the lab's bill: 1.4 of 9.1 basis points even in the liquid stock. A zero-commission broker is paid another way, often by the wholesaler that fills you, and fill quality varies a lot: Schwarz and co-authors measured mean round-trip costs from 0.07% to 0.46% across six accounts, excluding commissions — the same wholesalers gave different prices to different brokers, and the size of the PFOF did not explain the gap. So measure your own fills against the mid, and never backtest with commission as the only cost.

2.1.8 Try it

Open the companion lab, predict before you run, and change one thing at a time.

🔧 Try it (15 min, in the lab)

1. Fatter gaps. In section 2, set GAP_MEAN = 0.06. Predict the stop-limit's unfilled share from e−d/ηe^{-d/\eta} with d=ln⁡(95/93)d = \ln(95/93) before you run, then compare.
2. Run out of book. In section 1, add 100_000 to ORDER_SIZES. The displayed book runs out: what happens to the rest in a real market?
3. The √n rule. In section 3, set TRADES_PER_DAY = 200_000: predict the share left to settle, then try N_MEMBERS = 5.
4. A bigger ticket. In section 4, set QTY = 10_000. Which components grow, and which barely move?
Success: step 1 lands within 2 percentage points of your prediction, step 3 within 10% of it (relative), and you can say in one sentence why the billed fees in step 4 hardly move.


2.1.9 Glossary · Check yourself · Go deeper

Exchange — a regulated venue that runs a public order book and matches its members' buy and sell orders under published rules.
Broker — the firm that accepts your orders, checks them, sends them to venues for you, reports fills and holds your account.
Clearing house — the institution that confirms, nets and guarantees trades between the trade and its settlement.
Central counterparty — a clearing house that becomes buyer to every seller and seller to every buyer (novation), backed by its members' margin.
Custodian — a firm that holds securities on behalf of their owners, kept separate from its own assets.
Dark pool — a trading venue that does not display orders before they trade; in the US, a kind of alternative trading system.
Market order — an order to trade now at the best prices available: certain to execute in a liquid market, at an uncertain price.
Limit order — an order to trade only at a stated price or better: certain of its price, uncertain to execute.
Stop order — a dormant order that becomes a market order once the market trades at or through its stop price.
Bid — the highest price at which someone is currently willing to buy, with the size they will buy.
Ask — the lowest price at which someone is currently willing to sell, with the size; also called the offer.
Bid-ask spread — ask minus bid: what an immediate round trip costs at the touch, before any fees.
Mid price — halfway between the best bid and the best ask; the fair reference against which fill costs are measured.
NBBO — the national best bid and offer: the highest bid and lowest offer among US trading venues' protected quotes.
Payment for order flow — a payment from a market maker to a broker for routing it customer orders; legal with disclosure in the US, effectively banned in the UK and banned in the EU.
Time in force — the instruction that says how long an order stays live: day, good till cancelled, immediate or cancel, fill or kill, or until the close.
Settlement — the final delivery of securities against cash that completes a trade; T+1 for US equities since 28 May 2024.

Check yourself

1. Your strategy sends a market buy for 10,000 shares into the book of §2.1.4. What does it cost against the mid, and how much of that appears on your broker's statement?
9.1 basis points, or $457: 2.0 for the half-spread and the rest for eating into 7 levels of the book. None of it is on the statement: it is inside the fill price.
2. You hold a stock bought at $100 with a sell stop at $95. Results come out after the close, and the stock opens at $88. Where does the stop fill, and what would a stop-limit at $93 have done?
The stop becomes a market order at the open and sells near $88 — a 12% loss, not 5%. The stop-limit triggers too, but its limit is above the market, so it cannot fill at the open and you still hold the stock at $88. Only position size controls a gap.
3. 20 clearing members trade 50,000 times a day in one stock. Why does the clearing house need to move so little, and what would happen to that advantage if every trade had to settle instantly?
Each member's net position is a sum of many offsetting trades, so it grows like the square root of the number of trades: only 1.51% of gross volume is left after multilateral netting. Instant gross settlement removes the batch, so every trade must be funded and delivered on its own.
4. Your app shows an order as "filled". Name two things that can still go wrong before the shares are yours, and what protects you from each.
The other side can fail before settlement — the CCP guarantees the trade to your clearing broker, backed by members' margin and a default fund; and your broker itself can fail — your shares are segregated at the custodian, with SIPC protection (US) behind that. A shorter settlement cycle shrinks the first window: DTCC estimated T+1 could cut its value-at-risk margin by as much as 40%.
5. A broker advertises zero commissions and "best execution". What would you check before trusting it with an active strategy?
Its fills against the mid at the time of each order (its execution-quality and routing reports, or your own measurements), whether it takes payment for order flow and from whom, and its per-share fees. Commission is a small part of the bill; Schwarz et al. found mean round-trip costs from 0.07% to 0.46% across six accounts at five brokers, before commissions, with PFOF not explaining the gap.
🔧 Homework (~1 h before Session 2.2)

1. Your broker's bill. Put a real broker's published fees into the constants of lab section 4, rerun, and date every number. Which component moves most?
2. Limit-order fill odds. In a new lab section, rest a buy limit 1% below the price for one day under section 2's intraday model without news. Compare its simulated fill probability with the reflection principle for driftless Brownian motion, 2Φ(−d/(στ))2\Phi(-d/(\sigma\sqrt{\tau})), with the level moved βσΔt\beta\,\sigma\sqrt{\Delta t} further away for five-minute checks; assert agreement within 4 standard errors.
3. Read chapters 4 ("Orders and Order Properties") and 7 ("Brokers") of Harris (2003).
4. Map one foreign stock. Find its exchange, CCP, CSD and settlement cycle — the plumbing behind Session 2.2.

📚 Go deeper

  1. Harris, L. (2003). Trading and Exchanges: Market Microstructure for Practitioners, ch. 4 "Orders and Order Properties", ch. 5 "Market Structures", ch. 7 "Brokers" and ch. 25 "Internalization, Preferencing, and Crossing". Oxford University Press. ISBN 978-0-19-514470-3
  2. Bouchaud, J.-P., Bonart, J., Donier, J. & Gould, M. (2018). Trades, Quotes and Prices: Financial Markets Under the Microscope. Cambridge University Press. doi:10.1017/9781316659335
  3. Duffie, D. & Zhu, H. (2011). "Does a Central Clearing Counterparty Reduce Counterparty Risk?" Review of Asset Pricing Studies 1(1), 74–95. doi:10.1093/rapstu/rar001
  4. Schwarz, C., Barber, B. M., Huang, X., Jorion, P. & Odean, T. (2025). "The 'Actual Retail Price' of Equity Trades." Journal of Finance 80(5), 2507–2541. doi:10.1111/jofi.13467
  5. Battalio, R., Corwin, S. A. & Jennings, R. (2016). "Can Brokers Have It All? On the Relation between Make-Take Fees and Limit Order Execution Quality." Journal of Finance 71(5), 2193–2238. doi:10.1111/jofi.12422

Sources for the numbers

  1. US Securities and Exchange Commission (2023, 15 February). "SEC Finalizes Rules to Reduce Risks in Clearance and Settlement" (T+1, compliance date 28 May 2024). Press release 2023-29. https://www.sec.gov/newsroom/press-releases/2023-29
  2. European Parliament and Council (2025). Regulation (EU) 2025/2075 of 8 October 2025 amending Regulation (EU) No 909/2014 as regards a shorter settlement cycle in the Union (T+1 from 11 October 2027). https://eur-lex.europa.eu/eli/reg/2025/2075/oj/eng
  3. Financial Conduct Authority (2025, 21 November). "Government publishes draft Statutory Instrument on T+1 settlement" (draft SI of 20 November 2025; UK T+1 from 11 October 2027). https://www.fca.org.uk/news/statements/government-publishes-draft-statutory-instrument-t-plus-1-settlement
  4. Bodson, M. C. (2021, 6 May). Written testimony of the Chief Executive Officer, The Depository Trust & Clearing Corporation, before the US House Committee on Financial Services (NSCC netting, real-time settlement, T+1 margin estimate). https://www.congress.gov/117/meeting/house/112590/witnesses/HHRG-117-BA00-Wstate-BodsonM-20210506.pdf
  5. DTCC. "CNS®" (novation and the NSCC trade guarantee). https://www.dtcc.com/clearing-and-settlement-services/equities-clearing-services/cns
  6. US Securities and Exchange Commission, staff (2021, 14 October). "Staff Report on Equity and Options Market Structure Conditions in Early 2021" (off-exchange share; NSCC margin calls of 27 January 2021). https://www.sec.gov/files/staff-report-equity-options-market-struction-conditions-early-2021.pdf
  7. US Commodity Futures Trading Commission & US Securities and Exchange Commission (2010, 30 September). "Findings Regarding the Market Events of May 6, 2010." https://www.sec.gov/news/studies/2010/marketevents-report.pdf
  8. US Securities and Exchange Commission (2018). "Regulation of NMS Stock Alternative Trading Systems" Final rule (Form ATS-N; ATSs "including so called 'dark pools'"). https://www.sec.gov/rules-regulations/2018/07/regulation-nms-stock-alternative-trading-systems
  9. Directive 2014/65/EU (MiFID II), Article 4(1)(20) (systematic internaliser) and Article 27 (best execution). https://eur-lex.europa.eu/eli/dir/2014/65/oj
  10. Regulation (EU) 2024/791 (MiFIR review), Article 39a (prohibition of payment for order flow; exemptions until 30 June 2026). https://eur-lex.europa.eu/eli/reg/2024/791/oj/eng
  11. Financial Services Authority (2012, May). "Guidance on the practice of 'Payment for Order Flow'." Finalised guidance FG12/13. https://www.fca.org.uk/publication/finalised-guidance/fg12-13.pdf
  12. US Securities and Exchange Commission (2025, 12 June). "Withdrawal of Proposed Regulatory Actions" (including the Order Competition Rule). Release 33-11377. https://www.sec.gov/files/rules/final/2025/33-11377.pdf
  13. US Securities and Exchange Commission (2005, 9 June). "Regulation NMS." Release 34-51808. https://www.sec.gov/rules-regulations/2005/06/regulation-nms
  14. US Securities and Exchange Commission (2026, 11 June). "SEC Proposes Rescission of Regulation NMS Rules 611 and 610(e)." Press release 2026-54. https://www.sec.gov/newsroom/press-releases/2026-54-sec-proposes-rescission-regulation-nms-rules-611-610e
  15. FINRA. Rule 5310, "Best Execution and Interpositioning." https://www.finra.org/rules-guidance/rulebooks/finra-rules/5310
  16. FINRA. "Order Types" (market, limit, stop and stop-limit orders). https://www.finra.org/investors/investing/investment-products/stocks/order-types
  17. NYSE (2015, 16 November). "Elimination of Stop and GTC order types." Client notice. https://www.nyse.com/publicdocs/NYSE_Client_Notice_Removal_of_Stop_and_GTC_orders_112015.pdf
  18. US Securities and Exchange Commission (2026). Fee Rate Advisory 2026-2 (Section 31: $20.60 per million from 4 April 2026). https://www.sec.gov/rules-regulations/fee-rate-advisories/2026-2
  19. FINRA. Trading Activity Fee adjustment schedule, SR-FINRA-2024-019 (2026: $0.000195 a share, maximum $9.79 a trade). https://www.finra.org/rules-guidance/rule-filings/sr-finra-2024-019/fee-adjustment-schedule
  20. US Securities and Exchange Commission (2024, 18 September). "SEC Adopts Rules to Amend Minimum Pricing Increments and Access Fee Caps…" Press release 2024-137; and Atkins, P. S. (2026, 11 June). "Statement Regarding Minimum Pricing Increments and Access Fee Caps" (compliance postponed to November 2027). https://www.sec.gov/newsroom/press-releases/2024-137 · https://www.sec.gov/newsroom/speeches-statements/atkins-statement-minimum-pricing-increments-access-fee-caps-061126
  21. SIPC. "What SIPC Protects." https://www.sipc.org/for-investors/what-sipc-protects; FSCS. "What we cover." https://www.fscs.org.uk/what-we-cover/; Directive 97/9/EC on investor-compensation schemes. https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX%3A31997L0009
  22. Siegmund, D. (1985). Sequential Analysis: Tests and Confidence Intervals. Springer. doi:10.1007/978-1-4757-1862-1