A Beancount plugin that automatically generates commodity prices in alternative currencies (like gold/XAU) based on existing price data.
If you track your investments in USD but want to see their value in gold (XAU) to measure real purchasing power over time, you'd normally need to manually calculate and enter prices like:
2024-01-02 price VTSAX 0.060578 XAU
This plugin does that automatically. Given:
2024-01-02 price VTSAX 163.56 USD
2024-01-02 price XAU 2700.00 USD
It derives:
2024-01-02 price VTSAX 0.060578 XAU ; 163.56 / 2700.00
- Derived Prices: Convert all commodity prices to an alternative currency
- Inverse Rates: Automatically generates inverse exchange rates (e.g., USD/XAU)
- Proxy Commodities: Create a chartable commodity that mirrors an operating currency's price (useful for Fava, which doesn't show charts for operating currencies)
- Configurable: Exclude specific commodities, adjust decimal precision
pip install beancount-derived-pricesOr install from source:
git clone https://github.com/stenius/beancount-derived-prices
cd beancount-derived-prices
pip install -e .Add to your beancount file:
plugin "beancount_derived_prices" "target:XAU via:USD"
| Option | Default | Description |
|---|---|---|
target:<currency> |
XAU |
Target currency to derive prices into |
via:<currency> |
USD |
Base currency used for conversion |
exclude:<c1,c2> |
(none) | Comma-separated commodities to exclude |
precision:<n> |
6 |
Decimal places for derived prices |
proxy:<commodity> |
(none) | Create a proxy commodity for charting |
Basic gold pricing:
plugin "beancount_derived_prices" "target:XAU via:USD"
With proxy for Fava charts:
; XAU is an operating currency, so Fava won't show a price chart for it.
; The proxy:GOLD option creates a GOLD commodity with XAU's USD prices,
; which will show up in Fava's Commodities page with a chart.
plugin "beancount_derived_prices" "target:XAU via:USD proxy:GOLD"
Exclude volatile assets:
plugin "beancount_derived_prices" "target:XAU via:USD exclude:BTC,ETH"
Higher precision:
plugin "beancount_derived_prices" "target:XAU via:USD precision:8"
Full example:
option "operating_currency" "USD"
option "operating_currency" "XAU"
plugin "beancount_derived_prices" "target:XAU via:USD proxy:GOLD exclude:BTC precision:8"
; Your price data
2024-01-02 price XAU 2700.00 USD
2024-01-02 price VTSAX 163.56 USD
2024-01-02 price VOO 480.00 USD
; The plugin automatically generates:
; 2024-01-02 price VTSAX 0.06057778 XAU
; 2024-01-02 price VOO 0.17777778 XAU
; 2024-01-02 price USD 0.00037037 XAU
; 2024-01-02 price GOLD 2700.00 USD
- Collects prices: Finds all
pricedirectives quoted in the base currency (USD) - Calculates derived prices: For each date with a target currency price (XAU), divides each commodity's base price by the target's base price
- Generates inverse rates: Creates base-to-target exchange rates (USD → XAU)
- Creates proxy (optional): Mirrors the target currency's price as a regular commodity for charting
See how your investments perform relative to gold's purchasing power:
option "operating_currency" "USD"
option "operating_currency" "XAU"
2016-04-14 custom "fava-option" "conversion-currencies" "USD XAU"
plugin "beancount_derived_prices" "target:XAU via:USD"
Now in Fava, you can view your balance sheet converted to XAU.
Run the plugin multiple times with different targets:
plugin "beancount_derived_prices" "target:XAU via:USD"
plugin "beancount_derived_prices" "target:BTC via:USD"
- Python 3.8+
- Beancount 2.3+
MIT License - see LICENSE for details.
Contributions welcome! Please open an issue or submit a pull request.