GNOME Bugzilla – Bug 343245
Advanced Portfolio gets basis wrong with stock split
Last modified: 2018-06-29 21:06:00 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)
Created attachment 66388 [details] Sample file exhibiting problem
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.
Scott, Thanks for the patch, that does indeed seem to clean up the basis calculation.
See also bug#336240
Created attachment 95990 [details] The price editor panel
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.
Should be fixed by r16620, backported to branches/2.2 as r16663. Please mark the patch as obsolete or committed, whatever fits better.
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.
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.
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.