📚 Notes
Engineering notes: write-ups on the good stuff of system design, software architecture and distributed systems — distilled from classic books and articles.
Simulators
Solution Architect
Notes on the good stuff of system design: requirements & UML, SOLID & design patterns, architecture & API styles, databases & caching, microservices & distributed patterns, system design practice and a securities-trading case study.
▶ OpenAlgorithm Simulator
Type in your own data and watch the algorithm run on it: 14 models, from linked lists, stacks and queues through sorting, AVL and 2-4 trees, hash tables, graphs and string matching to dynamic programming — one step at a time, with the matching line of Go and TypeScript lit up beside the drawing.
▶ OpenOrder Book & Matching
Put your own order into a live order book and watch the exchange work through it: continuous matching order by order, the ATO/ATC call auction and its single clearing price, the time priority an amendment throws away, the ExecutionReport chain behind every order, and the band, tick and lot rules that reject an order before it ever reaches the book.
▶ OpenFIX Session
Watch a FIX session open, survive, break and come back, every message drawn as an arrow between two lifelines: the Logon handshake and why silence is the bad signal, sequence gaps and the resend that patches them, what one flag decides when you reconnect, and the question the session layer cannot answer — did my order actually get through?
▶ OpenT+2 & Buying Power
Follow a trade from the moment it fills to the moment the assets are actually usable: why the morning of T+2 is still too early, the three reasons your balance is not the number you can spend, the multilateral netting that makes a two-day cycle necessary, and who ends up carrying it when somebody is short on the settlement day.
▶ OpenIsolation Levels & MVCC
Run the same interleaving of two transactions at different isolation levels and watch the answer change, with the row's version chain drawn underneath: the dirty read, the non-repeatable read and its phantom cousin, the write skew that survives REPEATABLE READ without leaving a trace, and a race on a balance written four ways — one wrong and three right for different reasons.
▶ OpenLocks & Deadlock
Watch two transactions take locks and wait on each other, with the wait-for graph drawn underneath: the classic A-to-B transfer deadlock and why a consistent lock order is a proof rather than a mitigation, the upgrade deadlock that needs only one row, the queue behind a slow lock holder that raises no error at all, and the missing index that turns a one-row update into a table-wide block.
▶ OpenRate Limiting
Feed one request stream into four rate-limiting algorithms at once and watch which lets what through: the fixed window, sliding window, token bucket and leaky bucket side by side, including the boundary burst that reading about never quite makes real — and what happens the moment there is more than one server, when the limiter installed to protect the system turns out to race against itself.
▶ OpenThe trading-system spine
01FIX Protocol
Notes on FIX 4.2/4.4 for securities systems: tag=value message anatomy, session layer & sequence numbers, the order lifecycle, 4.2 vs 4.4, recovery after disconnects, engine operations & multi-venue gateway.
▶ Open 02OMS
Notes on the broker-side Order Management System: the order state machine & FIX mapping, pre-trade risk checks, idempotency, mid-session recovery & reconciliation, the order-entry hot path and a reference architecture.
▶ Open 03Money & Idempotency
Notes on handling money correctly in software: why float is a disaster, minor units & rounding, races on balances, double-entry, idempotency keys, the outbox pattern and reconciliation.
▶ Open 04Settlement & SWIFT MT
Notes on post-trade — where money and securities actually change hands: the T→settlement lifecycle, instructions & reference data, MT 540–548, matching/netting/cut-offs, fails, reconciliation, ops runbook and the Vietnam context.
▶ Open 05Market Data
Notes on the other half of a broker — market data: feed contracts & canonical ticks, snapshot/incremental, sequence-gap recovery, order book invariants, conflation, WebSocket fan-out, freshness & degraded modes, storage & replay.
▶ Open 06Margin & Collateral
Notes on the credit lifecycle in a brokerage — invariants over ratio formulas: collateral & haircuts, pre-order reservation, mark-to-market, interest accrual, margin calls, forced liquidation, exceptions & audit.
▶ Open 07PnL & ROI
Notes on the question every broker app answers differently: cost basis & weighted average, realized vs unrealized, why deposits break every subtraction (TWR vs MWR), fees & a tax on proceeds rather than profit, corporate actions, margin ROI and the invariant tying it to the ledger.
▶ OpenDeeper business domains
Custody & back-office
A share is a row in a ledger, and which ledger is the real one runs through everything here. Why a client holding 1,000 shares may only sell 600, why one quantity column can never answer that, the invariant tying your clients' balances to your account at the depository symbol by symbol, and why a mismatch means stop rather than guess.
▶ OpenCorporate actions
Notes on corporate actions from the builder's side: dividends, bonus shares, splits, rights issues and mergers — the one thing that changes a client's assets with no order placed. Why the ex-date sits exactly one session before the record date, why an announced event still gets amended, what happens to the fraction when an entitlement is rounded down, and why a rights issue left to expire is real money lost.
▶ OpenDerivatives
Buying a share is buying something you own; opening a futures position is taking on an obligation that costs you cash every day until you get out. Why margin here is a deposit against an obligation, not a loan; why profit and loss turns into real money every evening; why your counterparty after matching is the clearing house — and what a broker living with two counterparty models at once has to change.
▶ OpenCross-cutting controls
Security for Financial Systems
Notes on securing a brokerage — where money leaves through the market, not the cashier, and a filled order has no chargeback: threat modelling, authentication & step-up, the on-behalf-of problem at the heart of authorisation, four eyes & separation of duties, audit as evidence, secrets & the exchange link, order flow as market-moving data, triaging vulnerabilities, and digital forensics.
▶ OpenMarket surveillance
A broker watching its own clients sees only half the board — the central order book is anonymous, so you never see who was on the other side. Which detection techniques stop working when the feed shows only three price levels, why cancelled orders are the most valuable data people throw away, why every manipulation pattern has a lawful twin, and why the system raises questions for a human instead of concluding.
▶ OpenKYC/AML & onboarding
Notes on the compliance layer that runs before any money moves: identity proofing & eKYC as a state machine, CDD/EDD and customer risk scoring, tracing beneficial owners through ownership chains, sanctions & PEP screening against unaccented Vietnamese names, money-laundering typologies in securities, tipping-off as a design constraint, and the brutal arithmetic of false positives.
▶ OpenOperational risk & IT compliance
Notes on the part of the job that only surfaces on the worst day: when the systems go down, get changed, or get audited. Why the trading session does not set your RTO but does set the price of every minute, why HA is not DR and the difference only shows on the day it must not, why one RPO figure for a whole system is a number for the form rather than for the architecture, what a FIX sequence number does after a failover, and why a control you cannot produce evidence for is a control that does not exist.
▶ Open
