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 343245 - Advanced Portfolio gets basis wrong with stock split
Advanced Portfolio gets basis wrong with stock split
Status: VERIFIED FIXED
Product: GnuCash
Classification: Other
Component: Reports
1.9.x
Other All
: Normal normal
: ---
Assigned To: Chris Lyttle
Chris Lyttle
Depends on:
Blocks: backport
 
 
Reported: 2006-05-28 21:26 UTC by Stephen P Williams
Modified: 2018-06-29 21:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Sample file exhibiting problem (4.12 KB, application/octet-stream)
2006-05-28 21:28 UTC, Stephen P Williams
  Details
Fix doubling up in basis calculation (7.76 KB, patch)
2006-05-31 00:57 UTC, Scott Oonk
none Details | Review
The price editor panel (16.13 KB, image/jpeg)
2007-09-21 22:08 UTC, David Wilson
  Details

Description Stephen P Williams 2006-05-28 21:26:36 UTC
Please describe the problem:
I have an investment in Mobile Mini (NASDAQ:MINI) which is relatively simple:

1.  I purchased 100 shares on 01/02/2006 (mm/dd/yy) for a total
purchase+commission of $3705.95

2.  On 03/13/2006, the stock split 2:1.  My 100 original shares are now 200
shares, but my basis should still be $3705.95

3.  On 05/26/2006, MINI closed at $31.35

Steps to reproduce:
1. Create a new GnuCash file using the new account druid
2. Add a new account "Assets:Stocks"
3. Add a new Stock account for Mobile Mini (NASDAQ:MINI)
4. Open the "Mobile Mini" account register
5. Add a "buy" transaction for 100 shares on 01/02/2006 at a total buy price of
$3705.95 and proceeds coming from Equity:Opening Balances
5. Use the "Transactions:Stock Split..." dialog to enter the stock split (100
shares received, no cash-in-lieu)
6. In the price editor, add a "last" price for MINI at $31.35 on 05/26/2006
7. Run "Reports:Assets & Liabilities:Advanced Portfolio"


Actual results:
The numbers in the report make absolutely no sense:

1.  The basis is reported as $7411.90 (which is 2x what it should be)
2.  There is a "Realized Gain" of $3705.95
3.  There is an "Unrealized Gain" of -$1141.90


Expected results:
1.  My basis is $3705.95 -- a stock split does not affect the basis in the
investment.
2.  There is no "realized gain" yet becase I have not sold any of the investment.
3.  My unrealized gain should be +$2564.95 (which is what is in the "Total Gain"
column


Does this happen every time?
Yes

Other information:
I have attached a sample gnucash file (advanced-portfolio)
Comment 1 Stephen P Williams 2006-05-28 21:28:07 UTC
Created attachment 66388 [details]
Sample file exhibiting problem
Comment 2 Scott Oonk 2006-05-31 00:57:13 UTC
Created attachment 66502 [details] [review]
Fix doubling up in basis calculation

I was seeing a similar problem where I had one transaction to purchase shares, then a second transaction to re-invest dividends.  The attached patch should fix both problems.  It also fixes a .01 rounding error in the basis calculation I was seeing in one of my accounts.
Comment 3 Stephen P Williams 2006-06-03 21:40:40 UTC
Scott,

Thanks for the patch, that does indeed seem to clean up the basis calculation.
Comment 4 Christian Stimming 2006-06-20 12:22:51 UTC
See also bug#336240
Comment 5 David Wilson 2007-09-21 22:08:32 UTC
Created attachment 95990 [details]
The price editor panel
Comment 6 Andrew Sackville-West 2007-11-09 01:17:43 UTC
I took the time to port this to svn and can upload if people want it but I don't think this is the right fix. Instead the thing to do is tweak the way we go into basis-builder so that we actually account for splits properly by changing the basis-list. That means for a 2:1 split we would double the number of shares and half the price in the basis list. The patch above works for the specific case above, but I don't think it works in more complex cases where, for example, there were several purchases at different prices and *then* a split and then some sales all while doing FIFO basis accounting. That gets real complicated and you need to track the different price points and split them independently. 

The rounding stuff is good though and I'll include it in the patch to implement the above. Or post up the rounding patches to a separate RFE bug and note it here.
Comment 7 Andreas Köhler 2007-12-16 12:35:22 UTC
Should be fixed by r16620, backported to branches/2.2 as r16663.

Please mark the patch as obsolete or committed, whatever fits better.
Comment 8 ellisonch 2008-05-28 22:32:17 UTC
I'm getting faulty advanced portfolio behavior due to splits in gnucash 2.2.5 for windows.  

Account	Symbol	Listing	Shares	Price		Basis	Value	Money In	Money Out	Realized Gain	Unrealized Gain	Total Gain	Total Return	Brokerage Fees
xxx	xxx	NASDAQ	183.40	$16.14		$	$2,960.11	$2,500.00	$0.00	$	$	$	0.00%	$0.00

notice the blank fields, which only contain dollar signs.
Comment 9 Andrew Sackville-West 2008-08-15 00:20:34 UTC
do you mean with a stock split, as in 1 share of XZY is now 2 shares? or do you mean a split transaction?

a sample data file showing this behavior would be appreciated.
Comment 10 John Ralls 2018-06-29 21:06:00 UTC
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=343245. Please update any external references or bookmarks.