Cost Basis Calculator

Last Updated: October 17, 2026

Calculate the cost basis of your stock or fund purchases, find your average cost per-share, and figure the capital gain or loss on a sale.

USD throughout. Purchase averages are arithmetic summaries; use the adjusted basis of the shares actually sold. This tool omits tax-lot elections, wash sales and other basis adjustments.

Optional settings

Blank means zero. Buying adds fees to basis; selling subtracts fees from proceeds.

Cost Basis Formula

The cost basis is the total amount you paid to acquire an investment, including any commissions or fees. The calculator uses one of three formulas depending on what you want to find.

For a single purchase:

Cost Basis = (Shares * Price Per Share) + Fees

For an average cost basis across multiple buys:

Average Cost Per Share = Total Cost Basis / Total Shares

For a capital gain or loss on a sale:

Gain or Loss = (Shares Sold * Sale Price - Sale Fees) - (Shares Sold * Cost Basis Per Share)
  • Cost Basis is the total dollar amount invested, fees included.
  • Shares is the number of shares bought or sold.
  • Price Per Share is the amount paid for each share at purchase.
  • Fees are any commissions or transaction charges added to your basis.
  • Total Shares is the sum of all shares across every purchase.
  • Cost Basis Per Share is the total basis divided by the shares you own.
  • Sale Price is the amount you receive per-share when you sell.
  • Gain or Loss is the sale proceeds minus the basis of the shares sold.

The single mode adds purchase fees and computes per-share cost. The multiple-purchase mode reports a weighted average purchase cost, including entered reinvestments. It does not automatically determine tax basis: U.S. average-basis treatment is limited to eligible mutual-fund or qualifying DRIP holdings under applicable election rules. The sale mode uses your supplied adjusted basis for the shares actually sold; the optional holding-period label is user-specified, not inferred.

Typical Fees and Holding Periods

Purchase fees generally increase cost basis; sale fees reduce proceeds. Tax treatment depends on asset type, adjustments and the holding periods of the lots sold.

ItemTypical RangeEffect on Basis
Online stock commissionBroker-specificAdded to basis
Mutual fund loadFund-specificAdded to basis
Reinvested dividendVariesAdds shares and basis
Holding PeriodDefinitionTax Treatment
Short termHeld 1 year or lessTaxed as ordinary income
Long termHeld more than 1 yearGenerally eligible for long-term rates; exceptions apply

Example Problems

Example 1. You buy 100 shares at $25 per-share and pay a $5 commission. The cost basis is (100 * 25) + 5 = $2,505. The cost basis per-share is 2,505 / 100 = $25.05.

Example 2. You own those 100 shares with a basis of $25.05 per-share and later sell all of them at $40 per-share with a $5 sale fee. Net proceeds are (100 * 40) - 5 = $3,995. The basis sold is 100 * 25.05 = $2,505. The capital gain is 3,995 - 2,505 = $1,490.

Frequently Asked Questions

What is cost basis? Cost basis is the total amount you paid to acquire an investment, including the purchase price and any commissions or fees. You subtract it from your sale proceeds to find your taxable capital gain or loss.

How do commissions and fees affect cost basis? Fees paid to buy a security are added to your cost basis, and fees paid to sell reduce your proceeds. Both raise your basis or lower your proceeds, which reduces the taxable gain on a sale.

How is average cost basis calculated for multiple purchases? For a weighted purchase-cost average, divide total entered purchase costs, including fees, by total entered shares. For tax reporting, use adjusted basis and shares still held before sale, with prior sales and adjustments accounted for. Average-basis treatment has eligibility and election rules; ordinary stock sales generally use identified lots or FIFO. Reinvested distributions acquire separate holding periods.

Cost Basis Calculator screenshot