Notes and docs related to tracking investment lots with plain text accounting tools.
Last updated: 2026-01-13
## general
- https://en.wikipedia.org/wiki/Cost_basis
- https://www.costbasis.com
- https://www.double-entry-bookkeeping.com/marketable-securities/trading-securities/
- https://www.mscs.dal.ca/~selinger/accounting/tutorial.html
- [IRS publication 550 Investment Income and Expenses](https://www.irs.gov/forms-pubs/about-publication-550 ) (US taxes)
- [IRS publication 551 Basis of Assets](https://www.irs.gov/forms-pubs/about-publication-551) (US taxes)
## plain text accounting
- [Cookbook > Accounting situations](https://plaintextaccounting.org/Cookbook#accounting-situations)
- [Investing and trading](https://plaintextaccounting.org/Investing-and-trading)
- [Taxes > Capital gains](https://plaintextaccounting.org/Taxes#capital-gains)
- [Capital gains reporting](https://plaintextaccounting.org/Capital-gains-reporting)
- [[PTA lot tracking tests]]
## ledger
- [Commodities and Currencies](https://www.ledger-cli.org/3.0/doc/ledger3.html#Commodities-and-Currencies)
- [Commodity price histories](https://www.ledger-cli.org/3.0/doc/ledger3.html#Commodity-price-histories)
- [Commodity equivalences](https://www.ledger-cli.org/3.0/doc/ledger3.html#Commodity-equivalences)
- [Currency and Commodities](https://www.ledger-cli.org/3.0/doc/ledger3.html#Currency-and-Commodities)
- [Naming Commodities](https://www.ledger-cli.org/3.0/doc/ledger3.html#Naming-Commodities)
- [Buying and Selling Stock](https://www.ledger-cli.org/3.0/doc/ledger3.html#Buying-and-Selling-Stock)
- [Fixing Lot Prices](https://www.ledger-cli.org/3.0/doc/ledger3.html#Fixing-Lot-Prices)
- [Complete control over commodity pricing](https://www.ledger-cli.org/3.0/doc/ledger3.html#Complete-control-over-commodity-pricing)
- [Posting cost](https://www.ledger-cli.org/3.0/doc/ledger3.html#Posting-cost)
- [Explicit posting costs](https://www.ledger-cli.org/3.0/doc/ledger3.html#Explicit-posting-costs)
- [Primary and secondary commodities](https://www.ledger-cli.org/3.0/doc/ledger3.html#Primary-and-secondary-commodities)
- [Posting cost expressions](https://www.ledger-cli.org/3.0/doc/ledger3.html#Posting-cost-expressions)
- [Total posting costs](https://www.ledger-cli.org/3.0/doc/ledger3.html#Total-posting-costs)
- [Virtual posting costs](https://www.ledger-cli.org/3.0/doc/ledger3.html#Virtual-posting-costs)
- [Commodity prices](https://www.ledger-cli.org/3.0/doc/ledger3.html#Commodity-prices)
- [Total commodity prices](https://www.ledger-cli.org/3.0/doc/ledger3.html#Total-commodity-prices)
- [Prices versus costs](https://www.ledger-cli.org/3.0/doc/ledger3.html#Prices-versus-costs)
- [Fixated prices and costs](https://www.ledger-cli.org/3.0/doc/ledger3.html#Fixated-prices-and-costs)
## beancount
- [How Inventories Work](https://docs.google.com/document/d/11a9bIoNuxpSOth3fmfuIFzlZtpTJbvw-bPaQCnezQJs)
- [Inventory Booking (proposal)](https://docs.google.com/document/d/1F8IJ_7fMHZ75XFPocMokLxVZczAhrBRBVN9uMhQFCZ4)
- [Trading with Beancount](https://docs.google.com/document/d/1WjARst_cSxNE-Lq6JnJ5CC41T3WndEsiMw4d46r2694)
- [Stock Vesting in Beancount](https://docs.google.com/document/d/1mHNlNMTZsKPMjP_qQmedoizZFQy1-GzlR2lX5zy_0ok)
- [Exporting Your Portfolio](https://docs.google.com/document/d/1mNyE_ONuyEkF_I2l6V_AoAU5HJgI654AOBhHsnNPPqw)
- https://beancount.github.io/docs/beancount_language_syntax.html#reducing-positions
- https://beancount.github.io/docs/how_inventories_work.html
- https://beancount.github.io/docs/trading_with_beancount.html
- [Beancount Vnext: Booking Rules Redesign](https://docs.google.com/document/d/1H0UDD1cKenraIMe40PbdMgnqJdeqI6yKv0og51mXk-0/edit?tab=t.0#heading=h.9lk1l7gqxxfs)
## beans
- https://sboehler.github.io/beans/
- Converts to a desired commodity: *"derives arbitrary commodity conversions between all commodities, as long as there is at least one path (possibly over several links) from one commodity to another. For example, conversion from SomeStock in CHF is possible when prices of SomeStock in USD and CHF in USD is available. Inverted rates are derived automatically."*
- Generates revaluation transactions (calculates unrealized gains) when reporting in a different commodity:
- *"The journal now not only shows explicit inflows and outflows, but also valuation corrections due to price changes at the specific date they occurred."*
- *"When valuating the balance in a certain reference commodity, beans accounts for changes in valuation using the Equity:Valuation account. It reflects gains and losses over time with respect to the reference currency."*
- *"applies valuation directly at the transaction level. For example, if you choose to display a balance at market prices, beans will transparently insert valuation transactions to reflect gains and losses due to price changes"*
- *"Depending on whether one wants to convert commodities at cost or at market value, beans will add balancing accounts automatically."*
- *"offers either no valuation or valuation at market prices. Valuation at cost is yet to be implemented."*
- *"applies valuation at the level of transactions, which seems unique amongst plain-text accounting tools"* --[Transaction-level valuation](https://sboehler.github.io/beans/#org728ce98).
1. Converts all postings to the target commodity using market prices at target valuation date (there are no explicit transaction prices)
2. At each market price change, for each asset/liability account, calculates the balance and adds a revaluation transaction (transfer to/from Equity:Valuation).
## hledger
- https://hledger.org/dev/hledger.html#cost-reporting
- https://hledger.org/dev/hledger.html#value-reporting
- https://hledger.org/dev/hledger.html#balance-features
- https://hledger.org/dev/hledger.html#other-costlot-notations
- [Cookbook > Investing and trading](https://hledger.org/doc.html#investing-and-trading)
- https://hledger.org/track-investments.html
- https://github.com/adept/full-fledged-hledger/wiki/Investments-easy-approach
- [Full-fledged hledger: Manual lot tracking](https://github.com/adept/full-fledged-hledger/wiki/Manual-lot-tracking) discussion of UK disposal rules
- [Zoran Zaric: Tracking Investments in Lots with Hledger](http://rantsideasstuff.com/posts/2018/07/01-tracking-investments-in-lots-with-hledger/)
- [reddit: hledger: Balancing transactions that track the purchase of an asset as a commodity](https://www.reddit.com/r/plaintextaccounting/comments/1f92hqn/hledger_balancing_transactions_that_track_the/
- [#1015 Make hledger good for investment tracking (overview)](https://github.com/simonmichael/hledger/issues/1015)
- [[hledger lot tracking]] dev notes