Cost basis calculator
Bought the same stock at different prices, then sold some? Enter each buy with its date to see your cost basis and realized gain under FIFO or specific identification — split into short- and long-term, lot by lot.
Average basis is only available for mutual fund shares and eligible dividend-reinvestment (DRIP) shares — IRS FAQ, Pub. 550 “Average Basis”.
Buy lots
Educational estimate, not tax advice. Rules: IRS Pub. 550 (holding period, identifying shares, average basis), last verified Oct 15, 2026. Not included: commissions and fees, wash-sale adjustments, gifted or inherited shares, corporate actions (splits, spinoffs, mergers), return-of-capital distributions. Your figures stay in your browser.
FIFO vs LIFO — what’s the difference?
When you’ve bought a stock in several batches at different prices and then sell only part of your holding, the IRS needs to know which shares you sold — because that decides your cost basis, and therefore your taxable gain, and whether each piece of the gain is short- or long-term.
- FIFO (first in, first out) assumes you sold the shares you acquired first. It’s the IRS default when shares can’t be identified.
- LIFO (last in, first out) sells your most recent shares first — under IRS rules it is one way of choosing shares by specific identification.
In a stock that’s risen over time, FIFO usually sells your cheapest (oldest) shares, producing a larger reported gain now — but those old lots are also the ones most likely to be long-term. Newer, pricier lots shrink the gain but may be short-term, taxed at ordinary rates. Which one helps depends on your prices, dates and tax situation.
Specific identification — and what the IRS defaults to
The IRS doesn’t require FIFO. Under IRS Publication 550, if you can adequately identify the shares you sold, your basis is the cost of those particular shares — which means telling your broker which shares to sell at the time of the sale and getting written confirmation from them within a reasonable time. LIFO and “highest cost first” are simply two ways of choosing shares under that rule. If you can’t identify the shares, the basis is that of the shares you acquired first — FIFO.
Average basis: mutual funds and DRIP shares only
Pub. 550 allows the average basis method only for identical shares left with a custodian that are mutual fund (or other regulated investment company) shares, or shares held in a dividend reinvestment plan under the conditions it sets out. The basis of each share is the total basis of all those shares in the account divided by the number of shares. For the holding period, the shares sold are treated as the ones acquired first, so one sale can still be part short-term and part long-term. You have to elect the method with your broker (covered shares) or on your return (noncovered shares). Sources: Pub. 550 “Average Basis”; IRS mutual fund FAQ, checked Oct 15, 2026.
Worked example: FIFO vs LIFO vs specific ID
These are the calculator’s starting values. You bought 100 shares at $50 on Mar 1, 2024, 80 at $78 on Jan 10, 2025, and 50 at $65 on Jun 1, 2026. On Dec 1, 2026 you sell 120 at $90, for proceeds of $10,800. The first two lots are more than a year old by then; the third is not.
- FIFO sells the oldest shares first: all 100 at $50 plus 20 at $78 = $6,560 of basis, a gain of $4,240 — $4,240 long-term, $0 short-term.
- Newest first (LIFO): all 50 at $65 plus 70 at $78 = $8,710 of basis, a gain of $2,090 — $840 long-term, $1,250 short-term.
- Highest cost first: all 80 at $78 plus 40 at $65 = $8,840 of basis, a gain of $1,960 — $960 long-term, $1,000 short-term.
Same sale, same day: the reported gain ranges from $1,960 to $4,240 depending only on which shares count as sold — and the smaller gains come with a short-term slice taxed at ordinary rates. The shares you didn’t sell keep their own basis, so a smaller gain now leaves more unrealized gain in the shares you still hold — the method shifts gain between sales, it doesn’t erase it.
Wash sales change the basis too
If you sell at a loss and, within 30 days before or after the sale, buy substantially identical stock — including through your IRA or Roth IRA, or if your spouse buys it — the loss is a wash sale and can’t be deducted yet. Instead, the disallowed loss is added to the basis of the new shares, and their holding period includes that of the shares you sold. IRS Publication 550’s own example: buy 100 shares for $1,000, sell them for $750, and rebuy 100 shares for $800 within 30 days — the $250 loss is disallowed and the new shares’ basis is $1,050. This calculator does not apply wash-sale adjustments; the tax-loss harvesting calculator has a wash-sale check.
Reconciling with your broker’s 1099-B
Your broker reports each sale on Form 1099-B, and you use it to fill in Form 8949. When your own figure and the form disagree, these are the places to look:
- Covered vs noncovered shares. Brokers report your cost basis (box 1e) for covered securities — generally stock acquired after 2010. For noncovered shares — for example, stock bought before 2011 — the broker can check box 5 and leave the basis blank, so it’s on you to supply it.
- The lot method on file. The basis in box 1e reflects whichever shares the broker treated as sold. If you meant a specific lot but never designated it at the time of the sale, expect FIFO — and compare your result against the FIFO row in the calculator.
- Wash sales (box 1g). Box 1g shows a disallowed wash-sale loss only for covered securities bought back in the same account with the same CUSIP. A repurchase at another broker, in your IRA, or by your spouse won’t appear there — you have to make that adjustment yourself.
- Reinvested dividends. Each reinvestment is its own small buy lot at that day’s price, so a long-held dividend stock can have dozens of lots — enter them all if you’re checking the broker’s figure by hand.
If the 1099-B basis is wrong or missing, Form 8949 is where you report the correct figure; see the IRS Instructions for Form 8949 for the adjustment codes.
Cost basis calculator FAQ
Which cost basis method does the IRS use by default?
If you cannot adequately identify which shares you sold, IRS Publication 550 treats them as the shares you acquired first — FIFO. Specific identification is allowed when you tell your broker which shares to sell at the time of the sale and receive written confirmation within a reasonable time. Check which lot method your broker has on file for your account.
Can I use average cost for individual stocks?
Generally no. Pub. 550 limits the average basis method to identical shares of a mutual fund (or other regulated investment company) and shares held in a dividend reinvestment plan under the conditions it lists. That is why this calculator only offers average basis after you choose “Mutual fund / eligible DRIP shares”.
How is short-term vs long-term decided for each lot?
By that lot’s own holding period: counting starts the day after the trade date you bought and includes the trade date you sold. More than one year is long-term. A single sale that draws on several lots can therefore be partly short-term and partly long-term — the calculator splits it lot by lot. Under average basis, the shares sold are treated as the ones acquired first for this purpose.
Why does my broker’s 1099-B show a different basis?
The usual causes are a different lot method on file, noncovered shares (generally stock bought before 2011) with no basis reported, reinvested dividends you did not enter as separate lots, or a wash-sale adjustment. The 1099-B section above walks through each.
Does this calculator handle wash sales?
No — wash-sale disallowed losses and basis adjustments are not applied here. The tax-loss harvesting calculator has a separate wash-sale check that flags buys within 30 days of a loss sale.
This math stops at what you typed in.
Tradune runs it continuously on your real holdings — with your money-weighted return next to a buy-and-hold SPY twin, and SEC insider filings flagged on the stocks you own.
Educational analytics — not investment advice.