پرش به محتوای اصلی

خلاصه

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. یادداشت‌های دفتر

وضعیت مالی

ارزش خالص و حساب‌های تشکیل‌دهنده آن

ارزش خالص
دارایی‌ها به‌علاوه بدهی‌ها در ۱۲ ماه گذشته
۶۷٬۹۹۹٫۲۳ USD
۰٫۰۰ USDنسبت به ماه قبل

بهای تمام شده ۶۲٬۱۰۴٫۳۵ USD · سود و زیان تحقق‌نیافته +۵٬۸۹۴٫۸۸ USD

حساب‌ها
مانده فعلی حساب‌های دارایی و بدهی

گردش پول

درآمد و هزینه ماهانه بر اساس دسته حساب

مهٔ ۲۰۲۶
ورودی پول
مهٔ ۲۰۲۶
—
منابع اصلی
در این دوره گردش پولی وجود ندارد.
میانگین حداکثر ۳ دوره پیشین
+۶۹۵٫۶۷ USD
نمایش همه
خروجی پول
مهٔ ۲۰۲۶
‎−۱۳۹٫۹۵ USD
بیشترین هزینه‌ها
میانگین حداکثر ۳ دوره پیشین
‎−۳٫۳۰ USD
نمایش همه

فعالیت اخیر

فعالیت دفتر روزنامه با درنظرگرفتن ثبت‌ها

تراکنش‌ها
جدیدترین تراکنش‌های مطابق فیلترهای فعلی

درآمد در مقابل هزینه‌ها

درآمد در مقابل هزینه‌ها
نمودار میله‌ای مقایسه مجموع درآمد و هزینه‌ها برای هر بازه در دوره انتخابی.
داده‌های دوره‌ای
دورهدرآمدهزینه‌هاسود خالص
2024-01-31۰٫۰۰ USD۰٫۰۰ USD۰٫۰۰ USD
2024-02-29۰٫۰۰ USD۴٫۹۵ USD‎−۴٫۹۵ USD
2024-03-31۰٫۰۰ USD۴٫۹۵ USD‎−۴٫۹۵ USD
2024-04-30۰٫۰۰ USD۰٫۰۰ USD۰٫۰۰ USD
2024-05-31۰٫۰۰ USD۰٫۰۰ USD۰٫۰۰ USD
2024-06-30۰٫۰۰ USD۴٫۹۵ USD‎−۴٫۹۵ USD
2024-07-31۰٫۰۰ USD۰٫۰۰ USD۰٫۰۰ USD
2024-08-31۰٫۰۰ USD۰٫۰۰ USD۰٫۰۰ USD
2024-09-30۰٫۰۰ USD۰٫۰۰ USD۰٫۰۰ USD
2024-10-31۰٫۰۰ USD۰٫۰۰ USD۰٫۰۰ USD
2024-11-30۰٫۰۰ USD۰٫۰۰ USD۰٫۰۰ USD
2024-12-31۰٫۰۰ USD۰٫۰۰ USD۰٫۰۰ USD
2025-01-31۰٫۰۰ USD۰٫۰۰ USD۰٫۰۰ USD
2025-02-28۰٫۰۰ USD۰٫۰۰ USD۰٫۰۰ USD
2025-03-31۶۳٫۰۰ USD۰٫۰۰ USD۶۳٫۰۰ USD
2025-04-30۰٫۰۰ USD۰٫۰۰ USD۰٫۰۰ USD
2025-05-31۰٫۰۰ USD۰٫۰۰ USD۰٫۰۰ USD
2025-06-30۱۲۴٫۰۰ USD۰٫۰۰ USD۱۲۴٫۰۰ USD
2025-07-31۰٫۰۰ USD۰٫۰۰ USD۰٫۰۰ USD
2025-08-31۰٫۰۰ USD۰٫۰۰ USD۰٫۰۰ USD
2025-09-30۰٫۰۰ USD۴٫۹۵ USD‎−۴٫۹۵ USD
2025-10-31۰٫۰۰ USD۰٫۰۰ USD۰٫۰۰ USD
2025-11-30۰٫۰۰ USD۰٫۰۰ USD۰٫۰۰ USD
2025-12-31۰٫۰۰ USD۰٫۰۰ USD۰٫۰۰ USD
2026-01-31۰٫۰۰ USD۰٫۰۰ USD۰٫۰۰ USD
2026-02-28۱٬۶۸۶٫۰۰ USD۴٫۹۵ USD۱٬۶۸۱٫۰۵ USD
2026-03-31۱۱۵٫۰۰ USD۰٫۰۰ USD۱۱۵٫۰۰ USD
2026-04-30۲۸۶٫۰۰ USD۴٫۹۵ USD۲۸۱٫۰۵ USD
2026-05-31۰٫۰۰ USD۱۳۹٫۹۵ USD‎−۱۳۹٫۹۵ USD

ترازنامه

توزیع دارایی‌ها
نمایش بصری از ترکیب دارایی‌های Stock & ETF Cost-Basis Example — beancount.io
جزئیات
حسابمبلغسهم از کل
Assets:Brokerage:NWRB۴٬۱۹۹٫۰۰ USD۶٫۰۵%
Assets:Brokerage:Cash۱۸٬۲۹۵٫۳۵ USD۲۶٫۳۸%
Assets:Brokerage:BMKT۲۲٬۲۸۸٫۴۴ USD۳۲٫۱۴%
Assets:Brokerage:ACME۱۴٬۵۶۵٫۰۰ USD۲۱%
Assets:Bank:Checking۱۰٬۰۰۰٫۰۰ USD۱۴٫۴۲%
توزیع بدهی‌ها
نمایش بصری از ترکیب بدهی‌های Stock & ETF Cost-Basis Example — beancount.io
داده‌ای موجود نیست

جریان نقدینگی

جریان نقدینگی
جریان پول از منابع درآمد به هزینه‌ها و سرمایه‌گذاری‌ها

در حال بارگذاری نقش حساب‌ها…

README.md

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

bash
make install   # Install beancount + fava via uv
make check     # Verify the ledger has zero errors
make serve     # Open Fava at http://localhost:4741

File Guide

FileWhat it demonstrates
Makefilemake install / make check / make serve — the three commands above
pyproject.tomlThe pinned beancount + fava toolchain make install resolves
main.beanEntry point — options (including booking_method) and include directives
accounts.beanTicker commodities and the brokerage / dividend / capital-gains chart
prices/2024-2026.beanStatic quarter-end prices — market value only, never cost basis
transactions/opening.beanFunding the taxable brokerage account
transactions/purchases.beanBuying in identifiable lots with explicit {cost, date}
transactions/dividends.beanCash dividends, and DRIP purchases that create new lots
transactions/split.beanA share split that changes the count and preserves total basis
transactions/sales.beanSelling a named lot, and where the gain lands by holding period
transactions/assertions.beanYear-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:

beancount
; 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:

  1. A URL include resolves only inside a hosted beancount.io ledger. Nothing else reads it.
  2. A local run does not fetch URLs. bean-check and bea check read 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.
  3. Prices never change quantities, cost basis or realized gains. However they arrive, they move market value and nothing else; every number in transactions/sales.bean is 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:

beancount
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:

beancount
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 USD

Nothing 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 2026150 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