What to do when you sell a stock and close a position in GnuCash
Today I have a really simple GnuCash tip which saves me a lot of time, effort and screen real estate. I've solved the problem of what to do with closed positions in GnuCash.
The problem I'm referring to stems from the fact that any security you might invest in, whether it be stocks, bonds, mutual funds or what have you, results in the creation of a GnuCash account. This is because by definition anything which money flows into or out of is known as an account.
When you invest in a new stock, something you've never owned before, money flows out of your cash account and into the account representing the security purchased. Conversely, when you sell that security money flows out of the security's account and into a cash account.
But when you completely close out your position in a security, GnuCash retains a record of the security's account even though that account has zero balance. Over time a fair number of closed positions can result in a rather unwieldy looking GnuCash account tree - a long listing of zero balance accounts. What to do?
You can't simply delete these accounts, because if you do you'll lose all record of the trades. The tax man doesn't like that.

The answer is to create a separate account within your brokerage account where you'll keep your closed positions. I call mine Closed Positions. You can see it highlighted in the green circle above. When you sell the last shares of some security and close out that position, simply right-click on that security's account and select Edit. Then select your Closed Positions account as the new parent account for this security, and click OK.
Now all closed positions will still be available to you on your GnuCash accounts tree screen, but they will be under the Closed Position account, which you can keep collapsed, expanding it only when you need access to those closed position securities.
If you like, you can even hide the Closed Positions account by editing its properties and selecting the Hidden check box option.
I had been struggling with an ever growing stock accounts list for quite a while when I finally stumbled on this idea. I guess you could say it was inspiration born of necessity. Whatever it was, I was delighted when I discovered that I could so easily rearrange closed position accounts, setting them aside, out of sight until I need them at tax time.