How Do You Calculate Average Cost Basis After Buying at Different Prices?

Reviewed by Sang Lee | Published by AssetCalculus

Add up the total dollars you spent across all your purchases, then divide by the total number of shares you own. That single number is your average cost basis per share, and it’s what most brokers use to calculate your gain or loss when you sell.

For example, say you bought 10 shares at $30 and later bought 20 shares at $45. You’ve spent $300 + $900 = $1,200 for 30 shares total, so your average cost basis is $40 per share. It doesn’t matter that you never actually paid $40 for any individual share; the average is what counts for tax and performance purposes.

One caveat: if you sell only part of your position, some brokerages let you pick a different accounting method (like FIFO or specific-lot identification) instead of the average, which can change your reported gain. Check your brokerage statement to see which method was actually applied.

You can plug your own purchase history into our Average Cost Basis Calculator to get the exact number in seconds.

Tax Source and Recordkeeping Note

Average cost is useful for understanding an investment position, but tax-basis rules depend on the security and identification method. Review the IRS guidance on average basis and stock transactions, retain broker confirmations, and consult a qualified tax professional for your circumstances.

Step-by-Step Example With Three Purchases

Suppose you buy 10 shares at $20, 15 shares at $24, and 5 shares at $30. Your total cost before commissions is $200 + $360 + $150 = $710. You own 30 shares, so the weighted average cost is $710 ÷ 30 = $23.67 per share. You should not simply average $20, $24, and $30 because each purchase contains a different number of shares.

PurchaseSharesPriceCost
110$20$200
215$24$360
35$30$150
Total30—$710

How Fees Change the Calculation

Costs directly tied to acquiring an investment may affect tax basis. If the three purchases above included $6 in eligible acquisition costs, the simplified total basis would become $716, or $23.87 per share. Brokerage reporting and tax treatment can vary, so use the figures on your statements and tax forms.

What Happens When You Sell Only Some Shares?

Your taxable gain depends on the cost-basis method allowed for the asset and account, such as specific identification, FIFO, or an eligible average-basis method. Average cost is commonly discussed for mutual funds, but it is not automatically the correct method for every stock or security.

For the basic definition, read What Is Average Cost Basis?. For trading costs, see Stock Break-Even Price After Fees.

Official Resource

See IRS Publication 550 for federal guidance on investment income, sales, and basis. This article is educational and is not tax advice.

Frequently Asked Questions

Do reinvested dividends affect cost basis?

They generally create additional purchases and may increase the total basis. Keep records even when the cash never leaves the account.

Can I average the purchase prices?

Only when each purchase contains the same number of shares. Otherwise, calculate total cost divided by total shares.

Should I rely only on my own spreadsheet?

Use it as a check, but reconcile it with brokerage records and tax documents, especially after transfers, splits, mergers, or return-of-capital distributions.