DCA Calculator
Simulate dollar-cost averaging investment returns with periodic contributions.
About this tool
Dollar-cost averaging (DCA) is an investment strategy where you contribute a fixed amount of money at regular intervals—such as monthly or quarterly—regardless of the asset's price. Instead of trying to time the market perfectly, DCA reduces the impact of market volatility by spreading your purchases across different price points. When prices are high, your fixed contribution buys fewer shares; when prices are low, it buys more. Over time, this approach naturally lowers your average cost per share and can help smooth out the emotional stress of market fluctuations.
This calculator lets you simulate how DCA would have performed historically or project future returns based on your expected investment amount, contribution frequency, and assumed annual growth rate. Enter your initial lump sum (if any), the regular contribution amount, how long you plan to invest, and your projected annual return rate. The tool then calculates your total contributions, final portfolio value, and overall gain or loss, displaying the results in a clear summary and interactive chart. You can also adjust the growth rate to test different market scenarios—bull markets, bear markets, or moderate growth—to understand how DCA performs under various conditions.
DCA is particularly popular among individual investors who lack the capital to invest a large sum upfront or who prefer to avoid the anxiety of making one big bet on market timing. Young professionals saving for retirement, parents setting aside education funds, and anyone with a regular income can benefit from its disciplined, emotionally neutral approach. While DCA does not guarantee profits or protect against losses in declining markets, it historically has proved a reliable method for building wealth over decades, especially when combined with diversified, low-cost index funds or ETFs.
Frequently Asked Questions
Code Implementation
from dataclasses import dataclass
from typing import List
@dataclass
class DCAResult:
period: int
contribution: float
balance: float
total_invested: float
gain_loss: float
gain_loss_pct: float
def dca_simulator(
initial: float,
periodic: float,
annual_return: float,
years: float,
frequency: int = 12 # per year
) -> List[DCAResult]:
"""
Simulate dollar-cost averaging investment.
Parameters:
initial - lump-sum initial investment
periodic - periodic contribution amount
annual_return - expected annual return rate (e.g. 0.07 for 7%)
years - investment duration in years
frequency - contributions per year (12=monthly, 52=weekly)
"""
periodic_rate = annual_return / frequency
periods = int(years * frequency)
balance = initial
total_invested = initial
results = []
for t in range(1, periods + 1):
balance = balance * (1 + periodic_rate) + periodic
total_invested += periodic
gain = balance - total_invested
results.append(DCAResult(
period=t,
contribution=periodic,
balance=balance,
total_invested=total_invested,
gain_loss=gain,
gain_loss_pct=gain / total_invested * 100
))
return results
# Example: $5,000 initial + $500/month at 7% for 30 years
results = dca_simulator(5000, 500, 0.07, 30, 12)
final = results[-1]
print(f"Final balance: ${final.balance:>12,.2f}")
print(f"Total invested: ${final.total_invested:>12,.2f}")
print(f"Total gain: ${final.gain_loss:>12,.2f}")
print(f"Return on invest: {final.gain_loss_pct:>10.1f}%")
# Yearly summary
print("\nYear | Balance | Invested | Gain/Loss")
for i in range(11, len(results) + 1, 12):
r = results[i - 1]
yr = i // 12
print(f"{yr:4d} | ${r.balance:>10,.2f} | ${r.total_invested:>10,.2f} | ${r.gain_loss:>10,.2f}")
Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.