Dollar-Cost Averaging Calculator

Paste the price you paid at each purchase and this calculator returns the three numbers that matter: how many shares or units you accumulated, what they cost you on average, and what the position is worth now. Because you buy a fixed dollar amount rather than a fixed number of shares, your average cost is the harmonic mean of the prices, not the ordinary average — which is why it always lands at or below the arithmetic mean price when you pay no commission. The per-period table shows exactly where each purchase moved your cost basis.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Amount invested each periodThe fixed cash amount debited every period, before any commission is taken out.500 $
Purchase frequencyHow often you bought; it labels the schedule and converts your list of prices into a span in years.Monthly
Price at each purchaseOne price per purchase, separated by commas or spaces, oldest first — no thousands separators.42, 38.5, 45.25, 51, 47.75, 44.1, 49.9, 55.4, 52.15, 58, 61.3, 57.8
Current price (optional)Leave at 0 to value the position at the last price in your list.0 $
Commission per purchaseA flat fee deducted from each contribution before shares are bought; use 0 for commission-free brokers.0 $

It returns

  • Average cost per share — Total cash committed divided by total shares held — your blended cost basis.
  • Total shares accumulated
  • Position value
  • Total cash invested
  • Gain or loss
  • Return on cash invested
  • Arithmetic average price — The plain mean of the prices you entered, for comparison with your average cost.
  • Average price minus average cost — Per-share gap between the mean price and what you actually paid.

The formula

Average cost=k=1nCk=1nCPk
Shares=k=1nCfPk
Value=SharesPnow

In plain text: Average cost = ΣC / Σ(C / P_k) = n / Σ(1 / P_k)

  • CCash invested each period (constant) ($)
  • P_kPrice paid at purchase k ($ per share)
  • nNumber of purchases (count)

When C is the same every period it cancels out of the ratio, leaving n ÷ Σ(1/P_k) — the harmonic mean of the prices. A flat commission f reduces the cash that buys shares to C − f each period but leaves the numerator at C, which raises the average cost above the harmonic mean.

Updated Category Contributions, SIPs & Portfolio Rebalancing Verified against published test cases Reading time 13 min

What dollar-cost averaging actually computes

Dollar-cost averaging means committing a fixed amount of money at fixed intervals instead of buying a fixed number of shares. That single choice changes the arithmetic of your cost basis. When you spend $500 a month, a month where the price is low buys you more shares than a month where the price is high, so the cheap purchases carry more weight in your final average than the expensive ones do.

The number this calculator returns as its headline is your average cost per share: every dollar you committed divided by every share you ended up holding. That figure is what your broker reports as cost basis, what your capital-gains tax is measured against when you sell, and the break-even price below which the position shows a paper loss.

Three things fall out of the same schedule and are reported alongside it. Total shares tells you the size of the position. Position value marks it to the current price. And the arithmetic average price — the plain mean of the prices you typed — is shown next to your average cost so you can see the gap between them. That gap is the entire mathematical content of dollar-cost averaging, and on a commission-free account it is never negative.

The calculator does not care what the asset is. A monthly index-fund purchase, a weekly bitcoin buy and a quarterly employee share-purchase plan all use the same formula. Only the price list changes.

Why your average cost is a harmonic mean

Start from the definition. At purchase k you spend C dollars at price Pk, so you receive C ÷ Pk shares. After n purchases you hold Σ(C ÷ Pk) shares and have spent n × C dollars. Divide the second by the first:

Average cost = nC / Σ(C/P_k)

The constant C cancels top and bottom, leaving n / Σ(1/P_k). That expression is the textbook definition of the harmonic mean — the reciprocal of the average of the reciprocals. It is the mean you use whenever the quantity you hold fixed sits in the denominator: average speed over equal distances, average price-to-earnings ratio across an index, and average cost when you fix the dollars rather than the units.

The harmonic mean of a set of positive numbers is never greater than their arithmetic mean, and the two are equal only when every number is identical. That inequality is the whole claim behind cost averaging: with a fixed dollar amount and no fees, your average cost lands at or below the average price you saw, and the more the prices scatter, the wider the gap.

Notice what the inequality does not say. It says nothing about whether you made money — your return depends on where the price finished, not on how your cost compares with the mean. It says nothing about whether averaging in beat investing everything on day one. And it collapses to nothing at all if prices never move. It is an arithmetic identity about weighting, not a forecast.

Commissions break the symmetry. If a flat fee f is deducted before the purchase, only Cf buys shares while the full C stays in your cost basis, so the average cost rises above the harmonic mean and can exceed the arithmetic mean price outright. The calculator reports that case explicitly rather than pretending the inequality still holds.

Worked example: $1,000 a month at $8.00, $10.00 and $12.50

You invest $1,000 into the same fund on three consecutive months. The price is $8.00, then $10.00, then $12.50. There is no commission.

  1. Shares from the first purchase. $1,000 ÷ $8.00 = 125.000 shares.
  2. Shares from the second. $1,000 ÷ $10.00 = 100.000 shares.
  3. Shares from the third. $1,000 ÷ $12.50 = 80.000 shares.
  4. Total shares. 125 + 100 + 80 = 305.000 shares.
  5. Total cash committed. 3 × $1,000 = $3,000.
  6. Average cost per share. $3,000 ÷ 305 = $9.8361.
  7. Arithmetic average price. ($8.00 + $10.00 + $12.50) ÷ 3 = $30.50 ÷ 3 = $10.1667.
  8. The gap. $10.1667 − $9.8361 = $0.3306 per share, about 3.3% of the mean price.
  9. Position value at $12.50. 305 × $12.50 = $3,812.50.
  10. Gain. $3,812.50 − $3,000 = $812.50, or 812.50 ÷ 3,000 = 27.08% on the cash invested.

Now run the alternative to see where the $0.33 came from. Suppose you had bought 100 shares each month instead of spending $1,000 each month. You would have paid 100 × ($8.00 + $10.00 + $12.50) = $3,050 for 300 shares, an average of exactly $10.1667 — the arithmetic mean. Fixing the dollars instead of the shares got you five more shares for $50 less. That is the mechanism, stated in full: nothing about market timing, only about which quantity you held constant.

Check the harmonic-mean formula directly as a cross-check: 3 ÷ (1/8 + 1/10 + 1/12.5) = 3 ÷ (0.125 + 0.100 + 0.080) = 3 ÷ 0.305 = $9.8361. It agrees, as it must.

How to read your average cost

Read the average cost first as a break-even line. If the current price is above it, the position is in profit before tax and any dividends; below it, at a paper loss. It is also the number a tax authority will start from when you sell, so it is worth reconciling against your broker's own cost-basis figure — brokers include commissions and, in many jurisdictions, adjust for reinvested distributions, which this calculator does not do unless you enter those purchases as extra rows.

Read the gap between average cost and average price second, and read it modestly. It is a second-order effect. For prices scattered within a few percent of each other the gap is a fraction of a percent; it only becomes material when the price roughly halves or doubles across your buying window. The reference table below quantifies that directly, and the pattern it shows is worth internalising: the gap grows with the square of the dispersion, not with the dispersion itself, which is why it is near-invisible in calm markets and conspicuous in violent ones.

Read the return figure third, and read it as a return on cash committed, not as an annualised rate. Because your money went in over time, only the first contribution was exposed for the whole period. A 27% gain on cash invested over three months is not a 27% quarterly return on capital, and comparing it with a fund's published performance is comparing two different things. When you need the annualised figure for a stream of contributions, use a money-weighted measure — the money-weighted return calculator — or, for a single lump with a start and end value, the CAGR calculator.

Finally, sanity-check the schedule table. If one row shows a share count wildly out of line with its neighbours, you almost certainly mistyped a price or let a thousands separator split a number in two.

How far below the mean price your cost lands

Two equal purchases: the first at $100, the second at the price shown. Average cost is the harmonic mean 2 × 100 × P ÷ (100 + P); the gap is the arithmetic mean minus that figure.
Second priceArithmetic mean priceYour average costGap per shareGap as % of mean
$50.00$75.00$66.67$8.3311.1%
$70.00$85.00$82.35$2.653.1%
$90.00$95.00$94.74$0.260.28%
$100.00$100.00$100.00$0.000.0%
$110.00$105.00$104.76$0.240.23%
$130.00$115.00$113.04$1.961.70%
$150.00$125.00$120.00$5.004.0%
$200.00$150.00$133.33$16.6711.1%

A 10% move either way buys you about a quarter of a percent. A halving or a doubling buys you eleven percent. The averaging benefit is real but small until volatility is large.

A lower average cost is not the same as a higher return

The harmonic-mean inequality guarantees that your cost basis lands at or below the mean of the prices you paid. It guarantees nothing about profit. A position bought entirely through falling prices will show a very attractive cost advantage and a large loss at the same time, because the cost advantage is measured against the prices you saw and the loss is measured against the price today. Read the two figures separately; they answer different questions.

Mistakes and assumptions that change the answer

  • Leaving out fees. Enter the commission if your broker charges one. Fees enter the cost basis but not the price list, so omitting them makes your average cost look lower than the one on your statement.
  • Ignoring reinvested dividends. Each reinvestment is a purchase at that day's price and belongs in the list. Leaving it out understates both your share count and your cost basis. The DRIP calculator handles the compounding version of this directly.
  • Assuming whole shares. The schedule allows fractional shares. If your broker rounds down and returns the remainder as cash, your real share count will be slightly lower and your average cost slightly different.
  • Using closing prices when you bought intraday. For volatile assets the execution price can sit well away from the close. Use fills from your trade confirmations, not chart values.
  • Mixing currencies. Every price must be in the same currency as the contribution. Convert first if you bought a foreign-listed line.
  • Typing thousands separators. A price entered as 1,250.00 is read as two prices, 1 and 250. Write 1250.
  • Treating the return figure as annualised. It is a simple return on total cash committed and takes no account of when each dollar went in.

Averaging in versus investing it all at once

Two quite different questions get filed under “dollar-cost averaging”, and confusing them causes most of the argument about it.

The first is the one this calculator answers: given that money arrives from a salary in monthly slices, what does the resulting cost basis look like? Here averaging is not a strategy at all, it is a description of your cash flow. You cannot invest a January salary in the previous June. The harmonic-mean result is simply the arithmetic of that constraint, and it happens to be mildly favourable.

The second is a genuine choice: you already hold a lump sum in cash — should you invest it now or spread it over the next twelve months? That is a risk question, not an arithmetic one. Spreading it keeps part of the money out of the market for part of the period, which cuts the damage from an immediate fall and equally cuts the gain from an immediate rise. Since equity markets have risen over most long historical windows, holding back tends to cost expected return in exchange for a narrower range of short-run outcomes. If that trade buys you the discipline to actually invest, it is worth paying for; if it is a way of postponing a decision, it is not.

Once the money is in, the maintenance question becomes allocation rather than entry price, which is the province of the portfolio rebalancing calculator. If you are budgeting the contribution itself, work backwards from the goal with the monthly investment needed calculator, or project a fixed monthly plan forward with the SIP calculator. And if you are averaging down deliberately into an existing losing position rather than on a schedule, the stock average down calculator frames it as a single blended-basis decision instead of a series. Over long horizons the fee you pay each year will move your outcome more than the entry price ever did — the expense ratio drag calculator puts a number on that.

Key terms

Cost basis
The total amount you are treated as having paid for a holding, including commissions. Gains and losses are measured from it, and it transfers to any shares you keep when you sell part of a position.
Harmonic mean
The reciprocal of the mean of the reciprocals: n ÷ Σ(1/x). It is the correct average whenever the fixed quantity sits in the denominator, and it is never larger than the arithmetic mean of the same positive numbers.
Fractional share
A holding of less than one whole share, created when a broker splits a fixed dollar purchase across the price. Most retail brokers now support them; some still round down and return the remainder as cash.
Mark to market
Valuing a holding at the current price rather than at what you paid. The Position value output is a mark-to-market figure.

Frequently asked questions

Why is my average cost lower than the average of the prices I paid?

Because a fixed dollar amount buys more shares when the price is low. Those cheaper purchases carry more weight in the total share count, so the blended cost is pulled toward the low prices. Mathematically your average cost is the harmonic mean of the prices, which is never above their arithmetic mean and is equal to it only when every price is the same. The effect is automatic — it needs no skill and no forecasting.

Can my average cost ever come out above the average price?

Yes, but only because of fees. If you enter a commission, the full contribution stays in your cost basis while only the amount net of the fee actually buys shares. That pushes the average cost above the harmonic mean and, if the fee is large enough relative to a set of similar prices, above the arithmetic mean too. The calculator flags this case explicitly rather than repeating the fee-free rule.

How many prices should I enter?

One per actual purchase, in the order they happened. If you have bought monthly for three years, that is 36 prices. There is no upper limit in the math; the schedule table lists the first 60 rows and the summary figures still use every entry. If you only have a handful of the prices, enter those and treat the result as an estimate — a partial list gives a cost basis for the part you entered, not for the whole position.

Does dollar-cost averaging beat investing a lump sum?

Usually not on expected return, and that is not what it is for. Spreading a lump sum over months keeps part of it in cash, and cash has historically returned less than equities over long windows, so the average outcome of averaging in is a little worse while the range of short-run outcomes is narrower. If your money arrives monthly from a salary, though, the comparison does not apply at all — you have no lump sum to invest, and averaging is simply what your cash flow does.

Should I include reinvested dividends in the price list?

Yes, if you want a cost basis that matches your broker's. Each dividend reinvestment is a purchase: add the reinvested amount as a contribution and the price on the reinvestment date to the list. Because this calculator assumes a single fixed contribution per period, the cleanest approach when reinvestments vary in size is to use it for the scheduled buys and track the reinvestments separately, then add the two share counts and the two cash totals.

Does this work for bitcoin and other crypto?

It works for any asset with a price. Enter the amount you buy each period and the price at each buy, in the same currency throughout. Crypto is where the averaging gap is most visible, because the gap grows with the square of the price dispersion: as the reference table shows, two buys ten percent apart move the cost basis by a quarter of a percent, while two buys a factor of two apart move it by eleven percent. Enter your exchange's trading fee as the commission if it is charged as a flat amount; if it is a percentage, reduce the contribution instead.

What number should I put in the current price field?

Leave it at zero unless you want to value the position at something other than your last purchase price. At zero the calculator uses the final price in your list, which is the right choice when your last buy was recent. Enter today's price when your list ends months ago, or enter a hypothetical price to see where the position would stand at that level — the break-even point is your average cost.

Is the return figure annualised?

No. It is the gain divided by all the cash you committed, which understates the annual rate because your later contributions were invested for a shorter time. To annualise a stream of dated contributions you need an internal-rate-of-return measure such as XIRR, which weights each cash flow by how long it was invested. Use the money-weighted return calculator for that; use this one for cost basis and position size.

Why does my broker show a different average cost?

Usually one of four reasons: the broker includes commissions and regulatory fees you have not entered; reinvested distributions have been added as extra purchases; a partial sale has been processed under a specific lot-identification method rather than average cost; or a corporate action such as a split or a return-of-capital distribution has adjusted the basis. Reconcile purchase by purchase against your trade confirmations rather than against the summary figure.

References

  • CFA Program Curriculum, Level I: Quantitative Methods (harmonic mean and cost averaging) — CFA Institute
  • Investment Analysis and Portfolio Management, 11th ed. — Cengage Learning
  • Investor.gov — Saving and InvestingU.S. Securities and Exchange Commission