Lots used — FIFO
| Lot |
Shares used |
Basis |
Holding period |
Wash sale window check
No repurchase lot found within 30 days
If this is a loss, check whether you bought the same stock within 30 days before or after this sale — that could trigger wash sale disallowance.
Note on method selection: switching between FIFO, LIFO, and Specific ID here is for comparison only. To actually use Specific ID for a real trade, you must identify the specific lot to your broker at or before the trade — it cannot be selected after the fact at tax filing time.
This calculator estimates cost basis and gain/loss for comparison purposes. It does not account for wash sale disallowance adjustments, state taxes, the Net Investment Income Tax, commissions, or your complete tax situation. Not tax advice. Consult a qualified tax professional before filing.
How this cost basis calculator works
Enter each purchase lot — the date, number of shares, and price you paid. Then enter how many shares you plan to sell and at what price. The calculator shows your cost basis and taxable gain under three methods: FIFO (oldest shares sold first), LIFO (newest shares sold first, a form of Specific Identification), and Specific ID optimized for the lowest gain (a HIFO — highest-in-first-out — approach). Comparing all three side by side shows exactly how much the method you choose can change your tax outcome on the same sale.
A worked example
Marcus bought Apple stock in three lots over two years and now wants to sell 150 shares at $210/share:
Lot history
Lot 1 — Jan 2024100 shares @ $150
Lot 2 — Aug 2024100 shares @ $180
Lot 3 — Mar 2026100 shares @ $200
Selling 150 shares at $210: FIFO uses all of Lot 1 plus 50 shares of Lot 2, producing a basis of $24,000 and a taxable gain of $7,500 — all long-term. Specific ID optimized for lowest gain uses all of Lot 3 plus 50 shares of Lot 2, producing a basis of $29,000 and a gain of just $2,500 — but part of that gain is short-term since Lot 3 was purchased less than a year ago.
The $5,000 difference in taxable gain between the two methods is real — but so is the difference in tax character. A lower gain taxed partly at short-term (ordinary income) rates isn't automatically better than a higher gain taxed entirely at long-term capital gains rates. Run both scenarios through your actual tax bracket before deciding.
Why the method you choose isn't just about minimizing gain
It's tempting to always pick whichever method shows the smallest number on screen. But the smallest reported gain isn't always the smallest tax bill. Short-term capital gains (assets held one year or less) are taxed as ordinary income — up to 37% federally for top earners in 2026. Long-term capital gains (held over one year) are taxed at preferential rates of 0%, 15%, or 20% depending on income. A method that produces a larger gain but keeps it entirely long-term can result in less tax owed than a method that produces a smaller gain that's partly short-term. Always compare the after-tax outcome, not just the pre-tax gain shown.
Frequently asked questions
Can I actually choose which method to use, or does my broker decide?
You generally can choose, but the mechanics matter. FIFO applies automatically unless you specify otherwise. To use Specific Identification, you typically must instruct your broker which lot to sell at or before the trade — most brokerages let you select "specific lots" when placing a sell order. If you don't specify, FIFO is applied by default, even if you intended something else. Check with your specific broker for their exact process.
What if I don't know my exact purchase dates and prices?
Check your brokerage account — most platforms show your complete purchase history and often display cost basis automatically for "covered" securities (generally those purchased after 2011, when broker basis reporting became mandatory). For older holdings or transferred accounts, you may need to reconstruct purchase records from old trade confirmations, account statements, or your own records. Missing this information can force you into using a $0 cost basis in the worst case, so it's worth the effort to track down accurate records.
Does this work for ETFs and mutual funds too?
ETFs are traded like individual stocks and follow the same FIFO/Specific ID rules used in this calculator. Mutual funds are different — they also permit the Average Cost method, which blends your total cost across all shares into a single per-share basis. If you're calculating basis for mutual fund shares, check whether your fund company has been using average cost by default, since switching methods on existing shares has specific IRS rules.
How does this interact with tax-loss harvesting?
If you're selling at a loss for tax-loss harvesting purposes, Specific Identification becomes particularly valuable — it lets you precisely choose which losing lots to sell while retaining your winning positions. Use this calculator to compare which lots produce the largest deductible loss, then check the wash sale window before repurchasing. See our tax-loss harvesting guide for the complete strategy.
What happens if I sell more shares than fit in my listed lots?
This calculator will only account for the lots you've entered. If you're selling more shares than you've listed here, add additional lots using the "+ Add lot" button, or the calculation will be based on an incomplete purchase history. Always reconcile the total shares across all your lots against your actual current position before relying on any cost basis calculation for tax filing.