investing calculators

Cost Basis Calculator

Calculates your average cost per share across multiple stock purchases by dividing total dollars invested by total shares owned. Use it to determine your tax cost basis when selling shares bought at different prices.

About this calculator

Cost basis is the average price you effectively paid per share after accumulating a position through multiple purchases at different prices. The formula is: Cost Basis = totalCost / totalShares. Here, totalCost is the sum of all dollars you have invested in the stock (including any commissions added to the cost), and totalShares is the total number of shares you now hold. The result tells you the price per share you need to exceed when selling in order to recognize a gain. For example, if you invested $3,000 across two purchases and now hold 150 shares, your average cost basis is $3,000 / 150 = $20 per share. This average cost method is one of several IRS-accepted accounting methods — alongside FIFO and specific identification — for calculating capital gains when you sell a portion of your holdings.

How to use

Suppose you made two purchases: 100 shares at $18 ($1,800) and 80 shares at $22 ($1,760), for a combined total of 180 shares and $3,560 invested. Enter 180 in Total Shares Owned and $3,560 in Total Amount Invested. The calculator computes: $3,560 / 180 = $19.78 per share (rounded). When you later sell shares, the IRS considers your cost basis to be $19.78 per share under the average cost method. Any sale above this price results in a taxable capital gain; any sale below it produces a capital loss.

Frequently asked questions

How do I calculate the average cost basis for stocks I bought at different prices?

Add up the total dollar amount you paid for all purchases (your totalCost) and divide by the total number of shares you own (totalShares): Cost Basis = totalCost / totalShares. This gives you a single average price per share that blends all your purchase prices weighted by the number of shares bought at each price. You then use this figure to calculate capital gains or losses when you sell — subtract the cost basis per share from your sale price per share and multiply by the number of shares sold.

Why does knowing your cost basis matter for taxes?

Your cost basis determines how much of your proceeds from a sale are considered a taxable gain. The IRS requires you to report capital gains — sale price minus cost basis — on your tax return, and the rate you pay depends on how long you held the shares. If you do not accurately track your cost basis, you could end up overpaying taxes (if gains are overstated) or face penalties (if they are understated). Brokerage firms are now required to report cost basis to the IRS for most securities, but older holdings or transferred accounts may require manual calculation.

What is the difference between average cost basis and FIFO for stock sales?

Average cost basis uses a blended per-share price across all purchases, treating every share as if it cost the same. FIFO (First In, First Out) assumes you sell the oldest shares first, which may result in a higher taxable gain if early shares were purchased at a lower price. Specific identification lets you choose exactly which lot of shares you are selling, giving you the most tax flexibility. The average cost method is simple and widely used for mutual funds, while FIFO and specific identification are common for individual stock positions where tax optimization is important.