Average cost per share calculator

Enter your buys and sells in the order they happened (shares, price and any fees): the calculator gives your average cost per share and the realized gain or loss of each sale. Add today's price to see the gain or loss on what you still hold.

Free, no sign-up

Your buys and sells

In the order they happened: a buy after a sell averages with what was left.

  1. 1.
    $
    $
    Amount$4,200.00
  2. 2.
    $
    $
    Amount$2,325.00
  3. 3.
    $
    $
    Amount$3,184.00
Price of each buy vs average cost
Trade 1
$420.00
Trade 2
$465.00
Trade 3
$398.00

Average cost: $422.1304

Average cost

$422.1304

per share

Shares held
23
Cost of the position
$9,709.00

A plain average of the prices would give $427.67: it ignores how many shares each purchase bought.

$
Optional: to see the position's gain or loss.

Want the average cost of every holding without redoing this math?

In Allocta you log each buy and sell once, and the average cost, cost basis and gain or loss of every holding update on their own.

Start free

Calculated with the average cost method: fees are added to the cost and a sale does not change the average. Does not include taxes on gains and is not investment advice.

How is average cost per share calculated?

It's a weighted average: bigger purchases count more. Three steps:

  1. The cost of each purchase is shares × price, plus any fees or commissions.
  2. Add up the costs and add up the shares.
  3. Divide the total cost by the total shares.

In the example filled in above, 10 shares at $420, 5 at $465 and 8 at $398 cost $9,709 for 23 shares: an average cost of about $422.13 per share.

Why not just average the prices?

Because a plain average ignores how many shares each purchase bought. With the same three purchases, ($420 + $465 + $398) ÷ 3 = $427.67, about $5.54 more per share than your real average cost of $422.13: the $465 purchase was the smallest, but a plain average gives it the same weight as the others.

Does selling change my average cost?

Selling itself doesn't: the shares leave at your current average cost, the difference from the sale price is your realized gain or loss, and the shares you keep stay at the same average.

But selling changes how many shares you hold, so the order matters. Say you buy 100 shares at $20, sell 80 at $25, then buy 100 more at $30. After the sale you hold 20 shares that cost $400. The new buy costs $3,000, so your average cost becomes $3,400 ÷ 120 = $28.33.

If both buys had come before the sale, your average would be ($2,000 + $3,000) ÷ 200 = $25.00, and the sale wouldn't change it. Same trades, same 120 shares at the end, different average costs. That's why the calculator works through the rows in order.

Same buys and sell, different order (120 shares at the end)

Sold, then bought again

Order
100 at $20, sell 80, 100 at $30
Average cost
$28.33

Bought everything, then sold

Order
100 at $20, 100 at $30, sell 80
Average cost
$25.00

Is this the cost basis my broker reports?

Not always. This calculator gives your average cost per share, which is the right number to judge a position. For taxes, the IRS lets you use the average cost method for mutual fund shares, while for individual stocks and most ETFs brokers report cost basis lot by lot (first in, first out, unless you pick specific lots). Check the cost basis on your broker's statements and Form 1099-B before filing.

Can my average cost update on its own?

Yes. In Allocta every purchase you log updates the holding's average cost, splits included. And when you invest each month, it shows how much goes into each holding to keep your portfolio on target. Because it only uses new money, there's nothing to sell, so no capital gains tax on a sale in a taxable account.

FAQ

Do fees count in the average cost?

Yes. Commissions and fees you paid to buy are part of what the shares cost you, so the calculator has a fees field for each purchase. Most US brokers charge no commission on stocks and ETFs, so you can leave it empty.

What happens to my average cost after a stock split?

Your total cost stays the same and your share count changes. In a 2-for-1 split you get twice the shares and your average cost per share is cut in half.

Can I enter fractional shares?

Yes. Share amounts accept decimals, so it works for fractional shares and crypto too.

Calculate your next contribution in Allocta

Your first 7 days are on the Plus plan, with everything unlocked.

Start free

Related posts