Sub topic 5
Calculating Average Cost per Share
This chapter assumes you know what a share, stock, exchange-traded fund (ETF), and index fund are. It also assumes you can divide and calculate a basic average.
When you buy fractional shares on a regular schedule, each purchase may happen at a different price. Your average cost per share tells you how much each share cost on average across all purchases.
The weighted-average formula
Use this formula:
Average cost per share = total dollars invested ÷ total shares purchased
This is a weighted average because each purchase contributes its actual number of shares. A purchase at a lower price buys more shares than the same dollar contribution at a higher price.
Suppose you invest $100 at each of these prices:
| Purchase | Price per share | Dollars invested | Shares purchased |
|---|---|---|---|
| 1 | $50 | $100 | 2.00 |
| 2 | $40 | $100 | 2.50 |
| 3 | $25 | $100 | 4.00 |
| 4 | $40 | $100 | 2.50 |
| 5 | $50 | $100 | 2.00 |
You invested $500 and purchased 13 shares.
Average cost per share = $500 ÷ 13 = $38.46
The simple average of the five prices is $41. That is not your actual average cost because you did not buy the same number of shares at every price. You bought more shares when the price was $25 and fewer shares when it was $50.
prices = [50, 40, 25, 40, 50]
contribution = 100
shares = [contribution / price for price in prices]
total_shares = sum(shares)
total_invested = contribution * len(prices)
average_cost = total_invested / total_shares
print(round(total_shares, 4), round(average_cost, 2))
# 13.0 38.46Why the calculation works
Each purchase has its own cost and share quantity. Add all purchase costs together, then add all shares together. Dividing those totals gives one cost figure for the whole position.
A lower average cost does not mean the investment is profitable. Profit or loss depends on the current market price compared with your average cost, along with fees and other factors. If the current price is $45, the position has an unrealized gain before costs. If the current price is $30, it has an unrealized loss.
Include fees and rounding correctly
If your broker charges an investing fee, include that fee in total dollars invested when calculating your true cost. Keep trading fees separate if you want to compare the investment performance of the security itself.
Dollar-based orders also may be rounded. For example, a broker might allow six decimal places for fractional shares:
from decimal import Decimal, ROUND_DOWN
amount = Decimal("50.00")
price = Decimal("300.00")
shares = (amount / price).quantize(
Decimal("0.000001"),
rounding=ROUND_DOWN
)
print(shares)
# 0.166666The broker's records are authoritative for your actual share quantity and cost basis. Cost basis is the amount used to track what you paid for an investment, usually for tax reporting.
Exercise
You invest $200 when a fund costs $20 per share and another $200 when it costs $40. What is your average cost per share?
Show answer
You buy 10 shares at $20 and 5 shares at $40. The total is $400 divided by 15 shares, so the average cost is $26.67 per share.