Confused about operating currency and networth report

420 views
Skip to first unread message

Justus

unread,
Jan 10, 2017, 3:51:04 AM1/10/17
to Beancount
I have 3 operating currencies: US dollars, Australian dollars, and Vietnamese dong. I have assets, income, and expenses in all three currencies. When I run bean-report my.beancount networth I see inconsistent results that confuse. Any guidance on what is wrong (or what I'm doing wrong) or pointers on what I can debug would be appreciated.

Scenario 1.

They are listed in this order at the top of my file.

option "operating_currency" "USD"
option "operating_currency" "AUD"
option "operating_currency" "VND"

The report looks like (numbers are made up, but representative of reality)

Currency     Net Worth
--------  ------------
USD       2,378
AUD       3,230
--------  ------------

That's mostly what I would expect...my networth in USD is $X. Use the current exchange rate to also show it in AUD.

Except where is the VND?

Scenario 2.

All I do is change the order in which the operating currencies are declared. I move VND to the middle.

option "operating_currency" "USD"
option "operating_currency" "VND"
option "operating_currency" "AUD"

The reports looks like:

Currency          Net Worth
--------  -----------------
USD            2,378
VND       53,693,828
--------  -----------------

Again, this looks like what I expect. Except now AUD has disappeared.

Scenario 3.

This time I move VND to the top of the list.

option "operating_currency" "VND"
option "operating_currency" "USD"
option "operating_currency" "AUD"

The report:

Currency          Net Worth
--------  -----------------
VND       48,888,443
USD            2,165
AUD            2,941
--------  -----------------

One step forward, two steps back. Now it shows all three currencies (yay!) but...the numbers have changed and are now wrong. Some of my wealth has disappeared :)

Also...why does just changing the ordering matter? It doesn't seem like it should.

Justus Pendleton

unread,
Jan 12, 2017, 2:56:34 AM1/12/17
to Beancount
As a follow up to myself...to try to understand what is going on I reduced it down so I only have one operating_currency -- AUD.

One surprise is the way currency conversions work in holdings_report.py:convert_to_currency. What I mean is:

I have this...

2017-01-11 price AUD                            0.7379 USD
2017-01-11 price USD                       22,568.27 VND

But because I don't have an explicit AUD <-> VND price the call to prices.get_latest_price(price_map, base_quote) returns (None, None). This results in it throwing out anything I have with a cost_currency of VND.

If I add another entry, so it looks like

2017-01-11 price AUD                            0.7379 USD
2017-01-11 price AUD                       16,856.94 VND
2017-01-11 price USD                       22,568.27 VND

then things work as expected. Is it even possible to have bean-price fetch two different prices for AUD like that? One in VND and one in USD?

It seems like currency/commodity conversion should be using a graph rather than just a dictionary lookup. I have a patch that does this that I can submit so long as I'm not misunderstanding how all this is supposed to work. When I change it to use a graph lookup then the problem I talked about in my original post goes away.

Martin Blais

unread,
Jan 14, 2017, 6:03:26 PM1/14/17
to Beancount
Re. your first email: That's not great behavior from Beancount.
Ideally at the very least it should issue a warning, or try to resolve the rates.

In general, replacing the currency conversion with an unconditional graph search is too dangerous IMO, it could start getting really expensive without us noticing. Besides, if we did that I would consider redesigning the price map from scratch, avoiding filling it in with inverses in the first place.  A better approach to solve the networth report issue might be to have a function which fills in missing pairs in the existing price map for particular desired currencies (i.e., the operating currencies in this case) once and then use that. What do you think?

I'll comment further on your PR.
Thanks,
Reply all
Reply to author
Forward
0 new messages