Here's the script:
https://github.com/beancount/beanlabs/blob/master/beanlabs/compensation/net-worth-over-time.py

- It's not sufficient to add to an inventory because you'll need to convert
to market value
- Furthermore, one needs to convert all market values to a single currency.
The script does that.

In the new (v3) version, I will make the Python API take a more prominent
space with developer documentation specific to how to accomplish various
tasks with an Inventory (there are some details which aren't entirely
obvious, especially around market value conversions).





On Sun, Feb 14, 2021 at 3:45 PM Aaron Stacy <[email protected]> wrote:

> OK after reading the Inventory
> <https://github.com/beancount/beancount/blob/v2/beancount/core/inventory.py>
> class docs, I think I've got words for my issue -- the query's balance is a
> single inventory for all accounts, and I'd like an inventory per account.
>
> I think if I just want a csv I can export to a stacked area chart in a
> spreadsheet, I can do something like:
>
> inventories = defaultdict(lambda: Inventory())
> for directive in beancount.loader.load_file(...):
>   if isinstance(directive, Transaction) and asset_leg(directive) is not
> None:
>
> inventories[asset_leg(directive).account].add_position(asset_leg(directive).position)
>     print_line(inventories)
>
> On Sun, Feb 14, 2021 at 2:00 PM Aaron Stacy <[email protected]>
> wrote:
>
>> For example, this query is useful:
>>
>>     SELECT date, flag, description, account, units(position),
>> units(balance)
>>
>> But it loses the information for the balance of each account (i.e. are
>> the shares of Vanguard 2050 target retirement fund in my 401k or IRA?),
>> which would be nice for a stacked area chart to visualize both the sum
>> across accounts over time as well as individual account balances.
>>
>> It seems like maybe calling beancount.loader.load_file, and then
>> iterating over the transactions with an inventory object for each account
>> may be the way to go.
>>
>> On Sun, Feb 14, 2021 at 9:46 AM Aaron Stacy <[email protected]>
>> wrote:
>>
>>> Hi all, my I’ve seen some references to net worth over time
>>> scripts/queries, but I’m having trouble finding specifics. Anyone have
>>> quick links to share? Thanks!
>>
>> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beancount/CACjABkm%3DiFsZwwr-fUJVnCSxWfKG4QU18PTfWJskSJrPrApQgA%40mail.gmail.com
> <https://groups.google.com/d/msgid/beancount/CACjABkm%3DiFsZwwr-fUJVnCSxWfKG4QU18PTfWJskSJrPrApQgA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/CAK21%2BhMAzSVXbMnhn%2BkxdM64ZOjrc7VETd9ayKGbA2XrHnD9Ew%40mail.gmail.com.

Reply via email to