I did something similar to what other have written about.  I wrote a program
that leverages ledger to output records that are fairly easy to parse:

ledger register -C -B ^assets: and expr 'commodity != "$"' --format 
'%(format_date(date))|%(display_amount)|%(account)|%(payee)\n'

For every transaction that is linked to a non-dollar asset, which in my
case means mutual fund ticker symbols, I make sure that I use one of:

Dividend
Gain
Fee
Share Adjustment

somewhere in the payee field when it is internal growth, versus
an external contribution, so that I can skip it during my calculations.

What remains are my contributions and deductions, and I add those
to a cashflow sequence containing a date and a dollar amount.  The
final entry to the cash flow simulates a withdrawal, using the current
value of the account:

ledger balance -C -V --flat --no-total ^assets: and expr 'commodity != "$"'

Once I have a cashflow sequence I use the XIRR algorithm (e.g.,
the one in Finance::Math:IRR on CPAN) to compute the return.

One downside to the way I did it is that it computes the return over
the life of the account, it doesn't currently offer any way to narrow
down the information to just the current year.

Looking over some of the example here I think I should probably
revisit my method and incorporate some of the logic others are
using.


On Friday, January 16, 2015 at 5:28:49 PM UTC-8, Red Street wrote:
>
> Hi all,
> I'm trying to figure out how I can compute investment returns for a given 
> period using ledger.
>
> By "investment returns," I mean the usual. I think this page calls it 
> "Investor return": 
> http://www.bogleheads.org/wiki/Calculating_personal_returns
>
> I was thinking there would be a bunch of other folks here in the same 
> boat, and so, I was hoping to not reinvent the wheel. Any homebrewed 
> solutions or pointers welcome.
>
> Thanks in advance!
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to