Here's my take at a script that will calculate the money-weighted return 
for a portfolio (i.e. the XIRR function in spreadsheets).

https://github.com/hoostus/portfolio-returns

All it does it output a single number -- the rate of return. The only real 
work this script does is crawl through beancount files and figure out what 
cashflows in & out of the account there were over the specified time 
period. Then it feeds those cashflows into an IRR calculation.

Here's the return over the past 1 year.

> python irr.py --account Assets:US:Vanguard:Roth --1year 
/Volumes/my_docs/beancount/my.beancount --internal Income:TaxFree:Dividends 
0.72%

(Apparently not a fantastic year for my Roth IRA!)
Here's the return year-to-date.

> python irr.py --account Assets:US:Vanguard:Roth --ytd 
/Volumes/my_docs/beancount/my.beancount --internal Income:TaxFree:Dividends 
115.86%

(All numbers are annualised, so even a tiny increase after 19 days results 
in a huge annual rate of return.)

It seems to work the way I expect on my own beancount file and a few other 
small test cases I put together. Feel free to email me or post here if you 
have problems, suggestions, etc.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to beancount@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/bba922da-b960-480e-9e0c-9aececcf39b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to