fivenines
13/39

Guided Problem

PFX Build 10: Settle from the Fact Stream

Time
20m
Level
foundation
Artifacts
not specified
Progress0%
Lesson 1.10

Post-trade: clearing and settlement

What happens after the match: netting, settlement, and reconciliation — the machinery that makes a fill report into actual ownership.

Matching emits durable fills, and risk has already reserved the assets those fills consume. Post-trade turns those decisions into legal and ledger ownership.

The obvious shortcut is to make the matching engine call the depository synchronously or let it mutate custody balances as part of the matching transaction. Yet post-trade is an idempotent consumer of the immutable fill stream; settlement moves cash and shares together, and replay reconciliation can reproduce every ledger obligation.

A fill report says "Alice bought 100 ACME from Bob at 10.00." Post-trade turns that sentence into moved assets, in three stages:

flowchart LR
    TF["Trade feed from the core — every fill, all day"] --> CAP["1 · CAPTURE: enrich, assign trade IDs, confirm to both parties"]
    CAP --> NET["2 · NETTING: collapse each member's trades to one obligation per instrument"]
    NET --> STL["3 · SETTLEMENT at T+1: delivery versus payment — shares and cash swap atomically"]
    STL --> LED[("Custody ledger — the record of who owns what")]
    LED -.-> REC["Reconciliation: ledger vs journal replay — must match to the cent"]
    
The post-trade pipeline. It consumes facts, so it can run minutes behind, crash, and replay without ever touching trading availability — the payoff of the 1.1 tier split.

Netting is the volume crusher. A market maker might trade ACME 40,000 times today — buys and sells interleaved — yet net to: deliver 1,200 shares, receive 12,000 in cash. Settlement systems move the net, turning tens of millions of trades into thousands of transfers. (Real-world equities interpose a clearing house that becomes buyer to every seller and seller to every buyer — novation — so a defaulting member is the clearing house's problem, backed by margin, not their counterparties'. Our in-house version keeps the same shape.)

Settlement is delivery versus payment (DvP): shares and cash move in one atomic operation or neither moves. No state exists where Bob has given up shares but lacks his money. Within our own custody ledger this is a database transaction; against external banks and depositories it becomes coordinated batches with explicit failure handling.

Reconciliation is the immune system. Continuously, and fully at day's end: replay the journal, recompute what every account should hold, and diff against the ledger. Any nonzero diff pages a human. Position integrity beats availability — a market that is up but paying the wrong people is worse than one that is briefly down.

The depository is delayed for an hour. Trading should continue while obligations queue durably. When service returns, retries must not settle one fill twice, and the final ledger must reconcile with the same journal sequence that produced the trades.

Capture → net → settle (DvP) → reconcile. Netting collapses millions of trades into thousands of transfers. Reconciliation against journal replay is non-negotiable; integrity outranks availability.

Next step

See what actually stuck.

Take the practice scenarios now.