All tools
Finance

Stock Cost Basis Calculator

Average cost basis across multiple buy lots, with an optional stock-split adjustment.

🔒 Runs entirely in your browser — nothing here is ever uploaded

Last reviewed 2026-08-31

About the Stock Cost Basis Calculator

Computes your average cost basis per share across multiple buy lots at different prices and quantities — optionally adjusting for a stock split — then computes realized gain or loss on a sale using that blended average cost, the 'average cost method' some brokerages and countries require in place of FIFO or specific-lot identification.

100% Free Runs in Your Browser No Sign-Up Required
How to use it
  1. Enter each buy lot's price per share and quantity.
  2. If a stock split happened, toggle it on and enter the split ratio.
  3. Enter the number of shares sold and the sale price per share.
  4. Read your average cost basis per share, realized gain/loss, and remaining cost basis.
Formula
Average cost per share = total cost of all lots ÷ total shares across all lots. Realized gain/loss = (shares sold × sale price) − (shares sold × average cost per share). A split of ratio r multiplies each lot's quantity by r and divides its price per share by r, leaving total cost unchanged.
Worked example

Lot 1: 10 shares at $100 ($1,000). Lot 2: 20 shares at $130 ($2,600). Total: 30 shares, $3,600 cost, $120/share average. Selling 15 shares at $150: $2,250 proceeds, $1,800 cost basis sold, $450 realized gain, leaving 15 shares with $1,800 remaining cost basis.

Interpreting your result

This models the average cost method only, not FIFO or specific-lot identification. Canada's CRA requires average cost (adjusted cost base) for identical publicly traded securities; the U.S. IRS defaults to FIFO but permits specific-lot identification if elected. Check which method actually applies to your country, account type, and brokerage before relying on this for a tax filing. Not tax or investment advice.

Recommendations
  • A stock split never changes your total cost basis — it only redistributes it across more (or fewer) shares.
  • If a split happened between some of your lots but not others, enter the earlier lots' price and quantity already split-adjusted yourself.
  • Average cost is a pooled method: it doesn't matter which literal shares you sell, only how many.
Frequently asked questions
No. Average cost blends every lot into one per-share price; FIFO instead assumes your oldest lot's shares are the ones sold, keeping each lot's original price distinct.
See the full methodology and sources for every finance calculator
Disclaimer

Illustrative estimate only, not financial or tax advice. Verify figures with a licensed adviser or your local tax authority.