HomeInvesting & Real Estate › Dollar-Cost Averaging Calculator

Dollar-Cost Averaging Calculator

Simulates investing a fixed amount at each of a list of prices, and reports the units bought, the average cost per unit (harmonic mean of prices), the simple average price, the current value at the last price and the gain or loss.

When to use

You invest the same amount every period and want your true average cost, or want to see how a fixed-amount plan compares with the average price.

Do not use when: You buy a fixed number of units each time (the average cost is then the simple average price) or want a projection with a growth rate (use compound-interest). Informational only; not financial advice.

Formula

units = Σ_i amount_per_period / prices[i]; average_cost_per_unit = (n × amount_per_period) / units; simple_average_price = Σ prices[i] / n; current_value = units × prices[n]

Because a fixed amount buys more units when prices are low, the average cost is the harmonic mean of the prices, which is always at or below the arithmetic mean. Fees, taxes and dividends are ignored. Informational mathematics only; not financial advice.

Inputs

ParameterTypeUnitRequiredDescription
amount_per_periodnumberyesFixed currency amount invested at each price. Range: > 0, ≤ 1000000000000
pricesnumber_listyesUnit price at each purchase, in time order (2–60 values, all greater than 0).

Outputs

OutputTypeUnitDescription
periodsintegerLength of the price list.
total_investednumberamount_per_period × periods.
units_boughtnumberΣ amount_per_period / price_i.
average_cost_per_unitnumbertotal_invested / units_bought (harmonic mean of the prices).
simple_average_pricenumberArithmetic mean of the prices (average cost when buying a fixed number of units).
difference_percentnumber%(average_cost_per_unit − simple_average_price) / simple_average_price × 100; never positive.
current_valuenumberunits_bought × last price.
gain_loss_percentnumber%(current_value − total_invested) / total_invested × 100.
schedulelistOne row per purchase: period, price, units.

Example

100 per period at 10, 8, 12.5: {"amount_per_period":100,"prices":[10,8,12.5]}{"periods":3,"total_invested":300,"units_bought":30.5,"average_cost_per_unit":9.8361,"simple_average_price":10.1667,"difference_percent":-3.25,"current_value":381.25,"gain_loss_percent":27.08}

500 per month at 50, 45, 40, 48, 55: {"amount_per_period":500,"prices":[50,45,40,48,55]}{"total_invested":2500,"units_bought":53.1187,"average_cost_per_unit":47.0644,"simple_average_price":47.6,"difference_percent":-1.13,"current_value":2921.53,"gain_loss_percent":16.86}

GET https://tttkmbb.com/api/v1/calculate/dca-average-cost?amount_per_period=100&prices=10%2C8%2C12.5

Machine access

Sources

FAQ

Why is the average cost below the average price?

Each fixed amount buys more units at low prices than at high ones, so low prices get more weight; mathematically the average cost is the harmonic mean, which is ≤ the arithmetic mean unless all prices are equal.

Does dollar-cost averaging beat investing a lump sum?

Not on average in rising markets, where investing earlier tends to win; it reduces the regret and timing risk of a single purchase, which is a behavioural rather than a return advantage.

Related calculators