Fava Plugin to show portfolio summaries with rate of return

703 views
Skip to first unread message

Phractured Blue

unread,
Oct 15, 2021, 10:08:10 AM10/15/21
to Beancount
I've developed a Fava plugin that can calculate a portfolio summary. With several features I've not seen brought together in one place before.

What I needed was a way to group my various accounts by type (Roth, Pre-Tax retirement, Post-Tax investment, Cash) to see the total value of each group.  Additionally I was interested in comparing the performance of managed vs un-managed accounts (which is not straight-forward given the sporadic cash-flow increases).

I settled on calculating the TWRR (Time-Weighted Rate of Return) and MWRR (Money-Weighted Rate of Return) along with Cost and Balance for each account along with the account groups.  Calculating TWRR can be very expensive (even though the MWRR algorithm is significantly more costly) due to the need to calculate the balance at each cashflow point, so by default TWRR calculation is disabled.  It takes about 15 seconds to calculate TWR for ~1000 cash-flow transactions on  my portfolio.

I'm no financial wizard, so the MWRR code is based off the 'portfolio-returns' project ( https://github.com/hoostus/portfolio-returns), and I just hope I got the TWRR calculation correct.  I based the portfolio groups off the fava-classy-portfolio project (https://github.com/seltzered/fava-classy-portfolio)

I thought others may have a similar need, so if you there is any interest, the project can be found here:


Ben Blount

unread,
Oct 15, 2021, 3:42:31 PM10/15/21
to Beancount
Nice project!

--
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/24ed53aa-bc21-4fad-bfb3-ced422062857n%40googlegroups.com.

Pablo Osers

unread,
Dec 9, 2021, 10:15:17 AM12/9/21
to Beancount
Hi Phractured, 

Pretty nice plugin, I'll download it this week and give it a try.

Just to let you know, this is my per portfolio dashboard I already have in google sheets.

dashboard.png

I'll try to see if I'm able to understand your code and adapt it to show this dashboard. If you have time and want to help, let me know
BR
Pablo

Pablo Osers

unread,
Mar 28, 2022, 9:32:27 AM3/28/22
to Beancount
Hi Guys,

Finally got some time to tweak your plugin, pretty awesome BTW.

Here is a screenshot of my current work:

  • Added:
    • multi-currency support
    • units
    • PnL (with color)
    • Last price Date bellow balance (don't know if I'm using the proper API for this)
  • Pending:
    • Add dividends column 
Hope to get your feedback - comments

Annotation 2022-03-28 152628.png

Phractured Blue

unread,
Mar 29, 2022, 12:56:09 PM3/29/22
to Beancount
That looks interesting.
I'd be happy to look at/incorporate your changes into my repo.  Just make a pull request on the GitHub repo. I'm not sure I need the same columns as you, so I'll probably want to make the shown columns configurable, but overall it looks like a nice enhancement.

Chris Arderne

unread,
Mar 29, 2022, 12:56:14 PM3/29/22
to Beancount
@pablo
Can you share the repo where you've done this?
Message has been deleted

Pablo Osers

unread,
Mar 30, 2022, 6:38:45 AM3/30/22
to Beancount
Done!

Pablo Osers

unread,
Mar 30, 2022, 6:39:14 AM3/30/22
to Beancount

Pablo Osers

unread,
Jun 12, 2022, 2:15:56 AM6/12/22
to Beancount
Hi again,

just saw that you updated the code, you have to make a minor change on the template (for pnl colors to work).

You change the column name from PnL to pnl, so please you need to modify the name validation in the template.

Thanks

On Tuesday, March 29, 2022 at 6:56:09 PM UTC+2 Phractured Blue wrote:

Red S

unread,
Jun 14, 2022, 10:58:13 PM6/14/22
to Beancount
Thanks for sharing! Computing and displaying rate of returns is definitely a useful thing to have, and I'd love to see a "standard" solution for this for Beancount and Fava. A few challenges:

1. Extracting cashflows turned out to be far trickier than I'd imagined when I tried this a few years ago. I also tried hoostus' portfolio-returns, and though the code is clear and helpful, I found that it failed to consider several cases, because of which it produced between small and very large errors compared to what I was seeing at my broker, for example.

2. Verification that the right cashflows were used is a challenge. It's impossible to have faith in the returns numbers without such verification.

Martin wrote and shared beangrow which solves 1 and 2 above very well. See Martin's doc for more. It also covers grouping, which you mentioned as well. Also see my review of beangrow.

Just at thought, given all of that: it would be awesome if your backend could be made to work with beangrow instead.

Pablo Osers

unread,
Mar 31, 2023, 6:32:24 AM3/31/23
to Beancount
Hi all,

Opening the thread again as beangrow its now integrated into Fava thanks to this plugin https://github.com/andreasgerstmayr/fava-portfolio-returns

I have a question, I'm unable to configure beangrow to treat the investment as a whole, instead of commodity by commodity and aggregating them as a single investment. What I mean is, is it possible to use beangrow to calculate returns of money inflows-outflows of a group of accounts, without taking into considerations the buys/sells, but all the money transferred into that account and its current market value?

Thanks
Pablo
Reply all
Reply to author
Forward
0 new messages