Beancount Balance Assertion for Sum of accounts

431 views
Skip to first unread message

David Karapetyan

unread,
Feb 17, 2021, 3:28:00 AM2/17/21
to Beancount

Hello,

Firstly, I wanted to compliment you on this brilliant project (and your excellent documentation in particular on double-entry accounting, useful particularly for people already working in technical fields). I had a question about balance assertions for investment accounts. Specifically, suppose I have the following two (and only two transactions) for Fidelity:

Assets:US:Fidelity:SPAXX   10 USD
Assets:US:Fidelity:FNILX 20 USD

I would like to do a balance assertion on the sum of these accounts in time, i.e.

2020-01-01 balance Assets:US:Fidelity 30 USD

rather than asserting the balance of each individual sub-account (my reasons for this have to do with parsing html statements from Fidelity, which can be real pain if you are parsing via sub-account, but pretty straight-forward if parsing the total account amounts).

What are your suggestions for best going about this? I could always mirror-log a transaction to the combined Assets:US:Fidelity account whenever I log the same transaction to a subaccount, but that seems a bit cumbersome (and I would have to balance the transaction via a negative amount to some Expense account created for this purpose, which strikes me as inelegant).

Any suggestions are welcome :). Thanks again for your work.

Daniele Nicolodi

unread,
Feb 17, 2021, 3:58:28 AM2/17/21
to bean...@googlegroups.com
On 17/02/2021 09:28, David Karapetyan wrote:
>
> Hello,
>
> Firstly, I wanted to compliment you on this brilliant project (and your
> excellent documentation in particular on double-entry accounting, useful
> particularly for people already working in technical fields). I had a
> question about balance assertions for investment accounts. Specifically,
> suppose I have the following two (and only two transactions) for Fidelity:
>
> Assets:US:Fidelity:SPAXX   10 USD
> Assets:US:Fidelity:FNILX 20 USD

This is not valid Beancoutn syntax. However, completing it in the most
straightforward way:

2020-02-17 * "Foo"
Assets:US:Fidelity:SPAXX 10.00 USD
Assets:US:Fidelity:FNILX 20.00 USD
Assets:Openings

these are two postings on a transaction, not two transactions. However,
I don't think semantics is part of your problem :-)

> I would like to do a balance assertion on the sum of these accounts in
> time, i.e.
>
> 2020-01-01 balance Assets:US:Fidelity 30 USD

This works out of the box (as long as you remember to open the
Assets:US:Fidelity account):

2020-02-17 open Assets:Openings
2020-02-17 open Assets:US:Fidelity
2020-02-17 open Assets:US:Fidelity:SPAXX
2020-02-17 open Assets:US:Fidelity:FNILX

2020-02-17 * "Foo"
Assets:US:Fidelity:SPAXX 10.00 USD
Assets:US:Fidelity:FNILX 20.00 USD
Assets:Openings

2020-02-18 balance Assets:US:Fidelity 31.00 USD

Can you post a self contained minimal example where it does not work?

Cheers,
Dan

Martin Blais

unread,
Feb 17, 2021, 10:09:38 AM2/17/21
to Beancount
Further, it usually makes more sense to treat buy/sell on commodities in separate transactions.
This then allows you to eventually compute returns



--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/f74c13c4-2378-b381-f2c0-f83a2e65ee8c%40grinta.net.

david e

unread,
Apr 13, 2021, 9:45:33 AM4/13/21
to Beancount
that's a highly useful documentation @martin. is it linked in the beancount docs (I don't remember seeing it there) and if not, are there more reports like this available? thank you!

Martin Blais

unread,
Apr 13, 2021, 2:16:07 PM4/13/21
to Beancount
It's in the index:
https://docs.google.com/document/d/1RaondTJCS_IUPBHFNdT8oqFKJjVJDsfsn6JEjBG04eA/edit#heading=h.hzs9xa5699ul
It's fairly recent, so you might have missed it.
I'm planning another one on trading derivatives with Beancount.

Reply all
Reply to author
Forward
0 new messages