Day 49 — State Snapshots
You will build a system that can crash, restart, and pick up exactly where it left off — without losing a single trade or a single cent of P&L.
Table of Contents
1. What You’re Building
Think of any program that keeps important data — a video game that saves your progress, a banking app that stores your balance, a chat app that remembers your messages. They all have the same problem: the program runs in memory (RAM), but RAM is wiped when the power goes off. To survive a crash, the program has to write its state to disk regularly.
Our
MockBrokerhas the same problem. It tracks cash balances, open positions, and trade history — all in memory. If the process dies, that data is gone. Today we build the mechanism that saves it safely.The technical name for this saved copy is a state snapshot.



