After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 780846 - Stock adjustments lead to incorrect ACB
Stock adjustments lead to incorrect ACB
Status: RESOLVED OBSOLETE
Product: GnuCash
Classification: Other
Component: Currency and Commodity
2.6.15
Other Linux
: Normal normal
: ---
Assigned To: gnucash-core-maint
gnucash-core-maint
Depends on:
Blocks:
 
 
Reported: 2017-04-02 15:24 UTC by B Rhodes
Modified: 2018-06-29 23:55 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description B Rhodes 2017-04-02 15:24:08 UTC
One of the big selling features (over QuickBooks) of GNUCash is its ability to track stock transactions efficiently. However, I've noticed a problem in calculating the average cost basis for stocks.

The software works correctly for simple transactions, say I buy 100 shares at $10/share, then the transaction looks like

DR: ABC Corp; [Shares: 100]; [Price: 10]; [Value: 1000]
CR: Cash; [1000]

And when I go to the portfolio report, GNUCash shows the correct adjusted cost base of $1,000.

The problem arises where I need to make adjustments. The broker every so often 'rounds off' shares for no cash value or there's a return of capital which affects the ACB but not the overall shares. For the latter case, for example a return-of-capital of $50, I'd enter:

DR: Cash: [50]
CR: ABC Corp; [Shares: 0]; [Price: 0]; [Value: 50]

For a share adjustment (not quite a split) of, say, decreasing by one share, 1 share, I'd enter:

DR: ABC Corp; [Shares: -1]; [Price: 0]; [Value: 0]

This is how I process the change in LibreOffice Calc. Combining both transactions, I'd calculate the ACB by entering =(1000+50)/(100-1)= $10.61/sh However, the portfolio report in GNUCash doesn't show this.

If I knew anything about the code structure of GNUCash and were competent at C or Scheme, I'd attempt to tackle the problem myself. Whilst I understand that the programmers haven't dedicated GNUCash to be investment software, GNUCash seems to be 99% of the way to solving this problem. It should be adding up all the value adjustments and dividing by all the share adjustments to get the correct ACB. Somewhere along the line isn't - perhaps it's ignoring 'incomplete' share transactions.

Anyhow, it would be great for the ACB algorithm to reflect this method or have a 'logical' way of tracking ACB.
Comment 1 B Rhodes 2017-04-02 15:26:20 UTC
For the sake of correctness, I realise that my ACB example is incorrect. The correct calculation is =(1000-50)/(100-1)=$9.60/sh
Comment 2 John Ralls 2017-04-03 03:12:20 UTC
Have you tried the Advanced Portfolio Report? It's better at handling more complex situations like dividend reinvestment and splits.

Your broker shouldn't be rounding off shares. That's theft. Are you in the USA?

Stock corporations don't do returns of capital, at least not in the US or Europe. When they want to adjust the underlying value of shares they do things like share buybacks to reduce the number of shares outstanding or stock dividends to increase that number. Pass-through entities like partnerships do do returns of capital and those do affect your basis. 

I don't know if the Advanced Portfolio Report can handle returns of capital nor if it does how one would create transactions that it would recognize. I've asked the report's author; he doesn't know either and is looking in to it.
Comment 3 B Rhodes 2017-04-03 05:25:15 UTC
I'm in Canada, and, don't worry, it's 100% legit. Most of the 'stocks' in question are exchange-listed REITs in which ROCs are common.

As for the 'rounding off', it's a clerical adjustment to reconcile fractions differences between the issuers' books and the custodians'. They, in fact, rounded up but the books only reconcile if I make such an entry.

Nothing's getting stolen as the stocks are held at a Canadian charter 1 bank - which is about as highly regulated as you can get!

I checked Advanced Portfolio Report and I see the same issue. It seems as though that the basis only gets adjusted when there's a 'complete' transaction (that is, a share quantity, price AND total value). If any one of those elements is missing, then the adjustment gets ignored entirely.
Comment 4 Mike Alexander 2017-04-09 03:42:12 UTC
Are you sure this doesn't work in the advanced portfolio report?  It should work, and I just tried an example like your return of capital and it seemed to work fine.  The stock adjustment should also work fine since it is really just a very small reverse stock split (e.g. exchanging 100.5 shares for 100 shares).
Comment 5 CDB-Man 2017-04-17 00:25:54 UTC
I have the exact same issue as the requester.  My sample transactions are as follows:

1. Reclassification of cash dividend to return of capital (ie, due to late identification when notified by broker):
> DR: Income:Dividends $50.00
> DR: Trading:XSP: $50.00
>> CR: Assets:Stocks:XSP: [0 shares] [n/a price] $50.00
>> CR: Trading:CURRENCY:CAD: $50.00

The total basis in advanced portfolio is NOT reduced by the $50.00
I skimmed the Scheme, and it looks like the action descriptions are not used. I have the transaction marked as dividend.

2. Issuance of distribution $200.00, with $100 being dividend income and $100 being return of capital
> DR: Cash $200.00
> DR: Trading:XSP: $100.00
>> CR: Income:Dividends: $100.00
>> CR: Assets:Stocks:XSP:  [0 shares] [n/a price] $100.00
>> CR: Trading:CURRENCY:CAD: $100.00

The total basis in advanced portfolio is NOT reduced by the $100.00
I skimmed the Scheme, and it looks like the action descriptions are not used. I have the transaction marked as dividend.
Comment 6 John Ralls 2018-06-29 23:55:43 UTC
GnuCash bug tracking has moved to a new Bugzilla host. The new URL for this bug is https://bugs.gnucash.org/show_bug.cgi?id=780846. Please continue processing the bug there and please update any external references or bookmarks.