Beancount getting started

It’s actually quiet simple to get bean query results in a pandas dataframe. That gives you lots of flexibility.

Use query instead of shell and then you can directly create a dataframe with the result

I was doing also some work with Grafana and InfluxDB :wink:

For ideas:
I use lot of times graphics comparing the same fee/incoming/tax per month and per year:
incoming, taxes, dividends, saves, etc.

If there are big differences, I study why and adjust if necessary.

Been playing around with my Beancount and I’ve got a question for you: what is the point of the “at cost” & “at market value” display modes? For me it only shows the transactions in the base currency. So if my base currency is CHF, all the USD, PLN, EUR transactions are in “others”. Only when I switch to “converted to CHF”, it’s all in one place and the chart is complete.

The currency conversion remains opaque to me. What does “converted to CHF” mean, anyway? Does it mean: for any given date, convert all transactions/positions to CHF using the exchange rate at that date? Or convert all at the latest exchange rate?

Afaik “at cost” will show you stocks at the price when you bought them while “at market value” shows it with the current value.

My problem is, from 2010 to 2015 I only had bookings in PLN, since 2015 it’s USD, CHF, EUR. And both “at cost” and “at market value” show only the bookings in operating currencies, and each currency separate. So they are mostly useless if you’re dealing with 2+ currencies in your life.

The “Converted to CHF” is, I guess, “at market value converted to CHF?”

That’s intended afaik. I had to install a plugin that my BTC get converted to USD and then to CHF correctly for the “converted to CHF” view.

1 Like

Which plugin? That’s another thing that bugs me. Since everything can be quoted in USD, that’s what I did, I priced everything in USD. And then when I turned on “converted to CHF”, all the assets were not converted. Even if there is the price of VT in USD and price of CHF in USD…

I’ve used this line to make multi-step conversions possible:
plugin "tariochbctools.plugins.generate_base_ccy_prices" "CHF"

Install instructions here: Beancount getting started

1 Like

Conveet to chf only works if you have prices to chf. My plugin calculates those prices (e.g. if you have vt to usd and usd to chf then it calculates vt to chf)

1 Like

Hi Bojack,

Be sure that you have the prices of PLN, USD, etc… to CHF the date you are looking for!
If you buy the 2020-01-01 something in USD and you don’t have an entry in the ledger with:

2020-01-01 price USD                                  0.88 CHF 

Beancount cannot calculate the value for your stock in CHF!

Sometimes happened to me. If I bought 1 oz of gold at, lets say 1500$ and for this date I don’t have entries for prices from GOLD to USD and from USD to CHF, if I try to get the balance of gold, I don’t get 1727 CHF, I get 1 GOLD.

Regards.

i never ran into this issue with weekly price data.
does beancount not interpolate prices time-wise??

I don’t think that’s it. My setup is like this: I downloaded the price in USD for every asset that I have (and set operating currency as USD). Then the “Converted to CHF” did not work. With the plugin it works, though.

I would be surprised if it did. Interpolation would be wrong IMO. What I would expect is for it to take the last available price. So if you declared a price on 2010-01-01, it would apply for all following dates, until you posted a new price.

Thanks @tarioch for the great plugin (and thanks @MrCheese for the tip)

Question: the balance sheet looks clean now, but the income statement looks weird for “Converted to XXX” (Converted to USD is ok):

It wants to show me PLN but also USD (which is always 0.00). This looks wrong.

USD (operating currency) for comparison:

Any tips?

Thanks for that, I was lazy to look into the query library before, but your post saying it was easy motivated me to do it lol.

Here is a quick snippet that anyone can easily adapt for their needs:

from beancount.utils import misc_utils
from beancount import loader
from beancount.query import query as bean_query

def load():
	beanfile = '/path/to/main.beancount' #just make sure that this has the path to your main beauncount file
	errors_file = sys.stderr
	with misc_utils.log_time('beancount.loader (total)', logging.info):
		return loader.load_file(beanfile,
    							log_timings=logging.info,
    							log_errors=errors_file)

def print_query_results(query): #you can easily re-use this to do something smarter with the query result
	entries, errors, options = load()
	_, rrows = bean_query.run_query(entries, options, query)
	for r in rrows:
		print('{0},{1},{2},{3}'.format(r.date,r.account,r.total,r.currency))

if __name__ == '__main__':
    query = "SELECT date, account, sum(number) as Total, currency FROM year WHERE account ~ 'Income' GROUP BY date, account, currency ORDER BY date, currency" #example of a bean query
	print_query_results(query)
1 Like

Hi,

I think this is a silly question but I am not finding a way to get beancount_share to work.

I added plugin “beancount_share.share” “{}” to my beancount file and some expenses with tag #share-test, then I run bean-check against the file and it executs fine. However, I do not see the changes that bean_share should make. It looks like it does not do anything. What am I missing? Is there a specific command to apply the plugin?

Thanks,

Hi all, never mind, I got it working! @Akuukis thanks a lot for this plugin!
It was not working because I made a mess with python versions so bean-check was correctly using python3.7 but fava was loading with python3.6 and because of that failing to load the plugin. The only thing a bit weird is that I saw that later on the fava logs but this error did not show at all in the UI…

2 Likes

I set up a GitHub action to download prices daily and commit the new lines to the git repo. It’s pretty convenient, no need to fiddle with cron jobs.

2 Likes

Does anybody have an importer for UBS? I am experimenting with beancount after reading @Burningstone story. I managed to get started on windows (a pain) and have imported some Revolut and Cashback transactions. Now I would like to “scale” it a bit.

Been a couple years, be might still be the same. Ubs used to support mt940 format, you can use beancounttools/mt940importer.py at master · tarioch/beancounttools · GitHub

1 Like

Thanks for this.

Anyone have a Swisscard pdf importer? I’d rather not waste time trying to write a pdf importer if possible :sweat:

i dont, but i know the beancount author spent some time on this topic. you will need to brows the documentation Beancount - Index - Google Docs