Prepared by StockDCA · Revised September 8, 2026 · Examples use invented prices, not market forecasts.
To calculate a weighted average purchase cost, you need two numbers for each transaction: the price per share and the number of shares purchased. Add the purchase costs, add the shares, then divide. This page works through unequal purchases, fixed-dollar contributions, fractional shares and fees so you can reconcile the result with your records.
The calculation works for purchases of one security in one currency. A dollar-cost averaging schedule is one way to make those purchases, but the formula also works when the amounts or dates differ. It does not tell you whether to buy more or predict what the investment will be worth.
A complete example with unequal share quantities
Suppose your records show three purchases. Keep each transaction separate rather than averaging the three quoted prices.
| Purchase | Price per share | Shares | Price × shares |
|---|---|---|---|
| 1 | $100 | 2.5 | $250 |
| 2 | $80 | 5 | $400 |
| 3 | $120 | 1.25 | $150 |
| Total | — | 8.75 | $800 |
Weighted average = $800 ÷ 8.75 = $91.428571… per share, displayed as $91.43. The $80 purchase has the most influence because it accounts for five of the 8.75 shares.
The simple mean of $100, $80 and $120 is $100. That would be correct only if you had bought the same number of shares at each price. Here, it overstates what you paid per share. Averaging transaction prices without their quantities loses the information that makes the calculation useful.
Load this exact example in the calculator
With the optional current price set to $100, the same example produces a market value of $875 and an unrealized gain of $75. The percentage is $75 ÷ $800 × 100 = 9.375%, displayed as 9.38%. This is a simple price-based result, not an annualized return or a total return including dividends.
When you invested a fixed dollar amount
If you know the cash contribution and execution price but not the shares, divide cash by price first. For example, $100 invested at $16 buys 6.25 shares when fractional shares are available and there are no transaction fees.
| Period | Cash invested | Execution price | Shares to enter |
|---|---|---|---|
| 1 | $100 | $20 | 5 |
| 2 | $100 | $25 | 4 |
| 3 | $100 | $16 | 6.25 |
| 4 | $100 | $20 | 5 |
The total is $400 for 20.25 shares, or $19.753086… per share. In the calculator, enter the price and shares from each row. Do not enter $100 as the share quantity. Open the fixed-dollar example.
If your broker purchases only whole shares, some cash may remain uninvested. Use the actual shares and executed purchase cost from the confirmation, not the theoretical cash contribution. Pending transfers and unused cash are not purchased shares.
Fees change the cost, not the share count
The calculator has no separate fee field. Its displayed total is exactly the sum of entered price × shares. For a personal cost estimate that includes a purchase commission, you can calculate a fee-adjusted unit price before entering the row.
Adjusted unit price = (execution price × shares + purchase fee) ÷ shares. Buying 20 shares at $50 with a $5 purchase fee gives ($1,000 + $5) ÷ 20 = $50.25. Entering $50.25 and 20 shares represents a $1,005 purchase cost. Keep the actual execution price and fee separately in your records. Do not add the full $5 to the per-share price; that would incorrectly produce $1,100.
This adjustment is a way to model your entered purchase cost, not a determination of tax basis. The tool does not automatically handle distributions, withholding, wash-sale adjustments, currency conversion or other account-specific events.
Keep precision until the final display
Use the precision on your trade confirmation where possible. Rounding 6.25 shares to six loses a quarter share; rounding every calculated contribution before adding them can accumulate a difference. StockDCA keeps numeric precision through the calculation and formats dollar results to two decimals. Displayed share totals may show fewer decimals than the values used internally.
For the weighted example, multiplying the displayed $91.43 by 8.75 gives $800.0125. That tiny difference is caused by displaying a rounded average, not by a different purchase total. Reconcile total cost and shares first, then the displayed average.
A checklist when your broker shows a different number
- Same position? Do not mix tickers, share classes or currencies in one calculation.
- Complete history? Check for missed purchases, reinvestments and transfers. A transfer may require a basis from prior records rather than the market price on transfer day.
- Same units? A stock split changes shares and per-share figures. Do not combine pre-split and post-split records without consistent adjustments.
- Same definition? A broker's tax-lot basis after sales can differ from a weighted average of all purchases. This calculator does not reconstruct tax lots.
- Complete inputs? A completely blank row is ignored. A row with only one field filled blocks the estimate until you complete or remove it.
For a sale example showing why cost methods matter, use the calculator guide's average-cost versus FIFO illustration. For the investing schedule itself, read the DCA introduction.
Questions about this calculation
Can I average the prices without entering shares?
Only when every purchase contains the same number of shares. Otherwise, calculate each purchase cost and divide their sum by the total shares.
I have contribution amounts, not share quantities. What should I enter?
Use the executed share quantity from your broker. For a no-fee fractional-share example, divide the invested amount by its execution price, then enter that price and quantity.
Does the calculator project future monthly investments?
No. It summarizes the purchases you enter. It has no investment-frequency, annual-return or investment-term inputs and does not forecast future portfolio value.
Why does the rounded average not multiply back to the exact total?
The average is displayed to two decimal places. Reconcile with the full purchase costs and share quantities rather than multiplying a rounded displayed average.
Method and sources
All numerical examples on this page are hypothetical and are checked against the calculator's weighted-average arithmetic. For the distinction between a contribution schedule and a cost calculation, see Investor.gov's DCA definition. For the tax-lot distinction, see the IRS cost-basis FAQ. These sources do not endorse StockDCA.
Educational estimates only, not investment or tax advice. Actual records, costs and applicable rules take precedence over this illustrative calculator.