Investing guide
How to Use a Cost Basis Calculator
How a cost basis calculator works: blending share lots into an average basis, the basis of shares sold, and the realized gain after fees.
Quick answer
What this calculator tells you
A cost basis calculator figures out what you paid for shares — your basis — which determines the taxable gain when you sell. When you have bought the same security in more than one lot, the average-cost method blends them into a single basis per share, and the gain on any sale is measured against that average. Fees on the sale reduce the proceeds, and so the gain.
This guide uses the calculator's defaults — 100 shares with a $5,000 basis plus 50 new shares costing $4,000, then selling 60 shares for $5,000 with $20 in fees — to show how the average basis, the basis of the shares sold, and the realized gain are computed. Every figure matches the tool.
Inputs that matter most
Start with documents rather than memory whenever possible. For this calculation, pay particular attention to:
- existing shares and their total basis
- new shares and their cost
- shares sold and the proceeds
- sale fees
Use values that describe the same point in time. Mixing an old balance with a new rate or an annual cost with a monthly figure can make a polished result unreliable.
When this calculator is most useful
Use this tool early enough to improve the decision, but late enough that the inputs are grounded in real information. It is particularly useful when:
- You bought shares in multiple lots and need your cost basis.
- You want the realized gain or loss on a partial sale.
- You want the average basis per share after combining lots.
- You want the basis that carries over to your remaining shares.
It is less useful when the key facts are unknown, the options use different time periods, or the decision turns mainly on eligibility, contract language, taxes, or risks the calculator does not model. In those situations, gather the missing documents first and treat any early result as a rough range.
How the calculation works
The model turns the entered assumptions into a consistent comparison. It does not fill in facts that were not requested, predict changing markets, or reproduce an institution's underwriting system. That boundary matters: mathematical precision is not the same thing as certainty.
Blending lots into one average basis
The average-cost method pools every lot of a security into a single per-share basis. Using the defaults:
- Existing: 100 shares, $5,000 basis.
- New: 50 shares, $4,000 cost.
- Combined: 150 shares, $9,000 basis.
- Average basis per share: $9,000 / 150 = $60.
Once the lots are blended, every share you own is treated as having cost $60 — the average — regardless of what each lot actually cost. This is what makes the average-cost method simple: there is only one basis to track, not a separate figure per purchase. The key discipline is keeping the combined basis complete, because reinvested dividends and additional purchases all add to it, and a missed addition inflates your taxable gain later.
The gain on a sale, after fees
Selling some shares realizes a gain measured against the average basis, net of fees. On the defaults:
- Shares sold: 60 → basis 60 x $60 = $3,600.
- Gross proceeds: $5,000; less $20 fees → net $4,980.
- Realized gain: $4,980 - $3,600 = $1,380.
- Return on the basis sold: 38.33%.
The gain is the net proceeds minus the basis of the shares sold, so both the average basis and the fees matter. Fees reduce the proceeds and therefore the gain — the $20 here shaves the gain from $1,400 to $1,380 — which is why they belong in the calculation. The $1,380 is the figure that flows to your tax return as a capital gain, taxed at the long- or short-term rate depending on how long you held the shares.
What stays with the shares you keep
A partial sale splits the combined basis between the shares sold and those retained. On the defaults:
- Combined basis: $9,000.
- Basis of 60 shares sold: $3,600.
- Remaining 90 shares: $5,400 of basis, still $60 a share.
- The average basis is unchanged by the sale.
Under average cost, selling some shares does not change the per-share basis of the rest — the 90 shares you keep still carry $60 each, totaling $5,400. That remaining basis is what you will measure the next sale against, so tracking it matters as much as the gain you just realized. Keep the combined basis current across every purchase, dividend reinvestment, and corporate action, and the calculator will give you an accurate gain each time. For how that gain is taxed — the long- and short-term rates and the netting of gains and losses — IRS Topic 409 is the reference.
Worked example
See the method in context
Take the defaults: 100 shares with a $5,000 basis, plus 50 new shares bought for $4,000, then a sale of 60 shares for $5,000 with $20 in fees. The combined basis is $5,000 + $4,000 = $9,000 across 150 shares, so the average basis is $60 a share. The 60 shares sold carry $3,600 of basis (60 x $60).
Net proceeds are $5,000 - $20 = $4,980, so the realized gain is $4,980 - $3,600 = $1,380, a 38.33% return on the basis sold. The 90 remaining shares keep $5,400 of basis, still $60 a share. The whole calculation hinges on the $60 average: blend the lots correctly and both the gain on the sale and the basis of what you keep fall out of it.
After running the base case, change one important input at a time. A less favorable rate, cost, return, income, or holding period shows whether the conclusion is sturdy or depends on a narrow set of assumptions.
Build three scenarios, not one prediction
A single answer can create false confidence. Three deliberately different cases reveal both the likely range and the assumptions that deserve more investigation.
Conservative case
Include sale fees, which reduce the gain. On the defaults, the $20 fee lowers net proceeds to $4,980 and the realized gain to $1,380 — small here, but fees always shrink the taxable gain.
Expected case
Enter your existing shares and total basis, any new shares and their cost, the shares sold, the proceeds, and the sale fees. The calculator returns the average basis, the basis of the shares sold, the realized gain, and the remaining basis.
Improved case
Track your total basis carefully across every lot and reinvested dividend. An accurate combined basis — $9,000 here across 150 shares — is what keeps your reported gain correct and avoids overpaying tax.
Keep all unchanged inputs identical across the three runs. That discipline makes the comparison explainable and prevents several moving assumptions from hiding what actually changed the answer.
How to read the result
Look beyond the largest number on the screen. Review the breakdown, the time horizon, and any balance or cost that remains at the end of the comparison. Ask whether the result still fits cash flow and whether it changes under a conservative scenario.
Under the average-cost method, every share carries the same blended basis, so the gain on a sale depends on that average and on fees — which reduce the proceeds and therefore the taxable gain. The right next step is to track your total basis across all lots, and remember fees reduce the gain while the remaining shares keep the same average basis.
Common mistakes to avoid
- Forgetting a lot or reinvested dividends. Missing basis overstates your gain and your tax.
- Ignoring sale fees. They reduced the gain from $1,400 to $1,380 here.
- Mixing lot methods. Average cost blends all shares; do not switch mid-holding.
- Losing track of the remaining basis. The 90 held shares keep $5,400 of basis.
- Overlooking the holding period. Long- vs short-term changes the tax rate.
- Ignoring splits and spinoffs. Corporate actions adjust basis per share.
Decision checklist
Before acting, work through these questions. A “no” does not automatically reject the option; it identifies where more evidence or a wider safety margin is needed.
- 1Have I captured the basis of every lot, including reinvested dividends?
- 2Am I using the average-cost method consistently (not switching lot methods)?
- 3Did I subtract sale fees from the proceeds before computing the gain?
- 4Do I know the basis that carries to my remaining shares?
- 5Is the holding period long- or short-term for tax purposes?
Key terms in plain English
- Combined basis
- The total cost of all lots held. On the defaults, $5,000 existing + $4,000 new = $9,000 across 150 shares.
- Average basis per share
- Combined basis divided by total shares. On the defaults, $9,000 / 150 = $60.00 per share.
- Basis of shares sold
- The average basis times the shares sold. On the defaults, 60 x $60 = $3,600.
- Realized gain or loss
- Net proceeds (after fees) minus the basis of shares sold. On the defaults, $4,980 - $3,600 = $1,380.
Frequently asked questions
How do I calculate cost basis?
Add up what you paid across all lots, then divide by the total shares for the average basis per share. On the defaults, $5,000 for 100 shares plus $4,000 for 50 more is $9,000 across 150 shares — an average basis of $60 a share. Selling 60 shares uses $3,600 of basis (60 x $60).
What is the average-cost method?
It blends all your lots of a security into one average basis per share, so every share you own is treated as having the same cost. On the defaults, the $9,000 combined basis over 150 shares gives a $60 average. It is simpler than tracking individual lots and is common for mutual funds, though specific-lot methods can sometimes reduce taxes.
How is my realized gain calculated?
Net sale proceeds minus the basis of the shares sold. On the defaults, 60 shares sold for $5,000 with $20 in fees nets $4,980; subtract the $3,600 basis of those shares and the realized gain is $1,380 — a 38.33% return on that basis. The gain is what may be taxed; fees reduce it because they reduce the proceeds.
Do sale fees affect the gain?
Yes — they are subtracted from the proceeds, lowering the gain. On the defaults, the $20 fee turns $5,000 of gross proceeds into $4,980 net, so the realized gain is $1,380 rather than $1,400. Fees and commissions effectively reduce the taxable gain, which is why they belong in the calculation rather than being ignored.
What is the basis of my remaining shares?
Under the average-cost method, the remaining shares keep the same average basis. On the defaults, after selling 60 of 150 shares, 90 shares remain with $5,400 of basis — still $60 a share. The combined basis is split proportionally: $3,600 went with the shares sold, $5,400 stays with the shares held.
Why does cost basis matter for taxes?
Because your taxable gain is the proceeds minus the basis, so a higher, accurate basis means a lower reported gain and less tax. On the defaults, the $3,600 basis is what keeps the gain at $1,380 instead of being taxed on the full $4,980. Mis-tracking basis — especially forgetting reinvested dividends that add to it — leads to overpaying tax on gains you did not really have.
What does the cost basis calculator not account for?
Wash-sale adjustments, specific-lot or FIFO methods (it uses average cost), the short- versus long-term holding period that sets the tax rate, and corporate actions like splits or spinoffs that change basis. It computes the average-cost gain from your inputs. Use it for the basis and gain, and see IRS Topic 409 for how the gain is taxed.
Source and editorial note
For current background, review IRS: topic no. 409, capital gains and losses (basis and gain). Official rules and product documents control when they differ from this educational explanation.
Need help with unfamiliar language? Use the financial calculator glossary for definitions and links to related tools.
Prepared by Loan Lyze Editorial under our editorial policy. This article explains a calculator; it is not financial, tax, legal, insurance, or investment advice.