What is cost basis?
Cost basis is the original value of an asset for tax purposes — typically the purchase price plus any commissions, fees, or adjustments. When you sell an investment, the IRS calculates your capital gain or loss as the sale proceeds minus your cost basis. Getting this number right directly determines how much tax you owe.
Cost basis tracking becomes complicated when you buy shares of the same security at different prices over time, receive dividends that are automatically reinvested, or go through corporate actions like stock splits or mergers. Errors in cost basis reporting are one of the most common causes of overpaid capital gains tax — and occasionally of underreported gains that trigger IRS notices.
The cost basis formula
At its simplest, cost basis for a single purchase lot is:
Cost Basis = Purchase Price per Share × Number of Shares + Commissions/Fees
When you have multiple lots (shares bought at different times and prices), you choose an accounting method to determine which shares you're selling. FIFO (first in, first out) assumes you sell your oldest shares first. Specific identification lets you choose exactly which lot to sell. Average cost divides total dollars invested by total shares held.
Worked example
You hold VTI purchased in three separate lots and want to sell 40 shares. Here is how the three methods compare:
- Lot A (2019): 30 shares at $145.00 = $4,350 basis
- Lot B (2021): 20 shares at $210.00 = $4,200 basis
- Lot C (2023): 15 shares at $195.00 = $2,925 basis
Current price: $230. Selling 40 shares for $9,200 total proceeds.
- FIFO: Sell all 30 of Lot A + 10 from Lot B. Basis = $4,350 + $2,100 = $6,450. Gain = $9,200 − $6,450 = $2,750.
- Specific ID (highest-cost): Sell all 20 from Lot B + 20 from Lot C. Basis = $4,200 + $3,900 = $8,100. Gain = $9,200 − $8,100 = $1,100 — tax savings of $247.50 at a 15% long-term rate.
- Average cost: Total basis = $11,475 / 65 shares = $176.54/share × 40 = $7,062. Gain = $9,200 − $7,062 = $2,138.
When to use the cost basis calculator
Cost basis calculations matter any time you sell a taxable investment — the right accounting method can legally minimize your tax bill.
- Tax-loss harvesting: Identify your highest-cost lots to sell when a position is underwater, maximizing the realized loss you can use to offset gains elsewhere.
- Rebalancing a taxable portfolio: When trimming an overweight position, specific identification lets you sell the highest-cost lots first, minimizing the capital gain triggered.
- Inherited assets: Assets inherited at death receive a stepped-up basis equal to the fair market value on the date of death (IRC §1014), potentially eliminating years of embedded gains.
- Reporting IRS Form 8949: Every sale of a capital asset must be reported on Form 8949, which requires the cost basis, sale proceeds, and acquisition date for each lot sold.
Common mistakes
Cost basis errors are surprisingly common, especially for investors who have held accounts for years across multiple brokerages.
- Ignoring reinvested dividends: Every dividend reinvestment creates a new tax lot with its own basis and acquisition date. Failing to track these lots means you'll understate your basis and overpay taxes when you eventually sell.
- Forgetting the wash-sale rule: If you sell a security at a loss and repurchase the same or substantially identical security within 30 days before or after the sale, the IRS disallows the loss (IRC §1091). The disallowed loss is added to the basis of the replacement shares — it doesn't disappear.
- Assuming brokers track everything correctly: Brokers are required to report covered securities basis to the IRS, but they are not required to track assets transferred in from other institutions correctly. Always verify basis when moving accounts.
- Mixing up short-term and long-term lots: Gains on assets held one year or less are taxed as ordinary income (up to 37%); gains on assets held more than one year qualify for long-term capital gains rates (0%, 15%, or 20%). Selling the wrong lot can accidentally trigger a much higher tax rate.
Limitations of cost basis calculations
This calculator handles standard lot accounting, but real-world cost basis can get considerably more complex. Corporate actions — mergers, spin-offs, stock splits, rights offerings — require specific basis adjustments that vary by transaction type. For example, a stock split adjusts your per-share basis proportionally but does not change your total basis; a spin-off requires an allocation of the original basis between the parent and the spun-off company based on relative fair market values.
International investments introduce additional complexity: foreign stocks held through ADRs, currency-denominated positions, and PFIC (Passive Foreign Investment Company) holdings all have specialized cost basis rules. If your situation involves any of these, consult a CPA before filing — the penalties for PFIC reporting errors alone can exceed the tax owed.
Frequently asked questions
Which cost basis method saves the most tax?
Specific identification with highest-cost-first selection generally minimizes current-year capital gains, because you're selling the shares with the least embedded gain. However, the right answer depends on your tax situation: if you're in the 0% long-term capital gains bracket, it may be advantageous to realize gains now rather than defer them to a year when your income is higher.
What is the wash-sale rule?
The wash-sale rule (IRC §1091) disallows a capital loss if you buy a "substantially identical" security within the 30 days before or after the sale. Substantially identical generally means the same stock or ETF, but not necessarily a different fund tracking the same index. The disallowed loss adjusts the basis of the replacement security — it is deferred, not permanently lost.
Do I need to report cost basis on my tax return?
Yes. Every sale of a capital asset requires Form 8949, which lists each transaction with proceeds, basis, acquisition date, and sale date. Your broker's 1099-B reports this information for covered securities, but you are ultimately responsible for the accuracy of your return. Uncovered securities (purchased before 2011 for stocks) require you to track basis yourself.
What happens to cost basis when I receive a stock dividend or split?
In a stock split (e.g., 2-for-1), your number of shares doubles and your per-share basis halves — total basis is unchanged. Stock dividends work similarly. In a cash dividend that you reinvest, a new lot is created at the reinvestment price on the dividend payment date, and that amount is included in your taxable income for the year paid.
Related calculators
Cost basis intersects closely with these other calculations:
- DRIP Calculator — dividend reinvestment creates dozens of small tax lots; understand the long-run compounding impact and the tracking burden it creates.
- Margin Interest Calculator — margin interest paid on investment loans may be deductible as investment interest expense, affecting your overall tax picture.
This calculator is for educational purposes. Consult a CPA or tax attorney for advice on your specific situation.