This tutorial builds the ledger of a small stock brokerage. Users deposit dollars, buy and sell shares, get dividends and withdraw. Each chapter takes one thing the business needs and shows the Torment feature that handles it.
By the end, you’ll have used every part of the API and seen why each part exists.
What you need
Section titled “What you need”- Torment running locally (see the Quickstart).
- The short section on debits and credits. Every posting debits one account and credits another, and each chapter says which and why.
Chapters
Section titled “Chapters”- Chart of accounts: which accounts the brokerage needs, and why each has the type it has.
- Deposits: money arriving, and making sure a payment is never counted twice.
- Buying shares: paying, receiving shares and charging a fee, all or nothing.
- Partial fills: one order filled in pieces, kept together as one group.
- Currency exchange: a user deposits dirhams and buys in dollars.
- Dividends: paying thousands of users in a few requests.
- Withdrawals: money that has left the user’s wallet but not yet left the bank.
- Statements: a user’s history, their balance on any past date, and checking the books.
- Mistakes: fixing a wrong transfer without editing anything.
- Notifications: emailing users when money arrives or leaves, from Torment’s events.
Every request in the tutorial is also in scripts/brokerage.sh. With Torment running, make brokerage sends them all and checks each response, so the tutorial stays true to the API.