Reporting: weighted average price source
Derek Atkins
warlord at MIT.EDU
Mon Jul 7 11:53:09 EDT 2008
"David G. Hamblen" <dhamblen at roadrunner.com> writes:
> A few years back (v1.8x), I had problems with these absolute values, and I
> patched report-utilities.scm,and commodity-utilites.scm so that the balance
> sheet would balance. In addition to completely removing all the numeric:abs,
> I also had to do something about the division by zero in commodity-utilities
> when there was a zero share balance. I'm using the "Nearest in Time" and the
> problem went away in the 2.x updates. If anyone's interested, I can dig up
> my old postings.
>
> Anyway, I vote for getting rid of absolute values in bookkeeping.
It's not a question of book keeping. It's a question of computing
the share price. GnuCash stores buys as a positive and sells as
a negative. As Christian pointed out before, if you buy x shares
for $y and then later SELL x shares for $y then a non-abs weighted
average gives you a price of 0/share! Obviously this is wrong.
The weighted average should be $(y/x) per share. But without
the ABS you get:
y * x + (-y)*x xy -xy 0
-------------- == ------ == --- = 0
x + x 2x 2x
When you use abs() here you get the right answer.
Of course, then you need to make sure you re-apply the negative
for sales.
So it's not a question of absolute values in bookkeeping. It's
a question of absolute values in computing share prices. Not
the same thing.
-derek
--
Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
Member, MIT Student Information Processing Board (SIPB)
URL: http://web.mit.edu/warlord/ PP-ASEL-IA N1NWH
warlord at MIT.EDU PGP key available
More information about the gnucash-devel
mailing list