Investments
Let’s discuss how you can track investments, be it stocks, ETFs, crypto or anything similar. Beancount’s language allows to do this in a neat and precise way.
Totals tracking
If you followed the guide, you can already track net worth and total values of accounts by institution (including brokers). Displaying current valuation based on the market prices is a feature that all of them provide. Logically, they also provide history of this valuation over time (some do this from the start of your account, some will show just the last year), and you may choose to log in into your accounts less frequently when you do the regular totals update and backfill later when you feel less lazy.
But of course you can also track stocks, crypto, etc precisely as you would normally do with Beancount and its flexibility.
Commodities
We’ve already discussed commodities in Beancount in the section related to currencies. All the stocks, crypto, other tickers can be defined in Beancount in the same way.
Prices of the defined commodities may be fetched and saved using bean-price
in the way described earlier (e.g. from the Prices page of the UI).
The base guide on how to work with investments can be found at Trading with Beancount.
Accounts
Accounts can be defined using the same YAML config as in Totals section. I usually create a separate leaf account for each commodity (ETF, stock or crypto), and also a Cash account for tracking cash held in broker account. You can use booking_method
parameter to specify a booking method (e.g. FIFO or LIFO, all options and details described here) so you don’t have to provide specific lots on sale (if this data isn’t available from the institution, or is not important).
Importing
All you need to track investments is to import or manually enter all transactions from your broker.
For some brokers (at the moment, Interactive Brokers (IBKR) and, not verified but potentially, Kraken and Binance) the automatic importer is defined and works via Import tab alongside the bank importers. If you need other platforms, its likely that the importer also already exists (written for beancount-ingest or beangulp framework), and you can create an issue to integrate it into Lazy Beancount. Refer to the Import page.
Manual entry
If you don’t have too many transactions, you can enter them manually (example transactions can be found here):
2024-04-11 * "Buy SPY"
Assets:MyStockBroker:SPY 3 SPY {517.9 USD}
Assets:MyStockBroker:Cash -1556.12 USD
Expenses:MyStockBroker:Commissions 2.42 USD
2024-06-17 * "Sell SPY"
Assets:MyStockBroker:SPY -2 SPY {} @ 547 USD
Assets:MyStockBroker:Cash 1090.99 USD
Expenses:MyStockBroker:Commissions 3.01 USD
Income:MyStockBroker:PnL
Reading through this page may save you time because of not having to specify traded lots manually (if it’s not important for your case).
Metadata
Additional metadata in commodities.bean
specifying asset allocation or other information (example) may be used by dashboards with https://github.com/andreasgerstmayr/fava-dashboards. Could be used for rebalancing, for example.
Portfolio analysis
The fava-portfolio-returns plugin based on beangrow is now supplied with Lazy Beancount by default. I have not extensively tested it on all possible cases yet but hopefully it should be working as expected.
This doc has some useful thoughts on the verification of correctness of your data and numbers deduced from it by the library.