Cost Basis Calculator

Calculate average cost basis across multiple purchase lots.
Enter price and shares for each lot to find your average cost per share and total investment.

Average Cost Basis

Cost basis is what you paid for an investment, including commissions. It is the number subtracted from your sale price to calculate your taxable gain or loss. Get it wrong and you either overpay taxes or underreport income, and neither is a good outcome with the IRS (Internal Revenue Service).

The formula for a single purchase:

Cost Basis = (Price per Share x Shares) + Commissions

For multiple purchases of the same security, the average cost method totals everything:

Average Cost per Share = Total Cost of All Lots / Total Shares

Read this before you use the answer on a tax return. Averaging is not a method you may choose for ordinary US stock. Under IRS Publication 550, the average basis method is available only for mutual fund shares and for shares held in a dividend reinvestment plan. For individual equities the choice is between FIFO and specific identification, and a broker’s LIFO or high-cost setting is specific identification with the lot picked for you.

So the average this page produces is the correct tax figure if you hold a mutual fund or a DRIP position. For a stock you bought in several lots it is still a genuinely useful number, but it is a portfolio number rather than a tax one: it is your break-even price, and it tells you whether the position as a whole is above water. The gain on any actual sale comes from the specific lots sold.

The methods that do apply to individual equities:

FIFO (First In, First Out) treats the shares you bought first as sold first. It is the default if you do not specify anything. In a market that has risen since you started buying, FIFO sells your cheapest shares first, which produces the largest gain and the highest tax bill.

Specific Identification lets you name exactly which lot to sell. It is the most tax-efficient approach when your lots differ in price or holding period, and it is what the “LIFO”, “highest cost” and “tax lot optimizer” options in a brokerage account are doing behind the scenes. The requirement is that you identify the lot at or before the time of sale and get written confirmation from the broker. Deciding in April which lot you meant to sell in November does not count.

Dividend reinvestment quietly multiplies the work. Every DRIP purchase creates a new lot with its own basis and its own holding period, so after fifteen years of automatic reinvestment a single position can hold hundreds of lots. Brokers have been required to report basis on covered shares since 2011, so recent records are usually clean. Anything bought before that, or transferred in from a closed brokerage, is where the gaps turn up, and reconstructing it from old statements is the usual remedy.

When you sell only part of a position, only the basis of the shares actually sold affects that year’s return. The rest keeps its own basis and holding period.


How we build and check this calculator

This calculator runs entirely in your browser, so the numbers you enter stay on your device. The math behind it is written by hand and tested against worked examples and standard references before the page goes live.

SuperGlobalCalculator is independently built and maintained. See how we build and verify our calculators.


Embed This Calculator

Copy the code below and paste it into your website or blog.
The calculator will work directly on your page.