Tools › Investing › Saving and Planning › Capital Gains and Tax Lots


Capital Gains and Tax Lots

Which purchase lots a sale takes, and the gain or loss that results. Paste the lots (date, shares, cost per share), enter the sale and choose a lot method; the page shows the lots taken, the gain or loss on each, whether it is short-term or long-term under the one-year holding rule of IRS Publication 550, the totals, the tax at two rates you enter, the lots that remain, and the same sale under every method side by side. Advanced mode adds a wash-sale check against other purchases, the average-cost method of mutual funds and a sale commission. The page describes U.S. federal rules as general facts; it is an illustration, not tax advice. A calculator for education and analysis, not investment advice.

  • The lots a sale takes under first in first out, last in first out, highest cost, lowest cost or lots you name

  • Gain or loss on each lot, written out for the first one, with the days held and short-term or long-term by the one-year rule

  • Short-term and long-term totals and the tax at two entered rates; a net loss shown with the yearly deduction limit

  • The lots that remain, with their unrealised gain at the sale price

  • The same sale under every method in one table; Advanced: wash-sale check, average cost, sale commission

Capital Gains and Tax Lots


Unit System: /

/

Purchase Lots of One Security (money in any one currency)


The Sale






Tax Rates (percent; illustrative values, enter your own)



Advanced Options



×

Capital Gains and Tax Lots

Capital Gains and Tax Lots: How It Works

What it does

Shares of one stock or fund are often bought at several times and prices. Each purchase is a lot. When some of the shares are sold, the gain or loss depends on which lots the shares are taken from. The page takes a list of lots and one sale, applies a lot method, and shows the lots taken, the gain or loss on each, whether it is short-term or long-term, the totals, the tax at two rates you enter, the lots left, and the same sale under every method. It states U.S. federal rules as they are described in IRS Publication 550 (the edition for 2025 returns). It is an illustration, not tax advice.

The method

Symbols. Ns is the number of shares sold; ps the sale price per share; Fc the sale commission (Advanced); pn = ps − Fc / Ns the price received per share; nk the shares taken from lot k and ck that lot's cost per share; tst and tlt the entered short-term and long-term tax rates as decimals.

Which lots. The lots are put in an order and shares are taken from them one after another until Ns shares are found; the last lot reached is usually taken only in part.

  • First in, first out (FIFO): oldest purchase date first.
  • Last in, first out (LIFO): newest purchase date first.
  • Highest cost first / lowest cost first: by cost per share; the older lot first when two costs are equal.
  • Specific lots: the lots you list, in the order listed.
  • Average cost (Advanced): every share is given the cost cavg = (total cost of all shares held) / (shares held), and the shares sold are counted as the oldest ones for the holding period.

Publication 550 names two ways to find the cost of stock sold: the cost of the particular shares, when they are adequately identified to the broker at the time of the sale, and otherwise the cost of the shares acquired first. It allows the average basis for mutual fund shares. Last in first out, highest cost and lowest cost are ways of choosing which particular shares to identify.

Gain or loss on a lot.

Proceedsk = nk pn,   Costk = nk ck,   Gaink = Proceedsk − Costk

A negative gain is a loss. The cost per share should include any commission paid on the purchase; Publication 550 gives the example of 100 shares bought at 10 with a 50 commission, a cost of 10.50 a share.

Short-term or long-term. Publication 550: property held more than one year gives a long-term gain or loss, and property held one year or less a short-term one; the count begins on the day after the purchase, and the day of the sale is part of the holding period. For securities traded on a market the dates are the trade dates. The page therefore starts the count on the day after the purchase and calls a sale long-term when it falls on or after the anniversary of that starting day. A lot bought on 15 March 2022 is long-term from 16 March 2023. The publication's own example: bought 31 January 2024 and sold 29 January 2025 is short-term; sold 6 February 2025 is long-term. "Days held" in the tables is the number of days from the purchase date to the sale date.

Totals. Gst is the sum of the gains and losses of the short-term lots and Glt that of the long-term lots. Their sum equals the proceeds of the sale less the cost basis of all the shares taken, which the page prints as a check.

Tax at the entered rates. If both totals are gains, Tax = tst Gst + tlt Glt. If one is a loss and the sum is still a gain, the loss is taken from the other total first and the remainder is taxed at that other total's rate. If the sum is a loss there is no tax on the sale; Publication 550 states that a net capital loss for the year is deductible against other income up to the lesser of $3,000 ($1,500 if married filing separately) or the loss, and that the rest is carried over to later years.

Lots that remain. Unsold shares keep their dates and costs. Their unrealised gain is shares × (ps − ck).

Wash-sale check (Advanced). Publication 550: a wash sale occurs when stock is sold at a loss and substantially identical stock is bought within 30 days before or after the sale; the loss cannot be deducted and is added to the basis of the new shares; when the numbers of shares differ, the shares bought are matched with an equal number of the shares sold, in the order bought. The page lists the purchases you paste, and any unsold shares of the lots, that were bought from 30 days before to 30 days after the sale date, and matches them share for share against the shares sold at a loss, in the order those were taken. For nw matched shares with a loss of Lw a share, the disallowed loss is Dw = nw Lw and the basis of the matched new shares becomes their cost plus Dw.

What it assumes

One security, one sale, an ordinary taxable account, shares bought for cash. Dates are trade dates. The two tax rates are yours: the page ships no tax table, because the rate on a gain depends on total income, filing status, state and the tax year. The tax shown is for this sale standing alone; a real return first combines all the year's gains and losses and any loss carried over from earlier years. Not modelled: the net investment income tax, state taxes, the higher rates on collectibles and some other gains, shares received by gift or inheritance (whose basis and holding period follow other rules, see Publication 551), reinvested dividends unless you enter them as lots, stock splits, short sales and options.

When it misleads

A method must be allowed and in place before the sale. The table of methods shows arithmetic. Which methods are open for a given holding depends on the kind of security, on what was elected with the broker, and on identifying the shares at the time of the sale; the choice cannot be made afterwards. Average cost, once used for a fund, limits the later use of the other methods for that fund.

A smaller gain today is a larger gain later. Every method reports the same total once all the shares are sold. A method that uses up the high-cost lots now leaves the low-cost lots for a later sale. The page does not value that timing and does not say which method to use.

The holding-period day count has edge cases. For a purchase on the last day of February the anniversary rule used here can differ by a day from other ways of counting a year. A sale within a day or two of the one-year mark deserves a check against the broker's records.

The wash-sale check is partial. It sees only the purchases entered. It ignores purchases in other accounts unless you paste them, purchases by a spouse or in a retirement account, options and contracts to buy, other sales in the window, and the question of whether two different securities are "substantially identical". It also does not carry the holding period of the shares sold over to the new shares, as the rule does.

Rules change. The rules described are those of the publication edition named above. Later years and other countries differ.

Worked example

The default case (made-up lots): six lots, and a sale of 120 shares at 122.00 on 10 November 2026, first in, first out.

The oldest lots are taken first: all 50 shares of lot 1 (bought 15 March 2022 at 82.00), all 40 of lot 2 (20 June 2023 at 95.50) and 30 of the 60 shares of lot 3 (5 November 2024 at 118.25); 50 + 40 + 30 = 120.

Lot 1: proceeds 50 × 122 = 6,100.00; cost 50 × 82 = 4,100.00; gain 2,000.00. Lot 2: 4,880.00 − 3,820.00 = 1,060.00. Lot 3: 3,660.00 − 3,547.50 = 112.50.

Holding periods: lot 3, the newest, is long-term from 6 November 2025; the sale is a year later, so all three gains are long-term. Gst = 0, Glt = 2,000.00 + 1,060.00 + 112.50 = 3,172.50. Check: 120 × 122 − (4,100.00 + 3,820.00 + 3,547.50) = 14,640.00 − 11,467.50 = 3,172.50.

Tax at the illustrative rates of 24 % and 15 %: 0.24 × 0 + 0.15 × 3,172.50 = 475.88.

Other methods, same sale: last in, first out takes lots 6, 5, 4 and 20 shares of lot 3 and gives a short-term gain of 676.25 and a long-term loss of 207.00; highest cost first gives a net loss of 70.75; lowest cost first gives the largest gain, 3,577.50.

From the publication. Table 4-2 of Publication 550: 160 shares bought at 25, 240 at 20 and 10 at 30; 210 sold at 32. First in, first out gives a basis of 160 × 25 + 50 × 20 = 5,000, which the page reproduces. The average basis is 9,100 / 410 = 22.1951 a share and 4,660.98 for 210 shares; the publication rounds the average to 22.20 and prints 4,662. Its wash-sale example (100 shares bought for 5,000 and sold for 4,000; 50 and 25 shares bought inside the window for 2,750 and 1,125) gives 750 disallowed, 250 deductible and new bases of 3,250 and 1,375, which the Advanced check reproduces.

A calculator for education and analysis. It illustrates general U.S. federal rules and is not tax advice or investment advice.




References

Internal Revenue Service (2026). Investment Income and Expenses (Including Capital Gains and Losses). Publication 550, for use in preparing 2025 returns, U.S. Department of the Treasury, Washington, DC.

Internal Revenue Service (2025). Basis of Assets. Publication 551, Rev. December 2025, U.S. Department of the Treasury, Washington, DC.

Internal Revenue Service (2025). Topic No. 409, Capital Gains and Losses. Tax Topics, U.S. Department of the Treasury, Washington, DC.

Worked Examples

Published examples this tool reproduces; each page lists the inputs to enter and the printed answers.

All worked examples


DISCLAIMER: The methods and calculation on aNOWysis.com are provided as means to educate the reader. There is no warranty, expessed or implied, as to the relevance or accuracy of the methods or calculations. All calculations should be checked by a qualified analyst for appropriateness and accuracy. We will not be held liable for any damages, injuries or deaths caused by using methods or calculations from this site.