Prehľad
Stock & ETF Cost-Basis Example — beancount.io
A Beancount ledger demonstrating taxable brokerage accounting: one cash brokerage account holding two individual stocks and a broad-market ETF, bought in identifiable lots between 2024 and 2026. Poznámky ku knihe
Finančná pozícia
Čistá hodnota a účty, ktoré ju tvoria
Pohyb peňazí
Mesačné príjmy a výdavky podľa kategórie účtu
Nedávna aktivita
Aktivita denníka so zohľadnením zápisov
Príjmy vs Výdavky
Údaje podľa období
| Obdobie | Príjmy | Výdavky | Čistý zisk |
|---|---|---|---|
| 2024-01-31 | 0,00 USD | 0,00 USD | 0,00 USD |
| 2024-02-29 | 0,00 USD | 4,95 USD | -4,95 USD |
| 2024-03-31 | 0,00 USD | 4,95 USD | -4,95 USD |
| 2024-04-30 | 0,00 USD | 0,00 USD | 0,00 USD |
| 2024-05-31 | 0,00 USD | 0,00 USD | 0,00 USD |
| 2024-06-30 | 0,00 USD | 4,95 USD | -4,95 USD |
| 2024-07-31 | 0,00 USD | 0,00 USD | 0,00 USD |
| 2024-08-31 | 0,00 USD | 0,00 USD | 0,00 USD |
| 2024-09-30 | 0,00 USD | 0,00 USD | 0,00 USD |
| 2024-10-31 | 0,00 USD | 0,00 USD | 0,00 USD |
| 2024-11-30 | 0,00 USD | 0,00 USD | 0,00 USD |
| 2024-12-31 | 0,00 USD | 0,00 USD | 0,00 USD |
| 2025-01-31 | 0,00 USD | 0,00 USD | 0,00 USD |
| 2025-02-28 | 0,00 USD | 0,00 USD | 0,00 USD |
| 2025-03-31 | 63,00 USD | 0,00 USD | 63,00 USD |
| 2025-04-30 | 0,00 USD | 0,00 USD | 0,00 USD |
| 2025-05-31 | 0,00 USD | 0,00 USD | 0,00 USD |
| 2025-06-30 | 124,00 USD | 0,00 USD | 124,00 USD |
| 2025-07-31 | 0,00 USD | 0,00 USD | 0,00 USD |
| 2025-08-31 | 0,00 USD | 0,00 USD | 0,00 USD |
| 2025-09-30 | 0,00 USD | 4,95 USD | -4,95 USD |
| 2025-10-31 | 0,00 USD | 0,00 USD | 0,00 USD |
| 2025-11-30 | 0,00 USD | 0,00 USD | 0,00 USD |
| 2025-12-31 | 0,00 USD | 0,00 USD | 0,00 USD |
| 2026-01-31 | 0,00 USD | 0,00 USD | 0,00 USD |
| 2026-02-28 | 1 686,00 USD | 4,95 USD | 1 681,05 USD |
| 2026-03-31 | 115,00 USD | 0,00 USD | 115,00 USD |
| 2026-04-30 | 286,00 USD | 4,95 USD | 281,05 USD |
| 2026-05-31 | 0,00 USD | 139,95 USD | -139,95 USD |
Súvaha
Rozpis
| Účet | Suma | Podiel na celku |
|---|---|---|
| Assets:Brokerage:NWRB | 4 199,00 USD | 6,05% |
| Assets:Brokerage:Cash | 18 295,35 USD | 26,38% |
| Assets:Brokerage:BMKT | 22 288,44 USD | 32,14% |
| Assets:Brokerage:ACME | 14 565,00 USD | 21% |
| Assets:Bank:Checking | 10 000,00 USD | 14,42% |
Peňažný tok
Načítavajú sa roly účtov…
Stock & ETF Cost-Basis Example — beancount.io
A Beancount ledger demonstrating taxable brokerage accounting: one cash brokerage account holding two individual stocks and a broad-market ETF, bought in identifiable lots between 2024 and 2026.
The method rests on one idea — a share is not a number, it is a lot: a quantity held at a known cost acquired on a known date. Writing a purchase as 120 NWRB {41.80 USD, 2024-03-12} stores the basis with the position instead of in a spreadsheet beside it, so a later sale can name the exact lot it disposes of and Beancount computes the gain rather than trusting you to.
Everything else here is that one idea applied again. A reinvested dividend is a new lot at the reinvestment price. A share split is a rewrite that must preserve total basis and realize nothing. A year-end balance is a share count you can check against the broker's December statement.
The ledger sets option "booking_method" "STRICT", so a sale that does not identify its lot is an error rather than a guess. That refusal is the point: it is what makes the realized gains in this ledger reproducible.
Every issuer, ticker and price in this ledger is fictional. They are chosen to be plausible, never to describe a real security's market history.
Quick Start
make install # Install beancount + fava via uv
make check # Verify the ledger has zero errors
make serve # Open Fava at http://localhost:4741File Guide
| File | What it demonstrates |
|---|---|
Makefile | make install / make check / make serve — the three commands above |
pyproject.toml | The pinned beancount + fava toolchain make install resolves |
main.bean | Entry point — options (including booking_method) and include directives |
accounts.bean | Ticker commodities and the brokerage / dividend / capital-gains chart |
prices/2024-2026.bean | Static quarter-end prices — market value only, never cost basis |
transactions/opening.bean | Funding the taxable brokerage account |
transactions/purchases.bean | Buying in identifiable lots with explicit {cost, date} |
transactions/dividends.bean | Cash dividends, and DRIP purchases that create new lots |
transactions/split.bean | A share split that changes the count and preserves total basis |
transactions/sales.bean | Selling a named lot, and where the gain lands by holding period |
transactions/assertions.bean | Year-end share-count assertions against the broker statement |
Live prices (preview)
The prices in prices/2024-2026.bean are static and checked in. That is what makes this repository reproducible: clone it in two years and make check still produces the report it produces today. They are also unadjusted — the dates before NWRB's 4-for-1 split carry pre-split per-share prices, the dates from the split onward carry post-split ones, and nothing earlier is restated. The two directives straddling the split value the same holding at $7,440.00 on both sides of it.
A hosted beancount.io ledger will also be able to pull a managed price feed, with one line:
; include "https://beancount.io/prices/ACME-USD"It ships commented out, and three things are worth knowing before you uncomment it in a ledger of your own:
- A URL include resolves only inside a hosted beancount.io ledger. Nothing else reads it.
- A local run does not fetch URLs.
bean-checkandbea checkread files from disk, so that line fails locally with a "does not match any files" error — which is why this repository, meant to be cloned and run, ships static prices. - Prices never change quantities, cost basis or realized gains. However they arrive, they move market value and nothing else; every number in
transactions/sales.beanis computed from the lots.
And the fact most worth having in advance: your own price directive always wins over a managed one for the same date and commodity pair, whatever the include order. A managed feed is a fallback for dates you have not priced yourself, never an override — so pinning a price you reconciled against a statement is simply a matter of writing it down.
The one thing to copy
A purchase stores its own basis:
2024-03-12 * "Broker" "Buy 120 NWRB @ $41.80"
Assets:Brokerage:NWRB 120 NWRB {41.80 USD, 2024-03-12}
Expenses:Brokerage:Commissions 4.95 USD
Assets:Brokerage:Cash -5,020.95 USD…and a sale names the lot it sells, so the gain and its holding period both follow from the entry rather than from a spreadsheet:
2026-02-20 * "Broker" "Sell 60 ACME from the 2024 lot — long-term gain"
Assets:Brokerage:ACME -60 ACME {68.20 USD, 2024-06-18}
Assets:Brokerage:Cash 5,778.00 USD
Expenses:Brokerage:Commissions 4.95 USD
Assets:Brokerage:Cash -4.95 USD
Income:CapitalGains:LongTerm -1,686.00 USDNothing anywhere else in the ledger has to remember what those shares cost.
What the numbers come to
Running make check validates every year-end share count below, and bea report income-statement reproduces the realized results:
| Holdings at the end of 2026 | 150 ACME · 201.25 BMKT · 380 NWRB · $18,295.35 cash |
| Long-term capital gain | $1,686.00 (60 ACME bought 2024-06-18, sold 2026-02-20) |
| Short-term capital gain | $286.00 (40 ACME bought 2025-09-08, sold 2026-04-17) |
| Long-term capital loss | $135.00 (100 post-split NWRB, holding period dating to 2024-03-12) |
| Dividend income | $274.00 qualified · $28.00 ordinary |
| Brokerage commissions | $34.65 across four buys and three sells |