Christian Stimming wrote:
Derek Atkins schrieb:
I usually use the "Nearest in Time" option; the weighted average is not particularly informative. Weighted average is, however, the default; and it appears that that it's used to determine the cost when computing the unrealized gain. Since it's calculated using absolute values, it's not even the correct number.
Hmm, then that's definitely a bug..
However, there is a particular reason to have "Weighted Average" the default for any of the multi-currency report: GnuCash has two kinds of prices. There are *explicit* prices with an entry in the Price Editor. And there are *implicit* prices whenever a transaction with multiple currencies is booked.
.........
Christian
For the stock case, weighted average would work fine (at least for my test case) if the average were computed using the algebraic rather than the absolute values (with testing for 0/0 cases). I'm not sure I understand the impact on the implicit pricings. My example was buying 100 shares at $5, selling it at a later date at $5, and then at a still later date buying 10 shares at $20. The weighted average appears to be calculated as (5*100+5*100+20*10)/(100+100+10)=$5.71/sh. I think it should be calculated as (5*100-5*100+20*10)/(100-100+10)=$20.00/sh. The individual prices are always positive, but the shares and the values can both be negative. Seems like this ought to work with the implicit prices as well. The gotcha in this is the after the second transaction I have zero shares with an undefined price ($0/0); so we need to test and skip the case where there's no current position in the asset.
Dave _______________________________________________ gnucash-devel mailing list [email protected] https://lists.gnucash.org/mailman/listinfo/gnucash-devel
