Skip to content

Learn

Risk & Position Sizing

DCA average cost formula, with a worked example

If you buy the same amount of money on a schedule, your average cost per unit is not the average of the prices you paid. It is lower, by a predictable amount, and the reason is a piece of arithmetic worth understanding before it gets mistaken for an edge. This page gives the formula, works an example by hand, shows the spreadsheet and Python versions, and covers the fee adjustments that quietly change the answer.

Whether scheduled buying is a good idea is a different question — see averaging down vs dollar-cost averaging. The DCA calculator runs the arithmetic for a straight-line price path.

Before you start

You need a list of your purchases with, for each one:

  • The amount spent, in quote currency
  • The fill price
  • The fee, and whether it was charged in the quote currency or deducted from the units you received

If your venue shows only the units received, that is fine — units are what the formula ultimately needs.

The formula

For purchases of amount aᵢ at price pᵢ:

units bought on purchase i = aᵢ ÷ pᵢ
total units                = Σ (aᵢ ÷ pᵢ)
average cost               = Σ aᵢ ÷ Σ (aᵢ ÷ pᵢ)

When every amount is the same, the amounts cancel and this becomes:

average cost = n ÷ Σ (1 ÷ pᵢ)

That is the harmonic mean of the prices. Buying a fixed quantity each time instead gives the ordinary arithmetic mean. That single difference is the whole “DCA effect”.

Step 1: List the buys

Worked example — four buys of 250 each. The prices are made up for the illustration:

BuyAmountPriceUnits received
12501002.500
2250803.125
3250505.000
4250803.125
Total1,00013.750

Step 2: Divide total spent by total units

average cost = 1,000 ÷ 13.75 = 72.73

The arithmetic mean of the four prices is (100 + 80 + 50 + 80) ÷ 4 = 77.50.

The average cost sits 4.77 below it because the purchase at 50 bought twice as many units as the purchase at 100. Cheaper prices get more weight automatically — no decision was involved.

Had you bought a fixed 2.5 units each time instead, you would hold 10 units at an average of exactly 77.50. Fixed-quantity buying weights every price equally; fixed-amount buying weights them by how many units each one bought.

Step 3: See what drives the gap

The gap between arithmetic and harmonic means depends on how dispersed the prices are, not on whether they went up or down. Four illustrative paths, each with an arithmetic mean of 80:

Prices (250 per buy)Arithmetic meanAverage costGap
80, 80, 80, 8080.0080.000%
70, 90, 70, 9080.0078.751.6%
60, 100, 60, 10080.0075.006.3%
40, 120, 40, 12080.0060.0025.0%

Flat prices, no gap. The wider the swings, the larger it gets — a rough rule is that the gap is close to the variance of the prices divided by their mean.

This is also why the calculator’s straight-line model shows only a small effect: twelve buys evenly spaced from 100 to 120 give an average cost of 109.64 against an arithmetic mean of 110.00, a gap of about 0.3%. A choppier path between the same endpoints would show more.

None of this says anything about profit. Profit depends on where the price ends relative to your average cost, and the gap exists on paths that finish far below where they started. It is the same inequality behind volatility drag, seen from the buyer’s side.

Step 4: Handle unequal amounts

If the amounts vary, use the general form. Same four prices, amounts of 100, 200, 300 and 400:

units = 100/100 + 200/80 + 300/50 + 400/80
      = 1 + 2.5 + 6 + 5 = 14.5
average cost = 1,000 ÷ 14.5 = 68.97

This is a weighted harmonic mean. It is lower than the equal-amount figure here only because the larger amounts happened to fall at lower prices.

Step 5: Include fees

Fees reduce the units each purchase buys. Two cases, both using illustrative rates rather than any venue’s:

Percentage fee. At 0.1% per buy, each 250 buys 249.75 ÷ price units. Average cost rises from 72.73 to 72.80 — minor.

Fixed fee per purchase. A flat charge hurts small buys disproportionately. With a fee of 1 per purchase:

Size of each buyFee as share of buyAverage cost
2500.4%73.02
254.0%75.76

At the smaller size the fee eats most of the gap between 72.73 and 77.50. Splitting a fixed sum into more, smaller purchases increases the fee share, and venues also impose minimum order sizes that put a floor on how small a buy can be. The trading fee calculator shows the per-trade cost for your own rates, and fee drag over a year shows how it accumulates.

In a spreadsheet or Python

Amounts in column B, prices in column C, rows 2 to 5:

Equal amounts:    =HARMEAN(C2:C5)
Any amounts:      =SUM(B2:B5) / SUMPRODUCT(B2:B5 / C2:C5)
Arithmetic mean:  =AVERAGE(C2:C5)

In Python:

amounts = [250, 250, 250, 250]
prices = [100, 80, 50, 80]
units = sum(a / p for a, p in zip(amounts, prices))
print(sum(amounts) / units)  # 72.727...

If fees came out of the units received, replace the computed units with the units your venue actually credited.

How to tell it worked

  • Units × average cost equals total spent. 13.75 × 72.73 ≈ 1,000.
  • The average cost is at or below the arithmetic mean of the prices for equal amounts. Equal only if every price was the same. If yours is above, a purchase is missing or amounts were not equal.
  • It sits between the lowest and highest price paid.
  • It matches the venue’s figure once you use the units actually credited.

What usually goes wrong

  1. Averaging the prices. That gives the fixed-quantity answer, 77.50, not the fixed-amount one.
  2. Averaging averages. Combining two accounts by averaging their average costs is wrong unless they hold the same number of units. Add total spent and total units, then divide.
  3. Forgetting fees deducted in units. The ordered amount and the units credited differ, and the formula needs the units.
  4. Reading the gap as a return. The harmonic-mean effect appears on losing paths too. It tells you how the purchase rule weighted prices, not whether the purchases worked out.
  5. Comparing against the wrong alternative. The fair comparison is the same capital deployed at once, which the calculator’s last row shows — in a rising market that alternative ends ahead.

FAQ

What is the formula for DCA average cost?

Total amount spent divided by total units acquired, where the units from each purchase are the amount divided by that purchase’s price. With equal amounts this reduces to the harmonic mean of the prices: the number of purchases divided by the sum of the reciprocals of the prices.

Why is my DCA average cost lower than the average price?

Because a fixed amount buys more units when the price is low, so your holdings are weighted toward the cheaper purchases. The resulting harmonic mean is always at or below the arithmetic mean, and the gap widens as prices become more dispersed. It is a property of the purchase rule, not evidence of a profit.

How do fees change DCA average cost?

They reduce the units each purchase buys, which raises the average cost. A percentage fee has a small, proportional effect. A fixed fee per purchase weighs heavily on small buys and can erase most of the harmonic-mean effect when each purchase is small relative to the fee.

How do I calculate DCA average cost in Excel or Google Sheets?

With equal amounts, =HARMEAN(prices) gives the average cost directly. With varying amounts, divide the sum of the amounts by SUMPRODUCT(amounts / prices). If fees were deducted from units received, use the credited units instead.