Hide/aggregate lot accounts when tracking investments

31 views
Skip to first unread message

Ryan

unread,
Oct 26, 2022, 12:19:43 PM10/26/22
to hledger
I'm considering using hledger to track investment lots since I use it for other accounting. I've read this guide which seems reasonable. My concern is that having a separate account for each lot will clutter up reports and hledger-ui. The more I trade the more cluttered it will be.

We can hide/aggregate accounts with --depth but "lot" accounts aren't necessarily all at the same depth. They're also not necessarily deeper than other accounts that aren't lots which means aggregating them with --depth would also aggregate non-"lot" accounts at that same depth and deeper.

Is there any other way to aggregate accounts than by depth? Maybe with a pattern or something?

Simon Michael

unread,
Oct 26, 2022, 1:10:26 PM10/26/22
to hledger
Yes, you can temporarily hide & aggregate with account aliases. Eg if your lot account leaf names are all digits, add

 --alias '/:[0-9]+$/='

I also arrange the account tree to keep most lots at the same depth, where possible, which just makes things easier eg for zooming in and out in hledger-ui.




--
You received this message because you are subscribed to the Google Groups "hledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hledger+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hledger/92694898-ac7b-4f6a-bf0f-6fcb05a4cfaen%40googlegroups.com.

Ryan

unread,
Oct 26, 2022, 5:40:18 PM10/26/22
to hledger
That's cool! And an unexpected use of aliases! Thanks

Ryan

unread,
Oct 28, 2022, 3:35:05 PM10/28/22
to hledger
I stumbled on a minor gotcha with opening balances and using aliases to aggregate lots.

I've been using balance assignments for opening balances. To start tracking lots I broke out the 2022 opening balance posting for an asset into separate lots, one for each purchase made last year. So, for example

Opening balances
    assets:ABC        = 100

became

Opening balances
    assets:ABC:20211001        = 30
    assets:ABC:20211101        = 40
    assets:ABC:20211201        = 30

That works fine when they're not aggregated but when I aggregated the lots into assets:ABC with an alias then the opening balance was 30 instead of 100. To fix I removed the = and used regular postings instead of balance assignments for lot opening balances.

Opening balances
    assets:ABC:20211001        30
    assets:ABC:20211101        40
    assets:ABC:20211201        30

But it confused me for a bit since I was dealing with more postings and larger numbers. Just sharing in case others find this conversation, try aliases and run into the same issue.

- Ryan

Simon Michael

unread,
Oct 28, 2022, 4:30:12 PM10/28/22
to hledger
Thanks for the note. I most avoid balance assignments as they allow too much variability in different situations.


Reply all
Reply to author
Forward
0 new messages