0 · The machine from the top Draft
Markets and trading vocabulary
On this page
0.9 How a market works
An exchange runs a matching engine for each instrument (a stock, a futures contract, a BTC/USDT pair). Participants send it orders over the network; it matches buyers with sellers and tells everyone what happened. Chapter 6 goes into the data structures; this is the picture.
Orders. A limit order says “buy 2 BTC at 60,000 or better” and waits in the book until someone sells at that price. A market order says “buy 2 BTC now at whatever price is available” and trades immediately against the waiting limit orders. Orders can be cancelled or modified while they wait. Every order gets an id, and every change the exchange makes is a message.
The book. The order book is the set of waiting limit orders for one instrument, grouped by price. Buy orders are bids, sell orders are asks (or offers). The highest bid and the lowest ask are the top of book; the gap between them is the spread; the quantity waiting at each price is depth. Orders at the same price are usually filled in the order they arrived, so queue position matters. The smallest allowed price step is a tick.
Matching. When a new buy order’s price meets or crosses the best ask, the engine fills it against the resting asks, best price first, and publishes a trade. Any remaining resting quantity stays in the book; the incoming order’s remainder rests only if its type and time-in-force allow it. A market order does not become a resting limit order. A fill is the result for the participant: part or all of the order has traded.
Market data. The exchange publishes the book’s changes as a feed. At the start you take a snapshot of the whole book, then apply a stream of incremental updates: level changed, level removed, trade happened, each carrying a sequence number so you can tell whether you missed one. A gap means your copy of the book is wrong until you resynchronise. Traditional exchanges send this over multicast UDP with their own binary formats; crypto venues send it over WebSocket, often as JSON, with a REST snapshot to start from. The feed handler’s job is to keep a local copy of the book correct and to do it fast.
Market makers. A market maker keeps a bid and an ask resting in the book at the same time, earning the spread when both sides trade, and carrying the risk that the price moves while it holds a position (its inventory). Every time the market moves it must cancel and replace its quotes before someone trades against the stale ones. That cancel-replace loop, from a book update arriving to a new order leaving, is the hot path this book is about, and the reason a microsecond matters: whoever updates first keeps the spread, whoever updates last pays it.
0.10 Trading terms used in this book
The chapters use these without further explanation; section 0.9 gives the picture they fit into.
| Term | Meaning in this book |
|---|---|
| Order book, book | The resting buy (bid) and sell (ask) orders for one instrument, grouped by price |
| Bid, ask | A buy order, a sell order. The best bid is the highest buy price; the best ask is the lowest sell price |
| Top of book | The best bid and best ask with their quantities; the record every message touches |
| Spread, depth | The gap between best bid and best ask; the quantity resting at each price |
| Price level | All resting orders at one price on one side; the book is a ladder of levels |
| Tick | The smallest price increment. “30 ticks behind the best bid” is a distance in levels |
| Limit order, market order | An order with a price limit that may trade immediately or rest; an order that seeks immediate execution at available prices |
| Resting order | An order sitting in the book waiting to trade |
| Modify, cancel | A message that changes a resting order’s quantity, or removes it |
| Fill, trade | A match between a bid and an ask; the orders involved are “filled” |
| Snapshot, delta | A full copy of the book; one incremental change to it |
| Sequence number, gap | Exchanges number their messages; a gap means a lost message and a recovery step |
| Feed handler | The component that receives exchange packets, decodes them and rebuilds the book |
| Book handler | The code that applies one decoded message to the book |
| Quoter, market maker | A strategy that keeps its own bid and ask in the book; requoting is replacing them when the market moves |
| Inventory, position | What the strategy currently holds as a result of its fills |
| Hot path | The code that runs on every message between packet arrival and decision; everything else is off the hot path |
| Tick-to-trade, wire-to-wire | Latency from the last bit of an exchange packet arriving to the first bit of your order leaving |
| Kernel bypass | Reading packets straight from the network card in user space, skipping the Linux network stack |
| Colocation | Hosting your servers in the exchange’s data centre, so network latency is microseconds rather than milliseconds |
| Burst, lull | A run of many messages in a short time (after an economic release, say); a quiet spell with few or none |
| p50, p99, tail | Median and 99th-percentile latency; the tail is the slow end of the distribution, where the money is lost |
| FIX, SOH | A text protocol for orders; SOH (byte 0x01) separates its fields |
| SBE, WebSocket | A fixed binary message format used by exchanges; the TCP-based protocol most crypto venues publish over |