Learning objectives
By the end you can:
- Name and distinguish the core order types a trading venue offers (market, limit, marketable-limit, stop, stop-limit, IOC, FOK, GTC/day, iceberg (hidden/reserve), and pegged) and state, for each, what it buys you and what it costs you (certainty of execution vs. certainty of price, and how much of your intent it reveals to the rest of the market).
- Explain price-time priority (FIFO) as the rule that governs a limit order book, and, given a raw snapshot of price/size levels on both sides, compute the best bid, best ask, mid, spread (in price and in basis points), the size-weighted microprice, and the top-of-book order-flow imbalance, using the
synthetic-lobdataset's own schema. - Simulate walking the book: given a resting book and a marketable order, compute the size-weighted average fill price, the number of price levels touched, and the resulting slippage versus the best quoted price, including the case where the order is larger than the book's displayed depth and only partially fills.
- Implement a TWAP (time-weighted average price) scheduler (slicing an order evenly across time buckets with an exact, auditable remainder rule) and benchmark its realized execution against the unweighted TWAP price of the market's own tape.
- Implement a VWAP (volume-weighted average price) scheduler (sizing each time bucket's slice proportionally to a volume profile via the largest-remainder apportionment method) and benchmark its realized execution against the true volume-weighted VWAP price.
- Decompose Implementation Shortfall (Perold, 1988) into its four components (delay cost, execution cost, opportunity cost on any unfilled residual, and explicit fees) and compute the total shortfall in both currency and basis points.
- Model market impact with the practitioner's square-root law, split a modeled impact into its temporary (reverting) and permanent (information-driven) components, and invert the law to answer a capacity question: the maximum participation rate a fixed cost budget can afford.
- Measure execution quality honestly (arrival-price slippage, VWAP slippage, fill rate) and state, for a given trading objective (urgency vs. patience), which benchmark is the fair one and which can be gamed.
- (Copilot Discipline, R10.) Use a coding assistant to accelerate the boilerplate of an execution-algorithm function you have already designed and can compute by hand (never to originate the fill logic or the cost math) and review every generated line for a hallucinated broker/exchange API or a silently wrong sign convention before trusting it.
Prerequisites & connections
Builds on. CS1.01/CS1.02 (Python fundamentals, functions, and clean data structures) are assumed completely, every exercise here is ordinary functions over lists, tuples, and dicts. CS1.05 (Data Structures & Algorithms) is worth having fresh: a real production limit order book is implemented as a price-ordered structure, typically a pair of heaps or balanced trees, one per side, each level itself a FIFO queue of resting orders, and while this module's exercises work with an already-aggregated snapshot (a plain list of (price, size) levels, exactly what you get once you've grouped the synthetic-lob dataset's rows), the "why a heap and not a list" reasoning is a direct application of CS1.05's own material, not a new idea. Nothing from DA1.01–DA2.03 is a hard prerequisite (every graded solution in this module's code pack uses plain Python (math, arithmetic, sorting) precisely so a real desk's execution engine reads no differently whether it's a research notebook or a low-latency production path), though a production implementation of everything you build here would typically vectorize with NumPy/pandas once the by-hand version is understood, exactly this program's working agreement of by-hand before tool.
Feeds forward. QD1.03 (Building a Backtesting Engine) names "unrealistic fills" as one of its four classic pitfalls and requires realistic transaction costs and slippage to defeat it, this module is that cost/impact model; QD1.03 calls forward to it rather than re-deriving the square-root law or Implementation Shortfall itself. QD2.02 (Risk Systems) and QD2.03 (Performance & Attribution) both eventually report a strategy's net-of-cost returns, the "cost" side of that ledger is exactly this module's Implementation Shortfall and market-impact output. QD2.05 (the capstone) will ask you to cost and execute a strategy's trades honestly as one stage of the full pipeline, drawing on every exercise in this module directly. QM1.01 (probability, distributions) and QM1.03 (time-series, Monte Carlo) own the theory of a random walk and of volatility estimation, this module borrows a random-walk mid-price and a volatility number as inputs, never re-deriving why a random walk behaves the way it does; no theory is duplicated in either direction (C-3). Note also what this module is not: the Finance-Plus MS branch (Money & Monetary Systems) covers payment rails, central-bank operations, and monetary plumbing, a different meaning of "market structure" entirely, with zero overlap here.