Home › Investing & 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
| Parameter | Type | Unit | Required | Description |
|---|---|---|---|---|
amount_per_period | number | yes | Fixed currency amount invested at each price. Range: > 0, ≤ 1000000000000 | |
prices | number_list | yes | Unit price at each purchase, in time order (2–60 values, all greater than 0). |
Outputs
| Output | Type | Unit | Description |
|---|---|---|---|
periods | integer | Length of the price list. | |
total_invested | number | amount_per_period × periods. | |
units_bought | number | Σ amount_per_period / price_i. | |
average_cost_per_unit | number | total_invested / units_bought (harmonic mean of the prices). | |
simple_average_price | number | Arithmetic mean of the prices (average cost when buying a fixed number of units). | |
difference_percent | number | % | (average_cost_per_unit − simple_average_price) / simple_average_price × 100; never positive. |
current_value | number | units_bought × last price. | |
gain_loss_percent | number | % | (current_value − total_invested) / total_invested × 100. |
schedule | list | One 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
- API:
GET https://tttkmbb.com/api/v1/calculate/dca-average-cost(query parameters) orPOSTwith a JSON body{"inputs": {...}} - Schema: https://tttkmbb.com/api/v1/calculators/dca-average-cost · Markdown: https://tttkmbb.com/investing/dca-average-cost.md · JSON definition: https://tttkmbb.com/investing/dca-average-cost.json
- MCP: server
https://tttkmbb.com/mcp, toolrun_calculator with calculator_id="dca-average-cost" - OpenAPI operationId:
calculate_dca_average_cost - Freshness:
static. Authentication: none. Rate limit: fair use (see rate limits).
Sources
- Wikipedia – Dollar cost averaging (reference)
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
- Compound Interest Calculator — Project a plan with a constant return instead of listed prices.
- Stock Profit Calculator — Profit from selling the accumulated units.
- CAGR Calculator — Annualized return between two values.