Where you are. You can follow one card tap through five parties, read money as a tamper-evident record, and watch a goldsmith’s receipt change hands while the vault stays shut. All of that was one payment at a time. This lesson adds the machine that appears the moment payments pile up: many banks, owing each other all day in both directions, and a room that collapses the pile before anyone pays.
The walking clerks
London, a morning around 1770. From the door of each bank a clerk sets out with a leather bag. Inside the bag is paper: written orders that customers have signed, each telling its own bank to pay somebody else. The paper is a cheque, and because the customers of one bank keep paying the customers of another, every bank ends every day holding a stack of orders drawn on its rivals.
Cashing them means walking. The clerk carries Bank A’s stack of cheques drawn on Bank B to Bank B’s counter, presents them, and takes payment in coin and notes. Then on to Bank C with a different stack. Every bank sends a clerk to every other bank, twice a day.
Count it as an engineer. Each pair of banks needs its own exchange, so five banks need ten routes and ten banks need forty-five; every new bank adds a route to every bank already in town. The walking grows with the square of the banks, while the business only grows with the customers. It is point-to-point integration: every service talking directly to every other service, with coin in the streets as the transport layer.
Then somebody - the clerks, not the partners - counted the walking.
The idea in one paragraph
Bring every obligation to one place, total them against each other, and pay only what refuses to cancel. Alder’s customers wrote cheques on Birch all day, and Birch’s customers wrote cheques on Alder; the two stacks are mostly the same money travelling in opposite directions. Total everything and each bank is left with one signed number - what it owes the room, or what the room owes it - and only those differences change hands. The banks square up once, against the room, instead of pairwise, against everyone. The course later calls this netting, and it is the most reused trick in the plumbing; Module 3 builds the engine.
Gross, meet net
Two words carry this lesson, so take them now. The gross figure adds up every obligation as its own item: every cheque, at face value, as if each were paid separately. The net figure is what remains for one participant after everything that can cancel has cancelled: what others owe it, minus what it owes others, as one signed number.
Watch it on one pair. Say Alder owes Birch 120 today and Birch owes Alder 90. Gross between them: 210, two walks. Net: 30, one walk, a seventh of the coin. Nothing about either debt changed; the transport collapsed.
With five banks it stops being pairwise, and gets better. Cedar can owe Damson while Damson owes Alder and Alder owes Cedar, so the cancelling runs around rings, not just back and forth. The clearing house therefore nets each bank against the whole room: everything owed to it minus everything it owes. Those five nets must sum to zero, because every amount in the day is one bank’s debt and another bank’s claim - the pluses and the minuses are the same money counted twice. That zero is a conservation law, and the exercise asserts it.
Wider than the screen; scroll it sideways.
The exercise file carries one full day for five banks: sixteen obligations, 835 in gross. You will compute what actually moves.
Check yourself
1. Five banks need ten walking routes; ten banks need forty-five. What does the clearing house change about that growth?
Routes grow with pairs: for banks, so every new bank adds a route to every existing one. Through a hub, each bank keeps exactly one connection, and routes grow with instead of its square. It is the same move as replacing point-to-point integrations with a message bus: the payoff is not any single route, it is the growth curve.
2. The exercise asserts that the five net positions sum to zero. What is that assert actually checking?
Conservation. Every amount in the matrix is simultaneously one bank’s debt and another bank’s claim, so summing all the nets counts each amount once with a plus and once with a minus. A nonzero sum means the computation invented or destroyed money - a checksum the arithmetic gives you for free, which is why the script checks it before printing anything.
3. Gross was 835 and only 80 moved. Say precisely what shrank 10.4x and what did not shrink at all.
The money that had to move shrank. The obligations did not: all 835 was genuinely owed, and all 835 is discharged in full by the end of the day. Netting compresses transport, never debt; the ledgers finish in the same state either way.
4. Why did clearing happen at a fixed hour rather than continuously, cheque by cheque?
Cancelling needs a batch. Handled one at a time, every cheque moves at face value and gross equals net; the entire 10.4x lives inside the accumulation window. Same reason a write buffer needs a flush interval: write-through gets you one disk hit per operation and none of the coalescing.
5. Raise one existing debt and the total cash moved can go down. How?
Because movement depends on differences, not totals. A debt that opposes existing traffic cancels against it: raise Birch’s debt to Alder and it offsets what Alder already owes Birch, pulling both nets towards zero. Gross always rises when an obligation grows; net movement rises only when the change widens a difference. The exercise has you run exactly this.
Do this
Open code/clearing.py. Five banks, one day’s obligations as a matrix; gross_total is written, net_positions is yours. For each bank: everything owed to it (its column) minus everything it owes (its row), returned as a dict. The script asserts the nets sum to zero before it prints anything.
python code/clearing.py
Expected final line:
gross obligations 835; cash that actually moves 80; shrinkage 10.4x
Above it, one line per bank with its signed net; check by eye that they cancel. Then change one number: raise Birch’s debt to Alder from 90 to 120 and rerun. Gross goes up by 30, and the cash that moves goes down, from 80 to 50, because the new debt cancels against traffic already flowing the other way. That inversion - more owed, less moved - is netting in one experiment. The completed version is in solutions/clearing.py.
What you can now do. You can take a day of obligations between five banks, compute the gross total and each bank’s single net position, show that the nets sum to zero, and say exactly what shrank: the money that must move, 10.4x on this day’s matrix, while every debt is discharged in full. You have also met the trick’s name, netting, on a map that Module 3 turns into an engine. The next lesson speeds up the other half of the day: the squaring-up itself stops travelling on foot and leaves on a wire.