Asset allocation analysis tool

305 views
Skip to first unread message

Red S

unread,
Jul 14, 2019, 1:06:30 AM7/14/19
to Beancount
An asset allocation analysis tool that uses Beancount is here:
https://github.com/redstreet/beancount_asset_allocation

Contributions welcome.

Understanding the asset allocation of a portfolio is important. This script reports your current portfolio's asset allocation.

Configuration
You specify a set of accounts to consider (using regex patterns).

You also specify the percentage of each asset class for each commodity in your accounts as a part of its metadata in your Beancount ledger.

Sample output:
Asset Type Percentage Amount
-------------------- ------------ --------
bond 17.8% 240
bond_municipal 38.9% 525
equity 5.6% 75
equity_international 26.7% 360
realestate 11.1% 150
--- --- ---
Total 100.0% 1,350

Account balances:
`-- Assets
`-- Investments
|-- Brokerage 1 BNCT
`-- XTrade 2 BNCT
10 COFE

Martin Blais

unread,
Jul 26, 2019, 8:06:11 AM7/26/19
to Beancount
Added to contrib doc list.
Thanks Red!

BTW did you see this doc?
and this code?
I do a similar thing (across multiple dimensions) but delegates all the aggregation and reporting to a spreadsheet that is updated with live market data.





--
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 post to this group, send email to bean...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/c7491d83-2482-411d-9278-84d917086627%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Red S

unread,
Aug 3, 2019, 3:26:39 AM8/3/19
to Beancount
Thanks for adding it to the contrib list!

Yes, I have found your export tool useful, but thanks for mentioning it. I referenced it through another thread on the github fava thread here.

I wrote this as a way to get a quick dump of the current state, without having to mess with sheets, and as a foundational tool to write a GUI page in Fava (at some point in the future). Pasting from that github thread here for anyone reading this thread:

------

BTW, @blais has code for a more generic version of this in the beancount source (beancount/experiments/portfolio). Have you checked that out? It's lacking an example, but it's short and easy to understand if you can read python code.

Also check out this recent thread:
https://groups.google.com/forum/#!searchin/beancount/%22asset$20allocation%22|sort:date/beancount/F_pOdotQoxQ/4S4mBUMbAwAJ

The main point there being that exporting raw data to a spreadsheet which calculates your asset allocation is far more powerful than a static script, as it allows you to easily play with "what if" scenarios without having to change code.

------
To unsubscribe from this group and stop receiving emails from it, send an email to bean...@googlegroups.com.

Red S

unread,
Aug 3, 2019, 3:29:28 AM8/3/19
to Beancount
The tool now outputs asset buckets in a hierarchy. It also supports tax-adjusted asset allocation. Example output:

Asset Type Percentage Amount --------------- ------------ -------- total 100.0% 2,750 bond 48.2% 1,325 municipal 19.1% 525 equity 46.4% 1,275 international 43.6% 1,200 realestate 5.5% 150 Account balances: `-- Assets `-- Investments 7 BNCT |-- Brokerage 1 BNCT `-- XTrade 2 BNCT 10 COFE

Vivek Gani

unread,
Aug 25, 2019, 6:35:30 PM8/25/19
to Beancount
Nice to see more people working on this.

Just sharing for reference, my current workflow for viewing asset-allocation has been a two-stage process:
- Use beancount-plugins-metadata-spray for setting up the portfolio metadata.
- A fava extension with similar intent as the demo one in fava to present asset allocations, with some table row/column tree formatting to handle asset-class -> asset-subclass -> account breakdown. I haven't released it yet  but if there's interest I can try to throw whatever I've written so far out there.

Red S

unread,
Aug 31, 2019, 7:55:26 PM8/31/19
to Beancount
That's great. It would be very helpful if you posted your fava plugin. It's fine if it's rough around the edges. Thank you!

Vivek Gani

unread,
Sep 7, 2019, 7:29:07 PM9/7/19
to Beancount
Thanks Red. I've started Fava Classy Portfolio: https://github.com/seltzered/fava-classy-portfolio . For anyone else following this thread, here's the introduction:

"Classy Portfolio is an Extension for Fava, a web interface for the Beancount plaintext accounting software. The extension displays a list of different portfolios (e.g. 'taxable' vs. 'retirement'), with breakdowns using 'asset-class' and 'asset-subclass' metadata labels on commodities."

Let me know if you have any issues running it. Should work though haven't personally tried since doing some renaming.

Martin Blais

unread,
Sep 8, 2019, 8:48:36 AM9/8/19
to Beancount
Thanks Vivek,
Added to the list of contrib tools
https://docs.google.com/document/d/1Z37bQ45wDtjTPaMQ_x-f33p1trH9fNosEAUgbQXwp30/edit#
> --
> 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/7a4b8fb6-74f5-4f8e-84f9-32490d3cb13d%40googlegroups.com.

Red S

unread,
Dec 8, 2019, 4:15:25 PM12/8/19
to Beancount
Thanks for sharing this, Vivek! I tried it, but got a red error box in fava, and haven't figured out where the error output is. There's nothing in the console. Details here: https://github.com/seltzered/fava-classy-portfolio/issues/1

On a separate topic: I tried running the "Portfolio List Sample Report Extension" that ships with fava. Looks like you authored it (thank you!), so here's a question: how can I get it to optionally display the aggregate balance of all subaccounts for each row? Even better would be if it were able to display the table in a hierarchy exactly like the Balance and Income pages in fava.

Thank you.
Reply all
Reply to author
Forward
0 new messages