8.7. Selling Shares

Entering an investment you are selling is done in the same way as buying one except the total cost of the transaction is entered in the Sell column and the Shares column is entered as a negative amount. The net proceeds from the sale should be transferred from the stock account to your bank or brokerage account.

The proper recording of the stock sale *must* be done using a split transaction. In the split transaction, you must account for the profit (or loss) as coming from an Income:Capital Gains account (or Expense:Capital Loss). To balance this income, you will need to enter the stock asset twice in the split. Once to record the actual sale (using the correct number of shares and correct price per share) and once to balance the income profit (setting the number of shares to 0 and price per share to 0).

In the split transaction scheme presented below, the symbol NUM_SHARES is the number of shares you are selling, SELL_PRICE is the price for which you sold the shares, GROSS_SALE is the total price for which you sold shares, equal to NUM_SHARES*SELL_PRICE. PROFIT is the amount of money you made on the sale. COMMISSIONS are the brokerage commissions. NET_SALE is the net amount of money received from the sale, equal to GROSS_SALE - COMMISSIONS.

表 8.1. Selling Stock using Split Transaction Scheme

AccountNumber of SharesShare PriceTotal BuyTotal Sell
Assets:Bank  NET_SALE 
Assets:Stock:SYMBOL-NUM_SHARESSELL_PRICE GROSS_SALE
Assets:Stock:SYMBOL00PROFIT(Loss)
Income:Capital Gains  (Loss)PROFIT
Expenses:Commissions  COMMISSION 

If you will be recording the sale of the stock as a capital gain (or loss), please see the chapter 「Depreciation and Capital Gains」 for more information on this topic.

8.7.1. Example - Sale of stock with profit

As an example, assume you bought 100 shares of a stock for $20 per share, then later sell them all for $36 per share. In the split transaction scheme above, PRICEBUY is $20 (the original buying price), NUM_SHARES is 100, TOTALBUY is $2000 (the original buying cost), GROSS_SALE is $3600, and finally PROFIT is $1525 (GROSS_SALE-TOTALBUY-COMMISSION).

表 8.2. Selling Stock Split Transaction Scheme

AccountSharesPriceBuySell
Assets:Bank  3525.00 
Assets:Stock:SYMBOL-10036.00 3600.00
Assets:Stock:SYMBOL001600.00 
Income:Capital Gains   1600.00
Expenses:Commissions  75.00 
Selling Stock Example

An example of selling stock for gain. You bought 100 shares of AMZN for $20 per share, and sold for $36.

Selling Stock Example

An image of the account tree after the example of selling stock for gain.

8.7.2. Example - Sale of stock with loss

As an example, assume you bought 100 shares of a stock for $100 per share, then later sell them all for $50 per share. In the split transaction scheme below, PRICEBUY is $100 (the original buying price), NUM_SHARES is 100, TOTAL_BUY is $10,000 (the original buying price), (Loss) is $5000, and finally GROSS_SALE is $5000. Assume the commission was $100.00.

表 8.3. Selling Shares at loss Split Transaction Scheme

AccountSharesPriceBuySell
Assets:Bank  4900.00 
Assets:Stock:SYMBOL-10050.00 5000.00
Assets:Stock:SYMBOL00 5000.00
Income:Capital Gains  5000.0
Expenses:Commissions  100 

Note: You may either enter the loss as a positive number in the 「buy」 column or as a negative number in the 「sell」 column, GnuCash will move the 「negative profit」 to the other column.

Selling Stock at loss Example

Above is a screenshot of the example of selling stock. You bought 100 shares for $100.00 per share, and sold for $50.

Selling Stock at loss Example

An image of the account tree after the example of selling stock for loss.