Beancount getting started

My setup is very similar to the one from @nugget

To use my price importers what you need to do is install them, e.g. something like

pip install tariochbctools

and then you can use them in a commodity like

2010-01-01 commodity USD price: "CHF:tariochbctools.plugins.prices.exchangeratesapi/USD"

The price loader I use in the cronjob is a little bit more advanced

#!/usr/bin/env python3
from beancount.prices import price
from beancount import loader
from beancount.parser import printer

entries, errors, options = loader.load_file('main.beancount')
priceJobs = price.get_price_jobs_at_date(entries, inactive=True)
prices = []

for job in priceJobs:
    prices.append(price.fetch_price(job))

prices, ignoredEntries = price.filter_redundant_prices(prices, entries)

for newPrice in prices:
    with open('prices/' + newPrice.currency.lower() + '.beancount', 'a') as priceFile:
        priceFile.write(printer.format_entry(newPrice))

the script loads the file main.beancount to find all the commodities and then fetches the prices and puts them into a file prices/COMMODITY_NAME.beancount

1 Like