Capital gains
Cost basis calculator
Which shares you sell decides your gain. Pick the method and see the difference.
When you have bought the same stock at different prices and sell only some of it, the basis depends on which lots you are treated as selling. The default is FIFO, oldest first. But you can specifically identify lots, and funds often use average cost. The method changes your basis, your gain, and how much is long-term. Enter your lots and compare.
Your lots (in purchase order)
Enter your lots and the sale.
Worked example, two lots of 100 shares, selling 100 at $30
You bought 100 shares at $10 over a year ago (long-term) and another 100 at $20 recently (short-term). You sell 100 at $30, $3,000 of proceeds. The basis, and the gain, depend entirely on the method:
| Method | Basis | Gain | Short-term | Long-term |
|---|---|---|---|---|
| FIFO (oldest first) | $1,000 | $2,000 | $0 | $2,000 |
| LIFO (newest first) | $2,000 | $1,000 | $1,000 | $0 |
| Average cost | $1,500 | $1,500 | $1,500 | $0 |
FIFO reports a $2,000 gain, all long-term, more gain, but at the lower rate. LIFO reports $1,000, all short-term at ordinary rates. Same sale, $1,000 apart in reported gain and taxed differently. Take the split into the capital gains calculator for the tax.
Questions
What is cost basis?
What you paid for an investment, including commissions and fees, the number subtracted from your sale proceeds to find the gain. For reinvested dividends and shares bought over time, basis is tracked lot by lot.
Which method should I use?
FIFO is the default and often maximizes long-term treatment. Specific identification gives the most control, you can sell your highest-basis lots to minimize the gain, or your loss lots to harvest losses. But you must designate the lots at the time of sale. Mutual funds commonly use average cost.
Can I change methods later?
Once you use average cost for a fund, you generally must keep using it for shares already held. For individual stocks you can specifically identify lots at each sale. The rules differ by account and security, so confirm with your broker's records, which the IRS also receives on Form 1099-B.
How does the holding period work per lot?
Each lot has its own clock, running from the day after purchase. Selling across lots can produce both short and long-term gain on a single sale, the calculator splits them, because they are taxed at different rates.
Related tools
- Capital gains tax calculator the tax on the gain
- Crypto tax calculator basis for coins and tokens
- Dividend tax calculator reinvested dividends add basis
A basis and gain estimate. Your broker's 1099-B is the record the IRS matches against. Not tax advice.