Lesson 2: Dollar-Cost Averaging & Market Timing Myths
Learn why consistent investing beats trying to time the market, and how to implement a systematic investment plan.
What is Dollar-Cost Averaging (DCA)?
Dollar-cost averaging is investing a fixed amount at regular intervals regardless of market conditions. You buy more shares when prices are low and fewer when prices are high.
Mental model: DCA is like a subscription to your future self — you pay the same amount each month and let the market do the work.
How DCA Works
| Month | Investment | Price | Shares Bought |
|---|---|---|---|
| January | $500 | $50 | 10.0 |
| February | $500 | $40 | 12.5 |
| March | $500 | $25 | 20.0 |
| April | $500 | $50 | 10.0 |
| May | $500 | $80 | 6.25 |
| June | $500 | $60 | 8.33 |
| Total | $3,000 | Avg: $50.83 | 67.08 |
Key insight: Your average cost per share ($50.83) is lower than the average price ($50.83) because you bought more shares when prices were low!
Why Market Timing Fails
Market timing is trying to predict when to buy low and sell high. Studies consistently show it doesn't work:
The Cost of Missing the Best Days
| Scenario | 20-Year Return | Annual Return |
|---|---|---|
| Stayed fully invested | +6.1% | +6.1% |
| Missed 10 best days | +2.5% | +2.5% |
| Missed 20 best days | +0.1% | +0.1% |
| Missed 30 best days | -1.9% | -1.9% |
| Missed 40 best days | -3.6% | -3.6% |
Key insight: The best days often happen right after the worst days — selling during a crash means you miss the recovery.
The Math of Recovering from Losses
| Loss | Gain Needed to Recover |
|---|---|
| -10% | +11% |
| -20% | +25% |
| -30% | +43% |
| -40% | +67% |
| -50% | +100% |
This is why protecting your downside matters more than capturing every upside.
DCA vs. Lump Sum Investing
| Method | Pros | Cons | Best For |
|---|---|---|---|
| DCA | Reduces timing risk, psychologically easier | May underperform in rising markets | Regular income earners |
| Lump Sum | Historically outperforms DCA ~67% of time | Higher timing risk, emotionally difficult | Large cash windfalls |
The data: According to Vanguard research, lump-sum investing beats DCA about 67% of the time. However, DCA is better for most people because:
- It removes emotion from investing
- It's easier to stick with during downturns
- It aligns with how most people earn (regular paychecks)
Implementing a DCA Strategy
Step 1: Choose Your Investment
| Investment Type | Best For | Risk Level |
|---|---|---|
| S&P 500 Index Fund | Core US stock exposure | Medium |
| Total Stock Market Fund | Broad US diversification | Medium |
| Target-Date Fund | Hands-off, auto-rebalancing | Varies |
| Bond Fund | Stability, income | Low |
Step 2: Set Your Amount and Frequency
| Frequency | Pros | Cons |
|---|---|---|
| Weekly | More DCA benefit | More transactions |
| Bi-weekly | Good balance | — |
| Monthly | Simple, aligns with paycheck | Slightly less DCA benefit |
| Quarterly | Fewer transactions | Less DCA benefit |
Recommended: Monthly, on the same day each month, regardless of market conditions.
Step 3: Automate It
Set up automatic contributions through your broker or 401(k). Automation removes the temptation to time the market.
Common DCA Mistakes to Avoid
- Mistake: Stopping contributions during downturns — Fix: DCA works best when you buy more during crashes.
- Mistake: Checking your portfolio daily — Fix: Check quarterly; daily checking leads to emotional decisions.
- Mistake: Switching investments frequently — Fix: Stick with your plan for at least 5 years.
- Mistake: Investing money you'll need soon — Fix: Only DCA money you won't need for 5+ years.
Professional Tips & Tricks
- Automate your investments — it removes emotion and ensures consistency.
- Increase contributions with every raise — lifestyle inflation kills wealth building.
- Use tax-advantaged accounts (401k, IRA) for DCA when possible.
- Don't try to "optimize" your DCA — the benefit is consistency, not timing.
Key Takeaways
- DCA invests fixed amounts at regular intervals, reducing timing risk.
- Missing the best 10 days in 20 years cuts returns by more than half.
- Lump sum beats DCA 67% of the time, but DCA is easier to stick with.
- Automation is the key to successful DCA — remove emotion from the equation.
- Start early and stay consistent — time in the market beats timing the market.
Next up: Tax-efficient investing and retirement account strategies.
# Dollar-Cost Averaging Calculator
## Monthly DCA Simulation
Monthly Investment: $500
Period: 12 months
| Month | Price | Shares | Total Value |
|-------|-------|--------|-------------|
| Jan | $100 | 5.00 | $500 |
| Feb | $90 | 5.56 | $500 |
| Mar | $80 | 6.25 | $500 |
| Apr | $85 | 5.88 | $500 |
| May | $95 | 5.26 | $500 |
| Jun | $110 | 4.55 | $500 |
| Jul | $120 | 4.17 | $500 |
| Aug | $105 | 4.76 | $500 |
| Sep | $90 | 5.56 | $500 |
| Oct | $85 | 5.88 | $500 |
| Nov | $95 | 5.26 | $500 |
| Dec | $100 | 5.00 | $500 |
|-------|-------|--------|-------------|
| Total | $95.42| 63.13 | $6,313 |
Your Average Cost: $6,000 ÷ 63.13 = $95.04
Market Average Price: $95.42
You SAVED: $0.38 per share (0.4%)
## Cost of Missing Best Days (S&P 500, 2003-2023)
Strategy | 20-Year Return
Fully Invested | +6.1% annually
Miss 10 Best Days | +2.5% annually
Miss 20 Best Days | +0.1% annually
Miss 30 Best Days | -1.9% annually
## Recovery Required After Losses
| Loss | Gain to Break Even |
|-------|-------------------|
| -10% | +11% |
| -20% | +25% |
| -30% | +43% |
| -40% | +67% |
| -50% | +100% |Lesson Code (Python)
# Dollar-Cost Averaging Calculator
## Monthly DCA Simulation
Monthly Investment: $500
Period: 12 months
| Month | Price | Shares | Total Value |
|-------|-------|--------|-------------|
| Jan | $100 | 5.00 | $500 |
| Feb | $90 | 5.56 | $500 |
| Mar | $80 | 6.25 | $500 |
| Apr | $85 | 5.88 | $500 |
| May | $95 | 5.26 | $500 |
| Jun | $110 | 4.55 | $500 |
| Jul | $120 | 4.17 | $500 |
| Aug | $105 | 4.76 | $500 |
| Sep | $90 | 5.56 | $500 |
| Oct | $85 | 5.88 | $500 |
| Nov | $95 | 5.26 | $500 |
| Dec | $100 | 5.00 | $500 |
|-------|-------|--------|-------------|
| Total | $95.42| 63.13 | $6,313 |
Your Average Cost: $6,000 ÷ 63.13 = $95.04
Market Average Price: $95.42
You SAVED: $0.38 per share (0.4%)
## Cost of Missing Best Days (S&P 500, 2003-2023)
Strategy | 20-Year Return
Fully Invested | +6.1% annually
Miss 10 Best Days | +2.5% annually
Miss 20 Best Days | +0.1% annually
Miss 30 Best Days | -1.9% annually
## Recovery Required After Losses
| Loss | Gain to Break Even |
|-------|-------------------|
| -10% | +11% |
| -20% | +25% |
| -30% | +43% |
| -40% | +67% |
| -50% | +100% |Console Output
# Dollar-Cost Averaging Calculator
## Monthly DCA Simulation
Monthly Investment: $500
Period: 12 months
| Month | Price | Shares | Total Value |
|-------|-------|--------|-------------|
| Jan | $100 | 5.00 | $500 |
| Feb | $90 | 5.56 | $500 |
| Mar | $80 | 6.25 | $500 |
| Apr | $85 | 5.88 | $500 |
| May | $95 | 5.26 | $500 |
| Jun | $110 | 4.55 | $500 |
| Jul | $120 | 4.17 | $500 |
| Aug | $105 | 4.76 | $500 |
| Sep | $90 | 5.56 | $500 |
| Oct | $85 | 5.88 | $500 |
| Nov | $95 | 5.26 | $500 |
| Dec | $100 | 5.00 | $500 |
|-------|-------|--------|-------------|
| Total | $95.42| 63.13 | $6,313 |
Your Average Cost: $6,000 ÷ 63.13 = $95.04
Market Average Price: $95.42
You SAVED: $0.38 per share (0.4%)
## Cost of Missing Best Days (S&P 500, 2003-2023)
Strategy | 20-Year Return
Fully Invested | +6.1% annually
Miss 10 Best Days | +2.5% annually
Miss 20 Best Days | +0.1% annually
Miss 30 Best Days | -1.9% annually
## Recovery Required After Losses
| Loss | Gain to Break Even |
|-------|-------------------|
| -10% | +11% |
| -20% | +25% |
| -30% | +43% |
| -40% | +67% |
| -50% | +100% |Code Visualization Tips
- Plot your DCA purchases on a price chart — see how you bought more shares during dips.
- Calculate your average cost vs. the market average price after 12 months.
- Visualize the compounding effect of consistent investing over 20+ years.
Professional Tips & Tricks
- Automate your investments — it removes emotion and ensures consistency.
- Increase contributions with every raise — lifestyle inflation kills wealth building.
- Don't check your portfolio daily — check quarterly to avoid emotional decisions.
Python Code Judge & Practice Arena
LeetCode StyleRun real Python 3.12 WebAssembly code directly in your browser against automated test suites.
DCA Calculator
Up next · Continue learning
Tax-Efficient Investing & Retirement Accounts
Maximize your after-tax returns by understanding tax-advantaged accounts, tax-loss harvesting, and asset location strategies.