Stock Cost Basis Calculator

$
$
Average Cost Per Share$40.00
Total Shares40.00
Total Cost$1,600.00

The Stock Cost Basis Calculator blends several purchase lots into a single weighted-average cost per share. Add a row for each buy with its share count and price, and the tool sums the money invested, sums the shares, and divides one by the other. It is especially handy for seeing how averaging down on a falling position lowers your overall basis.

Formula

averageCost = Σ(shares × price) / Σshares

shares
Number of shares in a single purchase lot
price
Price paid per share in that lot
Σ
Sum taken across all lots

How it works

  1. Add one row per purchase lot, entering the number of shares bought and the price paid per share for each.
  2. The calculator multiplies shares by price for every lot to get total cost, adds up all the shares, and divides total cost by total shares.
  3. The weighted average means larger lots pull the basis toward their price, so a big purchase at a low price moves your average more than a small one.

Worked example

You buy 10 shares at $100, then average down with 30 shares at $20.

  1. Total cost = 10 × 100 + 30 × 20 = 1,000 + 600 = $1,600.
  2. Total shares = 10 + 30 = 40.
  3. Average cost = 1,600 ÷ 40 = $40.00.

40 shares at a weighted-average cost of $40.00, for $1,600 invested.

Frequently asked questions

Why is the average not just the midpoint of my prices?
Because it is weighted by share count, not lot count. A lot with more shares carries more weight, so buying many shares at a low price pulls the average down further than a small lot would.
How does averaging down work?
Averaging down means buying more shares after the price falls, which lowers your weighted-average cost. The break-even price you need to sell at to avoid a loss drops accordingly, though it also increases your exposure.
Should I include commissions and fees in cost basis?
For tax purposes, trading commissions and fees are generally added to your cost basis. You can fold them in by entering a slightly higher per-share price for the lot they belong to.