8.7. Selling Shares

Entering an investment you are selling is done in the same way as buying one (see Section 8.5.2, “Buying New Shares”) 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 Expenses: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).

Note

In order to get GnuCash to commit this zero-share, zero-price split to the transaction, you *must* Tab out of the split. If you use the Enter key, GnuCash will convert the split into shares of the commodity.

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.

Table 8.1. Selling Stock using Split Transaction Scheme

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

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

8.7.1. Example - Sale of stock with profit

As an example we will use the AMZN account created in the previous section. So you bought 100 shares of AMZN for $20 per share, then later sell them all for $36 per share with a commission of $75. 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).

Table 8.2. Selling Stock Split Transaction Scheme

AccountSharesPriceBuySell
Assets:Bank ABC  3525.00 
Assets:Brokerage Account:Stock:AMZN001600.00 
Expenses:Commissions  75.00 
Assets:Brokerage Account:Stock:AMZN-10036.00 3600.00
Income:Cap Gain (Long):AMZN   1600.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 we will use the IBM account created in the previous section. You then have bought 51.7598 shares of IBM for $96.6001 per share, then later sell them all for $90 per share. In the split transaction scheme below, PRICEBUY is $96.6001 (the original buying price), NUM_SHARES is 51.7598, TOTAL_BUY is $5,000 (the original buying price), (Loss) is $341.62, and finally GROSS_SALE is $4658.38. Assume the commission was $100.00.

Table 8.3. Selling Shares at loss Split Transaction Scheme

AccountSharesPriceBuySell
Assets:Bank ABC  4558.38 
Assets:Brokerage Account:Stock:IBM00 341.62
Expenses:Commissions  100 
Assets:Brokerage Account:Stock:IBM-51.759890.00 4658.38
Income:Cap Gain (Long):IBM  341.620

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 $5000 worth of IBM shares with a stock value of $96.6001, and sold for $90.

Selling Stock at loss Example

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