Advanced portfolio report

Andrew Sackville-West ajswest at mindspring.com
Wed Nov 28 12:14:34 EST 2007


On Tue, Nov 27, 2007 at 11:01:11PM -0500, Morrison J. Chang wrote:
> On Tue, 2007-11-27 at 08:01 -0800, Andrew Sackville-West wrote:
> 
> > I'm curious to see what you did. I've also finished that part of the
> > report... heh heh. In a nutshell: I've kept track of which splits have
> > already been taken care of in a list and then only used a split in the
> > basis calculation if we haven't seen it before. For the
> > splits/mergers, I just run through the basis-list and total up the
> > number of shares, work out the ratio and apply that ratio back through
> > the list. That way the basis get recalculated for every "lot" in the
> > basis list. 
> > 
> 
> [too many meanings to the word split]
> I've done something similar. I've made the assumption that only
> ledger-splits on the same account and that have both a units and value
> entry are worth dealing with. If it has units but no value - its a
> stock-split/merger and a factor is applied to the basis list.

yep. 

...

> > 
> > sure. I'm putting this email on the list. I'm just about done with
> > mine and I'll post it up there as well. We can have dueling reports!
> > 
> Cue the banjo...

brickbats at 40 paces...

> 
> > > 
> > > My version should handle splits and correctly calculate gain for
> > > avg-basis, fifo, and filo. The issue with what I have now is some
> > > rounding problems (probably due to using gnc-numeric) and I ignore
> > > transaction values from income accounts since I don't know if there are
> > > dividend or capital gain accounts.
> > 
> > There's really no way to tell about the income accounts,
> > unfortunately. At least if its reinvested. I suppose if its not
> > reinvested you could tell because its money in and money out, but no
> > shares touched. That's pretty tricky though. 
> > 
> > THe rounding is easy. Look at bugzilla #343245, comment #2 attachment
> > includes code to fix the rounding errors. Pretty straightforward.
> > 
> > 
> Hmm ... did a quick search and replace using GNC-DEMON-AUTO (logior
> GNC-DENOM-REDUCE GNC-RND-NEVER) instead of the usual 10000 GNC-RND-ROUND
> but I seem to get some odd problems with display (like blank or
> fractional entries in the realized gain column).

there are a handful of roundings that affect the *display* of
values. They are easy to spot as they use 100 as denom. Reverting
those should fix this. I had *exactly* the same thing happen to me yesterday.

> 
> > What are you doing with commissions/brokerage fees?
> > 
> 
> As of now nothing. At some point I figure I would stop mucking the with
> the business rules and start adding a column or something as suggested
> in prior posts.


At the moment, I'm adjusting brokerage fees back out of everything so
that the amounts listed for money-in, money-out, basis etc all reflect
just the pure amounts associated. I've also totalled the brokerage
fees in a separate column. 

> 
> > We should compare notes I think before either of us goes any farther
> > so that we don't continue to duplicate efforts.
> 
> Agreed.
> 
> In any case I just found a test case that I'm failing on that I need to
> fix before I'm ready to post.

What's your test case? Maybe mine already solves it?

I'm ready to post except for all the (display (list foo bar
baz))(newline)'s everywhere from debugging. I'll put mine up today. 

I look forward to seeing what you've got.

A
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20071128/565586ba/attachment.bin 


More information about the gnucash-devel mailing list