Subject: Tax Code - Capital Gains Computation

Last-Revised: 4 Aug 1998
Contributed-By: John Schott (jschott at, Art Kamlet (artkamlet at, Chris Lott (contact me), Rich Carreiro (rlcarr at

Gains made on equities (i.e., stocks or mutual funds) are subject to capital gains taxes. In the simplest case, you bought a lot of shares (either stocks or mutual funds) at some date, made no further investments (took your dividends in cash), and finally sold the shares at some later date. Your gain is simply the difference between your net cost and net income, and you report that as a capital gain. This article focuses on computing the amount of the gain (but not the amount of tax you'll have to pay, see the article on capital gains tax rates elsewhere in the FAQ for that).

Note that this article discusses only realized capital gains. Tax is only due on a realized capital gain, never (at least not as of this writing) on an unrealized capital gain. A realized capital gain is money in your pocket. If you bought shares at 10 and sold at 20, you realized a capital gain of $10 per share, and of course Uncle Sam (and just about every other tax authority out there) wants a piece of the action. An unrealized capital gain is a gain that you have on paper; in other words, you bought a stock at 10, still hold the shares, and on some date it's trading at 20. You have an unrealized capital gain as of that date of $10 per share, and because it's

unrealized, there are no tax implications.

The first part of computing capital gains and gains taxes is determining the cost basis of the securities that you sold. For more information on that, see the FAQ article on computing cost basis. That article discusses how to compute the cost basis if you inherit or are given some stock or other equities.

Computing gains is simple for a sale of a single share, or a sale of a single lot of shares. The situation becomes more complex if you acquired several lots of shares at different prices. It's not so bad for stocks, because when you sell shares of stock, you always, always, always sell specific shares. But when you sell shares in a mutual fund, things are not as simple. We'll cover these two cases next.

  • Selling shares of stock.
    For example, say you hold 200 shares of IBM, half of which you bought at $40 and half at $50 (I should be so lucky). What price should you use if you sell 100 shares?

    In this simple example, it's your choice: either $40 or $50. But, to be legal, you must specify to your broker precisely which lot you are selling before you give the sell order. IRS Pub 550 clearly says that adequate specific identification of shares has been made if you tell the broker at time of sale what shares are being sold and if the broker so notes it on the confirmation slip. Many brokers (especially as they now have years of computer records) are able to mark that on your confirmation slip automatically. But another way is to tell your broker and then get him to sign a confirmation letter attesting to that fact. If you don't do this, the IRS, in an audit, may reverse your decisions.

    Note that the broker is under no obligation to accept a specific shares order, but I personally would take my business to another broker if I ran into that.

    In any case, the key element in identifying specific shares to be sold is that you've got to convince the IRS that you made your choice of what shares to sell prior to the trade and convince the IRS that you informed the broker of that choice (also prior to the trade).

    If you don't tell the broker, and get no information on the confirmation slip, the specific shares you sell are the oldest (sometimes called first-in first-out or FIFO).

  • Selling shares of a mutual fund.

    Mutual fund investors have to choose one of four possible methods of computing their basis for sold shares. These are as follows.

    1. Specific shares -- the investor decides which specific shares are to be sold.
    2. First-in-first-out (FIFO) -- the oldest shares are sold first (this is actually a kind of specific shares).
    3. Average cost, single category -- the basis of a share is the average basis of all shares.
    4. Average cost, double category (may now be triple category, given the new capital gains law) -- shares are segregated by holding period, the basis of a share in a given category is the average basis of all shares in that category.

    Investors may switch between (1) or (2) as they like, but once (3) or (4) is chosen for a security, the investor must stick with that method until he has entirely liquidated his position in the security or receives IRS permission to change methods.

    The following discussion details the average cost, single category method (3), which is probably the most commonly used method.

    The description that "the basis of a share is the average basis of all shares" pretty much says it all. Despite this, the calculation often confuses people, especially when additional purchases are made subsequent to sales, and it can be laborious to keep track of everything. Key points to remember are the following.

    • Reinvestment of distributions are treated exactly like (and in fact are) purchases.
    • Every time a sale is made, the basis of every remaining share becomes the average cost used in the sale calculation. A share has no "memory" of what its previous basis values were.
    • For purposes of computing holding period only, you are deemed to be selling the oldest shares first. You have no choice in the matter.

    Various software packages such as Captool, by Captools Inc (formerly Techserve) can do the computation for you. If I were doing it manually (or using a spreadsheet) I'd probably do something like the following.

    1. Divide a piece of paper into six columns. Label them "Date", "Number of shares", "Cost", "Total Shares", "Total Cost" and "Average Cost".
    2. Fill in the first three columns for all your purchases up to the point of your first sale.
    3. Now fill in the "Total Shares" column. Obviously, for the first entry this will be equal to the number of shares bought. For subsequent entries, it will be equal to the "Total Shares" value of the previous entry plus the "Number of Shares" value for the current entry.
    4. Fill in the "Total Cost" column the same way.
    5. Fill in the "Average Cost" value for the final entry by dividing that entry's "Total Cost" value by its "Total Shares" value. You could do this for every entry (and that would be the easier thing to do in a spreadsheet) but only the average cost as it existed right before a sale matters, and if you're doing it manually why waste the time computing and writing down numbers you won't need?
    6. Now put in an entry for your first sale.
      • Put down the date.
      • Put the quantity of shares sold in the "Number of Shares" entry as a *negative* number (you are selling them, after all).
      • Multiply "Number of Shares" by the average cost you got in step (5) and enter that in the "Cost" column. This will be negative -- as well it should -- since a sale reduces your total basis by the basis of the shares that are sold.
      • Fill in "Total Shares" for this entry like you did in step (3). Since "Number of Shares" for this entry is negative, "Total Shares" will decrease as it should.
      • Fill in "Total Cost" for this entry like you did in step (4). Since "Cost" for this entry is negative, "Total Cost" will decrease as it should.
      • Note that your gain (or loss) on the sale is the sum of your sales proceeds and the "Cost" value (which is a negative number) of the sale entry.
    7. If your next transaction is a sale, do it just like (6). If your next transaction is a purchase:
      • Put down the date.
      • Put down the shares bought in the "Number of Shares" column.
      • Put down the cost in the "Cost" column.
      • Fill in "Total Shares" as in step (3).
      • Fill in "Total Cost" as in step (4).
      • If desired, fill in average cost column. You only really have to do this for a purchase entry that immediately preceeds a sale entry.
    8. Keep the sheet up to date with all purchases and sales as you make them.

    Note that this procedure only tells you the overall gain or loss on a sale. You still have to determine the holding period for the shares sold, and if multiple holding periods are involved, apportion the gain or loss into each holding period.

    As previously stated, you must consider the oldest remaining shares to be the ones sold for this purpose. So if you sell N shares, go back to your purchase records and mark off (physically or mentally) the oldest remaining N shares (which may well be from different purchases) and see what the holding periods are.

    Here's an example for all of this:

    • On 02/01/97 buy 100sh for $1000.
    • On 08/01/97 buy 75sh for $1000.
    • On 12/23/97 reinvest $600 of distributions getting 40sh.
    • On 12/01/98 sell 200sh for $4000.
    • On 12/24/98 reinvest $300 of distributions getting 14sh
    • On 06/15/99 buy 100sh for $2000
    • On 10/31/99 sell 50sh for $900

    Date Nr Shares Cost Total Shares Total CostAvgCost
    02/01/97 100 $1000.00 100 $1000.00
    08/08/97 75 $1000.00 175 $2000.00
    12/23/97 40 $ 600.00 215 $2600.00 $12.0930
    12/01/98 (200) ($2418.60) 15 $ 181.40
    12/24/98 14 $ 300.00 29 $ 481.40
    06/15/99 100 $2000.00 129 $2481.40 $19.2357
    10/31/99 (50) ($961.79) 79 $1519.61

    Since the basis of the shares sold on 12/01/98 was $2418.60 while the proceeds of that sale were $4000, there was a $1581.40 gain on the sale. The shares that were sold were the 100 shares purchased 02/01/97, the 75 shares purchased 08/08/97, and 25 of the forty shares purchased 12/23/97. The 100 shares purchased 02/01/97 have a holding period of over 12 months, the 75 shares purchased 08/08/97 also have a holding period of over 12 months, and the 25 shares sold out of the block of 40 purchased 12/23/97 have a holding period of less than 12 months. Enter each piece in the appropriate part of Schedule D, prorating the $2418.60 basis and the $4000 proceeds across the pieces based on the number of shares in each piece.

    Now, since the basis of the shares sold on 10/31/99 was $961.79 while the proceeds were $900, there was a $61.79 loss on that sale. The shares that were sold were the remaining 15 shares in the block of forty purchased 12/23/97, the 14 shares purchased 12/24/98, and 21 shares from the block of 100 purchased 6/15/99. The 15 shares purchased 12/23/97 have a holding period over 12 months, while both the 14 shares purchased 12/24/98 and the 21 shares purchased 06/15/99 have holding periods under 12 months. Again, enter each piece in the appropriate parts of Schedule D, prorating the $961.79 basis and the $900 proceeds.

    Finally, there's a reporting shortcut. If you have multiple purchase blocks in the same holding period category, you can combine them into a single entry. Just write "various" for the acquisition date and combine the basis and proceeds of the blocks to get the basis and proceeds of the single entry. For example, for the 10/31/99 sale, on the short-term part of Schedule D I would combine the 14 12/24/98 shares and the 21 6/15/99 shares into a single entry, reporting 35 shares, acquisition date of "various", sell date of 10/31/99, basis of $673.25, proceeds of $630.00, and a loss of $43.25.

    And now you see why I use a piece of software to track all this and generate reports for me :-).

Remember that the averaging method for computing cost basis applies only to shares of mutual funds and does not apply to conventional stock sales. A cost basis includes brokerage and all other costs specifically attributable to holding the security. Be sure to correct your per-share values for stock splits (see the article elsewhere in the FAQ for more information about splits) and dividends, as well as any participation in a DRIP.

Ok, hopefully by now you have computed the total gain on your equity sales. Now you have to figure out how much tax you owe. Please see the article in the FAQ on capital gains tax rates for more help.

Previous article is Tax Code: Capital Gains Cost Basis
Next article is Tax Code: Capital Gains Tax Rates
Category is Tax Code
Index of all articles