Unrealized Gains (Again)

John Ralls jralls at ceridwen.us
Tue Mar 7 10:37:32 EST 2017


> On Mar 6, 2017, at 10:46 PM, David Carlson <david.carlson.417 at gmail.com> wrote:
> 
> Perhaps I could state my question a little differently.  I do always enter the total amount and the number of shares and let GnuCash calculate the price for actual transactions.  This forces the number of shares to always match the brokers' statements.  For mutual funds, shares are usually stated to the nearest 1/1000, as they are for this example.  
> 
> I think that whatever rounding discrepancies exist, they are forced by this method to accumulate as unrealized gain.  That is how the first purchase created an instant unrealized gain of $4.72 in the balance sheet report which used the 'nearest in time' quoted price of  $14.62.  This is what I actually expected for the date of purchase.
> 
> What I am more concerned about is ultimately whether the trial balance method of tracking the cost basis for an account with many purchases and sales is accurate when the average cost method (or any variation of lot tracking) is used.  I did not express that in my original message, as I have not gotten that far in my experiment yet.  What I did state was that the unrealized gain as reported by the balance sheet report differed from the spreadsheet unrealized gain number by $4.13 on December 31 2016.  The difference between the report and the spreadsheet changes after most transactions.  Thus I expect that the final closing transaction will probably leave a residual cost basis in that security account, possibly worth several dollars.  I think that has already happened in my data for some closed 401-K's.  
> 
> Would it be appropriate to track whatever residual unrealized gain exists and transfer that amount to equity at some point to drive it to exactly zero after the last fractional share is gone?  If so, is there some easy way in GnuCash to find that residual value for any commodity account in a practical data file that could have hundreds of securities and thousands of purchases and sales?
> 

David,

Although the trial balance report will probably call that error "unrealized" it's actually "unrecognized": Unrealized gains are the gains on things that you haven't sold. Unrecognized gains are realized gains that aren't balanced by an income split. E.g., you transferred $1000 from checking to XYZ when you bought it and transferred $2000 back when you sold it, so you need an income split of $1000 to "recognize" the difference. 

I don't think there's any way to get the unrecognized gains to zero out if you use an average cost basis method when there are multiple interleaved partial buys and sells, as one would have with a long-held mutual fund where you reinvest dividends and periodically rebalance your portfolio. Only a consistently-applied FIFO or LIFO policy will recognize exactly the gains.

If you want the trial balance report to balance out then yes and you've been using average cost or taking the gains off of your brokerage statement, you'll likely need to create adjustment transactions to account for the error. I can't think of any way to get GnuCash to calculate that error, easily or otherwise, unless you close out all of your positions.

Regards,
John Ralls



More information about the gnucash-user mailing list