The Trading Machine, One Slide At A Time
What actually happens between “buy” and “bought”?
If you have just joined a quant trading firm, your first month is a wall of acronyms: OMS, RMS, EMS, SOR, FIX, ITCH, colo, drop copy, refdata, TCA… and every meeting quietly assumes somebody already gave you the map. Nobody did. So here it is, as a deck.
How to use it: each slide builds itself, step by step, as it scrolls into view.
- Click a slide (or use the ‹ › buttons) to step through at your own pace; ↻ replays, ⛶ presents it fullscreen.
- The colours mean the same thing everywhere: blue is market data, orange is orders, red is risk, green is post-trade, violet is oversight.
Nothing here is specific to any one firm; it’s the textbook shape of electronic trading, the kind of thing you could reconstruct from exchange manuals and regulator rulebooks. Brief notes under each slide, an appendix for the parts the textbook skips, and a jargon glossary at the end. That’s it. The slides are the post.
The Agenda
- The map: the whole machine · front, middle, back · life of an order
- The data plane: market data · the order book
- The order plane: OMS, EMS, SOR · the order state machine · protocols
- The control planes: risk · compliance · reference data
- The money: alphas and execution · the speed layer · post-trade
- The appendix: the CS map · what you’re trading · the Indian edition · the sequencer · the order FSM
- Reference: the vocabulary · where to start
The Whole Machine On One Slide
Two planes moving in opposite directions, and everything else is bookkeeping around them:
- Market data flows out of the exchange (blue); orders flow into it (orange).
- The risk gate has veto power on the way in; the OMS remembers everything that happened.
- Orientation the slide can’t say out loud: a quant fund is the buy side, brokers and banks are the sell side, exchanges are venues.
Every slide after this zooms into one box.
Front, Middle, Back
Mandates, not floor plans:
- Front makes the money. Middle keeps the score honest. Back makes it real.
- The borders blur in practice; in a quant fund, engineers sit in all three.
- The slow halves kill firms faster than slow strategies do… breaks and unexplained P&L end careers quietly.
Life Of An Order
Ten steps, two clocks:
- Steps 1 to 6 are the fast loop: tick-to-trade, in microseconds.
- Steps 7 to 10 are the truth loop: milliseconds, then hours, then next day.
- A trade is not done when you get the fill. It’s done when it settles and reconciles, and the gap between those two “done”s employs half the industry.
The Market Data Plane
The exchange publishes each packet once over UDP multicast; everyone in the datacenter hears it at the same nominal moment. From there, it’s your problem:
- Two identical feeds (A and B) cover packet loss; sequence numbers expose gaps.
- You rebuild the order book yourself, packet by packet. There is no “the” book, only your copy.
- US wrinkle: a consolidated tape (the SIP) computes the official NBBO under Reg NMS,1 and fast firms take the direct feeds and beat it.
- When arrival times quietly stop being equal, regulators get involved… India has an entire saga about it.
The Order Book
The one data structure to internalize this year:
- Prices move on a grid (the tick), sizes come in lots, and at every price there is a queue.
- L1 is the best bid and ask, L2 is depth per level, L3 is every order in line.
- Under price-time priority, your queue position is your economics; for market makers, the queue is the game.
The Order Plane: OMS, EMS, SOR
From “I want 50k” to venue-native bytes:
- OMS is the system of record, EMS slices parent orders into child orders, the SOR picks venues, adapters speak each venue’s dialect.
- In HFT these blur into one custom stack and the strategy talks to the gateway directly.
- Drop copy gives risk and compliance their own independent feed of everything you do.
One Order’s State Machine
Follow the numbers: buy 500, ack, a fill for 200, another for 150, the final 150.
- Every arrow is an execution report (FIX 35=8) carrying cumQty (done) and leavesQty (still open).
- done + open must equal 500 at every step… the first invariant you’ll ever assert.
- The subtle corner: cancels (yours, or the exchange’s on a halt or disconnect) kill only the open quantity. The 350 already done stays yours.
- This is the happy path. The full state machine, in-flight windows and all, gets its own appendix slide.
How Machines Talk To Markets
Two dialects for one conversation:
- FIX is the street’s shared text language, alive since the 90s:2 flexible, verbose, everywhere reach matters.
- Native binary protocols (ITCH, OUCH,3 MDP3, EOBI) are each venue’s fast lane: fixed byte offsets, decoded like casting a struct pointer.
- The difference compounds: nanoseconds instead of microseconds, a few million times a day.
The Risk Machine
Three jobs wearing one name:
- Pre-trade: inline checks on every single order, inside the hot path’s latency budget.
- At-trade: kill switch, cancel-on-disconnect, open-order tracking while orders live.
- Post-trade: positions, margin, stress.
None of it is optional politeness: SEC rule 15c3-5 makes pre-trade controls law in the US,4 MiFID II RTS 6 mandates kill functionality in the EU.5 Ask an old-timer about Knight Capital.6
Compliance And The Regulators
The violet plane keeps the licence to make money, and it’s mostly engineering:
- Every order event archived; drop copies feeding surveillance independently of you.
- Clocks within 100 µs of UTC for HFT under MiFID II.7
- Every US order event reported to the Consolidated Audit Trail.8
I’ve made the wider argument before: a fair market is one the regulator can replay. Inside a firm, the same bar applies to you.
Reference Data
One golden record per instrument: identifiers, tick sizes, calendars, corporate actions, fees.
- Refdata bugs are special because nothing crashes; the system runs fine and is simply wrong.
- Wrong tick size rejects all day; a missed split invents overnight PnL; a stale calendar quotes into an auction you didn’t know existed.
- Needless to say: when a number looks insane, check refdata before you check your math.
Alphas, Strategies, Execution
An alpha is a prediction with a horizon, and the horizon decides the technology:
- Microsecond signals need the next slide; multi-week signals need better models.
- Execution is its own discipline: VWAP, POV, arrival price… getting size done without moving the market against yourself.
- TCA measures what it actually cost, and the loop from TCA back to research is what keeps you honest.
Alpha picks the destination; execution pays the toll.
The Speed Layer
My corner of the world.
- Inside the colo: layer-1 switches, kernel bypass, pinned busy-polling C++ with the NUMA topology minded, and FPGAs when software is still too slow.
- Between cities, physics takes over: microwave cuts Chicago to New Jersey from ~6.5 ms to ~4 ms one-way, near the ~3.9 ms light limit.9
- Treat every number as an order of magnitude; the ratios are the point. A blink is 150 ms.
The machines are not playing our sport.
Post-Trade: Where It Becomes Real
The emerald plane, where the trade becomes legally true:
- The CCP steps in via novation (buyer to every seller, seller to every buyer) and demands margin.
- Settlement moves securities against cash: T+1 in US equities since May 2024,10 T+2 in much of the world.
- Every day, your back office reconciles your books against the broker’s and the custodian’s. A mismatch is a “break”, and someone’s evening is gone.
The fill is instant. Ownership takes a day. Truth takes a reconciliation.
You Already Know This Machine
If you came into this from a CS degree, wondering how much of it is genuinely new: less than you’d fear. Strip the vocabulary off and half the deck is systems you have already built in college, just with a P&L attached.
Row by row, with the details:
| You know it as | The floor calls it |
|---|---|
| a sorted map of FIFO queues | the order book (slide 5): price levels are the keys, time priority is the queue |
| pub/sub over UDP multicast | the market data plane (slide 4): the exchange publishes once, everyone subscribes |
| building reliability on an unreliable transport | A/B feed arbitration: sequence numbers, gap detection, retransmission requests |
| a state machine with an invariant | the order lifecycle (slide 7): done + open = sent, at every step |
| a session protocol with heartbeats and replay | FIX: sequence numbers, resend requests, heartbeats… TCP’s ideas at message level |
| casting a pointer onto a fixed-offset struct | native binary decoding (slide 8): ITCH and friends are specs for exactly this |
| an event-sourced ledger | the OMS: current state is a fold over every execution report ever received |
tee on a stream | drop copy: the same order flow, duplicated to an independent consumer |
| config management | refdata (slide 11): wrong config never crashes, it just misbehaves expensively |
| a single-threaded event loop | the matching engine: strictly sequential per instrument, determinism is the product |
The computer science is the familiar part. What’s actually new is the domain: why the queue position pays, why the invariant is money, why the config file can lose a fortune quietly. That’s the part worth your first year.
The Vocabulary
The slides carried most of it. Here’s the rest of the week-one jargon, in five tables and no ceremony.
The things you trade
The deck talks about orders all day and never says what’s being bought. If markets are new to you, this is the missing slide zero.
| Term | Meaning |
|---|---|
| equity | a share of a company; what the cash segment trades |
| index | a basket standing in for a market (Nifty 50, S&P 500); traded via futures, options and ETFs |
| derivative | a contract whose value derives from something else: a stock, an index, a rate |
| future | lock a price today, settle later; margin posted up front makes it inherently leveraged |
| option | the right (not the obligation) to buy (call) or sell (put) at a strike price by an expiry; you pay a premium for it |
| expiry | the day a derivative stops existing; derivative desks live by this calendar |
| long / short | positioned to profit if it rises / falls; shorting equity means borrowing shares first |
| margin | collateral the clearing house demands so your promises are believable |
| hedge | a position whose only job is to cancel a risk you didn’t want |
Orders you can send
| Term | Meaning |
|---|---|
| market order | trade now at whatever the book offers; you pay the spread |
| limit order | trade at my price or better; may rest in the book |
| IOC / FOK | immediate-or-cancel (partial fill ok) / fill-or-kill (all or nothing); never rests |
| day / GTC | how long an unfilled order lives: today, or until cancelled |
| post-only | rest in the book or be rejected; never take liquidity |
| iceberg | display a small slice, hide the full size |
| peg | price tracks a reference (mid, best bid) automatically |
| stop | dormant until a trigger price trades, then goes live |
Market structure
| Term | Meaning |
|---|---|
| maker / taker | resting order that gets hit = maker (often earns a rebate); aggressor = taker (pays the fee) |
| auction | batch match at the open and close; the close is the day’s biggest liquidity event |
| halt / LULD | trading pauses; limit-up-limit-down bands stop runaway prices in US equities |
| dark pool | venue with no displayed book; typically matches at the midpoint, hides intent |
| DMA / sponsored access | trading venues directly through a broker’s membership and infrastructure |
| NBBO | the official US national best bid and offer, consolidated across venues |
| basis / roll | futures price minus spot; migrating positions to the next contract before expiry |
Risk and PnL
| Term | Meaning |
|---|---|
| notional | size times price: what the position is “worth” on paper |
| gross / net exposure | sum of absolute position values / the same sum with signs |
| mark-to-market | valuing positions at current prices; splits PnL into realized and unrealized |
| drawdown | peak-to-trough loss; the number risk managers actually fear |
| Sharpe | return per unit of volatility; the quant scoreboard |
| ADV | average daily volume; your size as a fraction of ADV predicts your impact |
| slippage | what you actually paid versus the price when you decided |
| adverse selection | your resting orders fill exactly when the price is about to move against you |
| locate / borrow | to sell short you must first find shares to borrow |
Latency
| Term | Meaning |
|---|---|
| tick-to-trade | market data in to order out; the headline latency number |
| wire-to-wire | measured on the wire by hardware taps, not by your own code’s opinion |
| p50 / p99 | median versus tail latency; in HFT the tail is the story |
| jitter | variance of latency; determinism often beats raw speed |
| colo / cross-connect | your servers in the exchange’s datacenter, cabled to its network |
If Your Desk Is In India
The deck is deliberately generic, and its legal examples lean US and EU because that’s where the textbook was written. But there’s a decent chance you’re reading this from Mumbai… and India’s copy of the machine has real personality. Some of it, to be honest, is ahead of the textbook.
The fine print, with sources:
| The deck says | Your Indian desk says |
|---|---|
| venues, plural, plus a consolidated tape | NSE and BSE, no consolidated tape, no NBBO: you take each venue’s own feed. And by contracts traded, NSE has been the world’s largest derivatives exchange five years running, and counting.11 |
| pre-trade risk checks are the law | same instinct, different shape: every algo needs exchange approval, and the exchange runs its own price and quantity checks in front of yours.12 Since 2025, retail algo orders carry exchange-assigned IDs too.13 |
| LULD bands | index circuit breakers at 10 / 15 / 20% halt the entire market; individual stocks get price bands instead of halts.14 |
| T+1 in US equities since May 2024 | since January 2023 here. India finished its phased move to T+1 before the US began.15 |
| the close is an auction | not yet! India’s close has been the VWAP of the last 30 minutes; a real closing auction only arrives in August 2026, for stocks with derivatives.16 |
| dark pools | none. Off-book size goes through the exchanges’ block-deal windows: on-exchange, size-gated, disclosed.17 |
| colo and cross-connects | NSE colo, with a history worth knowing before someone tells you the folklore version: the unfair millisecond. |
| fees are refdata | very much so: STT, stamp duty and exchange charges ride on every trade, and the tax line is part of the strategy math, not a rounding error. |
Add the rhythm: the market runs 9:15 to 15:30 IST with a pre-open auction, and derivative expiry days set the pulse of the week.
One more India-specific thing: NISM. SEBI’s certification institute runs a series of exams, and depending on your seat, compliance may sign you up for one in month one (Series VIII if you touch derivatives,18 Series VII if you sit near ops and settlement19). Don’t groan. The workbooks are free PDFs, and they’re quietly the official India edition of slides 3, 9 and 14.
The Architecture Everyone Reinvents
One more diagram, because you will meet this pattern in month one and nobody will name it for you. Exchanges run it. Fast firms run it. The build ladder below ends at it.
- One process (the sequencer) stamps a global order onto every event: orders, ticks, timers, everything. That stamp is the consensus; there’s no distributed agreement protocol in the hot path.
- Every consumer (strategy, risk, OMS, capture) reads the same stream and derives identical state. Disagreement between systems becomes structurally impossible, which is half of what slide 14 spends its life reconciling elsewhere.
- Recovery is replay: crash, rejoin, re-read the log from event #1, arrive at the same state. Determinism is the fault tolerance.
- It’s also the debugger. Any production moment can be reproduced tick by tick, which is worth more than any log line you will ever print.
The LMAX architecture is this pattern built around ring buffers; Jane Street’s exchange talk is this pattern grown into a venue. Once you see it, you can’t unsee it.
The Order FSM, Properly
Slide 7 showed one order’s happy path with real numbers. The full machine has more corners, and you should be able to draw all of them: every state, every event that moves it, and the two windows where you’ve asked for something and the exchange hasn’t answered yet.
Then make it an exercise, because it is one:
- Enumerate the events, not the states: ack, reject, fill, cancel ack, replace ack, unsolicited cancel, expiry. States are just what’s left behind after events, and the exchange’s execution reports are the only input that moves anything.
- The in-flight windows (PendingCancel, PendingReplace) are where the bugs live. Fills can and do land inside them: your cancel isn’t a cancel until the exchange says so, and the fill that raced it is still yours.
- Now represent it in code, and feel the floor drop. One atomic enum? Fine, until cumQty and leavesQty need to move together with the state… a torn read between them breaks the invariant. So: pack state and both quantities into one 64-bit word and swap it atomically? Single-writer with a seqlock for readers? A version counter the hot path validates before acting? Each of these is a real production design, and choosing between them is the exercise.
- Decide what happens on an illegal transition: a fill for an order you believe is Canceled, a duplicate execution report, a report for an order you’ve never heard of. The boring, correct answer: the exchange wins, log loudly, resync from a snapshot. Your enum is a cache of their truth.
Draw the diagram from memory before you write the enum. If your drawing has an arrow you can’t explain, so will your code.
Where To Start
- Learn the map (slide 1) until you can redraw it from memory. Whiteboard it. Seriously.
- Then the order book and the order state machine (slides 5 and 7); they sit underneath every conversation you’ll have for years. When slide 7 starts feeling trivial, the full FSM is the deep end.
- Go deep on whichever plane your team owns. Let the rest stay a map until it becomes relevant. It will.
- Interrogate your own firm; the deck is generic, your paycheck isn’t. Five questions for week one: which venues and segments do we trade? Which plane does my team own? What’s our tick-to-trade budget (microseconds and milliseconds are different careers)? Where does the truth live when two systems disagree? And what was our worst day, and what changed after it? Every firm has a Knight story. Learn yours early.
- The book everyone recommends is Larry Harris, Trading and Exchanges. To be honest, I haven’t read it myself yet… so take that as the street’s recommendation, not mine.
- The internet’s good corners, all free: Zerodha Varsity for India-flavoured basics (their futures and options modules are the gentlest on-ramp I know), Databento’s microstructure guide for the market data plane in real packet-level detail, Jane Street’s How to Build an Exchange talk for the matching engine from the inside, and Mechanical Markets when you’re ready to hear how HFT argues with itself.
- If your team is the speed layer: Martin Thompson’s Mechanical Sympathy blog (the name is the philosophy: Jackie Stewart’s point that you drive better when you understand the car), then the LMAX Disruptor and Martin Fowler’s write-up of the architecture around it: a single-threaded business core fed by lock-free ring buffers, doing millions of orders a second… in 2011.
- And build toys! Nothing teaches this stack faster than implementing it badly once. The ladder: an order book with sorted price levels and FIFO queues (slide 5); a matching engine on top with price-time priority and partial fills; an OMS that consumes your own fills and asserts done + open = sent at every event (slide 7); and finally the whole thing rewired as the sequencer, one process stamping a total order on every event while everyone else replays the same stream into identical state.
Maybe I’m biased toward the fast half of this picture; it’s where I’ve spent my career. But speed only wins trades. Truth keeps firms alive… and in six months you’ll be the one presenting this deck to the next fresher. Hopefully with better slides than mine!
References
Footnotes
-
FIX Trading Community, the standards body behind the FIX protocol ↩
-
Nasdaq data product and protocol specifications (ITCH, OUCH) ↩
-
SEC rule 15c3-5 adopting release: risk management controls for brokers with market access, 2010 ↩
-
Commission Delegated Regulation (EU) 2017/589 (MiFID II RTS 6), organisational requirements for algorithmic trading firms ↩
-
SEC administrative order against Knight Capital under rule 15c3-5, 2013 ↩
-
Commission Delegated Regulation (EU) 2017/574 (MiFID II RTS 25), clock synchronisation ↩
-
Laughlin, Aguirre and Grundfest, “Information Transmission between Financial Markets in Chicago and New York”, 2013 ↩
-
SEC press release: settlement cycle shortened to T+1, compliance date May 28, 2024 ↩
-
NSE press release: world’s largest derivatives exchange by contracts traded per FIA, fifth consecutive year, January 2024 ↩
-
SEBI circular CIR/MRD/DP/09/2012: broad guidelines on algorithmic trading ↩
-
SEBI circular: safer participation of retail investors in algorithmic trading, February 2025 ↩
-
SEBI circular SEBI/HO/MRD2/DCAP/P/CIR/2021/628: introduction of T+1 rolling settlement, September 2021; the exchanges’ phased rollout covered every listed stock by January 27, 2023 ↩
-
SEBI circular: introduction of the Closing Auction Session in the equity cash segment, January 2026, live August 3, 2026 ↩
-
SEBI circular: review of the block deal framework, October 2025 ↩
-
NISM Series VIII, equity derivatives: the mandated certification for approved users and sales personnel on the equity derivatives segment ↩
-
NISM Series VII, securities operations and risk management: the mandated benchmark for associated persons in broking operations and risk; the workbook is a free PDF ↩