Home›Taxes & portfolio

Average cost of your stocks

Enter your buys and sells and see the average cost, the total cost basis, the gain already realized on sales and today’s unrealized gain or loss. Find out how many shares to buy at the current price to bring the average cost down to your target.

Educational simulation. Not investment advice. Results are estimates based on the data you enter and do not replace advice from a qualified professional.

Reviewed on Oct 31, 2026

In date order. Fees: commission and exchange fees for each trade. Example values for a fictional stock.

Your trades
Today

Fees on purchases are part of the cost; sales do not change the average cost.

Your inputs stay only on this browser and are not sent anywhere. Untick to delete them.

—Average cost
—

Price of each trade and the average cost

Dots: price of each purchase and sale. Line: average cost after each trade. Dashed: current price.

Tap the chart to see the values.

Buying more to lower the average cost

Resulting average cost by the quantity bought today at the current price.

Tap the chart to see the values.

Trades and average cost

The summary lists your inputs, results, formulas, assumptions and sources. The full report also includes the charts and interpretations, in color. In the print dialog, choose Save as PDF.

Method, assumptions and sources

Formulas

Average cost = total paid on purchases, including fees ÷ shares held
Sale: total cost −= quantity sold × average cost; gain = (quantity × price − fees) − quantity × average cost
Shares to reach target = (total cost − target × quantity) ÷ (target − price), if the price is below the target

Assumptions and limits

  • Educational simulation. Sales do not change the average cost: they reduce the quantity and the cost at the average. Tax rules on cost basis differ by country and account type.
  • Check the result against your broker statements. Splits, reverse splits and stock dividends require adjustments. Lowering the average cost is not, by itself, a reason to buy more.

Official sources and references

Frequently asked questions

What is average cost?

The average price you paid for each share you still hold, including commissions and fees: total paid on purchases divided by the number of shares. It tells you whether a position is at a gain or a loss.

How do I read the default example?

After five purchases and one sale, you hold 155 shares at an average cost of $55.51, a total cost basis of $8,603.48. At the $50.20 price the position has an unrealized loss of $822.48, and the July sale already realized a gain of $28.48.

Does selling change my average cost?

No. A sale reduces the quantity and the total cost in the same proportion, so the average cost of what you keep stays the same. The gain or loss on the sale is (quantity × sale price − fees) − quantity × average cost.

Should fees be included?

Yes. Commissions and fees on purchases are part of what you paid, so they raise the average cost. Fees on sales reduce the proceeds and therefore the gain.

How many shares do I need to buy to lower my average cost?

The calculator solves it for you: with the price at $50.20 and a $52 target, you would need 302 more shares, about $15,160. Each extra share lowers the average a little less.

Is average cost the method my tax authority uses?

Not always. Some countries and account types use average cost, others first-in, first-out (FIFO) or specific lot identification. Check the rule that applies to you or ask a tax professional.

What are the limits of this calculator?

It does not adjust for stock splits, reverse splits, spin-offs or stock dividends, and it assumes the trades are in date order. Always reconcile the result with your broker statements.

How to calculate the average cost of a stock

The average cost (or average cost basis) is what each share you own cost you on average, including commissions and fees. It is the reference for knowing whether a position is at a gain or a loss, and in many tax systems it is the basis for computing the taxable gain when you sell.

The formula

Average cost = total paid on purchases, including fees ÷ number of shares held

Example

DateTradeQuantityPriceAverage cost after
JanBuy50$65.00$65.02
MarBuy25$57.80$62.63
MayBuy40$52.80$59.22
JulSell30$60.20$59.22 (unchanged)

Each purchase blends into the average; the sale does not change it. The gain on the July sale is 30 × $60.20 − $1 fee − 30 × $59.22, about $28.48.

Selling does not change the average

When you sell, the quantity and the total cost fall in proportion, so the average cost of the shares you keep stays the same. That is why a partial sale never “improves” your average cost.

Lowering the average cost

Buying more when the price is below your average cost pulls it down, but each additional share lowers it a little less. Lowering the average is not a reason to buy on its own: ask whether the investment is still sound, or you may just be adding to a mistake.

Practical tips

  • Keep all broker confirmations: they show quantity, price and fees for each trade.
  • Stock splits, reverse splits and stock dividends change the number of shares and require an adjustment.
  • Tax rules differ by country: some use average cost, others first-in, first-out or specific lots. Check the method that applies to your account.