Cost Basis & Dollar-Cost Averaging
Last reviewed: May 2026
A stock average calculator computes your weighted average cost per share across multiple purchases — the foundation of performance tracking and tax reporting. Whether dollar-cost averaging into index funds or building a position over time, knowing your true average cost tells you your break-even price, unrealized gain or loss, and eventual tax liability.1
| Month | Investment | Price | Shares | Avg Cost |
|---|---|---|---|---|
| Jan | $500 | $50 | 10.0 | $50.00 |
| Feb | $500 | $45 | 11.1 | $47.37 |
| Mar | $500 | $40 | 12.5 | $44.77 |
| Apr | $500 | $42 | 11.9 | $43.89 |
| May | $500 | $48 | 10.4 | $44.65 |
| Jun | $500 | $52 | 9.6 | $45.67 |
Buying more after a decline lowers your break-even but increases exposure to a falling asset. Only average down when your original thesis is intact and the decline is sentiment-driven. Set a maximum position size before your first purchase to prevent emotional decisions.2
When you buy the same stock or fund at different prices over time, your average cost per share determines your profit or loss when you sell. If you buy 100 shares at $50 and later 100 shares at $30, your average cost is (100×$50 + 100×$30) ÷ 200 = $40 per share. If the stock rises to $45, you're profitable ($5/share × 200 = $1,000 gain) even though your second purchase was underwater at $30. This averaging effect is fundamental to dollar-cost averaging strategies and determines your tax liability on sales. The IRS allows two methods for calculating cost basis on mutual funds: average cost (total investment ÷ total shares) and specific identification (selecting which specific shares to sell). Specific identification lets you minimize taxes by selling highest-cost shares first, but requires meticulous record-keeping of every purchase date and price.
Dollar-cost averaging (DCA) — investing a fixed dollar amount at regular intervals — automatically buys more shares when prices are low and fewer when prices are high, mathematically reducing your average cost below the average price. Investing $500/month in a stock that trades at $50, $40, $30, $40, $50 over five months buys 10, 12.5, 16.7, 12.5, and 10 shares respectively — 61.7 shares at an average cost of $40.52, while the average price was $42. However, research from Vanguard analyzing 91 years of market data found that lump-sum investing outperformed DCA about two-thirds of the time, because markets trend upward and delayed investment means missing returns. DCA's advantage is psychological: it reduces regret risk and removes the paralyzing fear of investing a large sum at a market peak. For most people, the best approach is immediate lump-sum investment for existing savings plus automatic DCA from ongoing income (which most 401(k) participants already do via paycheck deductions).
Buying more shares of a declining stock to lower your average cost is called "averaging down." It's one of the most debated strategies in investing because it amplifies both the potential recovery profit and the potential total loss. If you bought 200 shares at $100 ($20,000 invested) and the stock drops to $50, buying 200 more shares ($10,000) lowers your average to $75. A recovery to $75 makes you break even instead of needing a 100% gain back to $100. But if the stock drops to $25, you've now lost $22,500 instead of $15,000. Averaging down works when the price decline doesn't reflect a fundamental deterioration — a broad market correction, temporary earnings miss, or sector rotation. It fails catastrophically when the decline signals real business problems: declining revenue, competitive disruption, or accounting fraud. Professional investors distinguish between these cases through fundamental analysis; retail investors often average down based on emotion ("'it has to come back") without assessing why the stock fell.
Selling stocks at a loss to offset capital gains taxes requires understanding your cost basis. If your average cost is $40 and you sell at $35, you realize a $5/share loss that can offset other gains dollar-for-dollar, or up to $3,000 of ordinary income per year with unlimited carryforward. The wash sale rule prevents you from claiming the tax loss if you repurchase the same or "substantially identical" security within 30 days before or after the sale. However, you can sell a declining S&P 500 ETF and immediately buy a similar (but not identical) total market ETF, harvesting the loss while maintaining market exposure. Tax-loss harvesting is most valuable in high-income years and for investors with large realized capital gains from selling a business, real estate, or concentrated stock positions. The cost basis of your replacement purchase becomes the lower price, deferring but not eliminating the eventual tax — it's a timing benefit that has present value because a dollar of tax saved today is worth more than a dollar of tax paid decades from now.
As different investments grow at different rates, your portfolio drifts from its target allocation. A 60/40 stock/bond portfolio might become 70/30 after a bull market. Rebalancing — selling appreciated assets and buying underperforming ones — mechanically implements "sell high, buy low" and maintains your intended risk level. Each rebalancing trade creates new cost basis entries: selling appreciated stocks generates capital gains (and tax liability in taxable accounts), while buying discounted bonds establishes a new, lower average cost. In tax-advantaged accounts (401(k), IRA), rebalancing has no tax consequences and should be done at least annually. In taxable accounts, rebalancing costs must be weighed against the risk management benefit — sometimes adding new contributions to the underweighted asset class achieves rebalancing without triggering sales. Automatic rebalancing features in robo-advisors and target-date funds handle this complexity continuously, typically rebalancing when any asset class drifts more than 5 percentage points from its target.
If you hold the same stock across multiple brokerage accounts, each account tracks its own cost basis independently. Transferring shares between brokerages is supposed to carry cost basis information, but errors are common — especially for shares purchased before 2012, when the IRS began requiring brokerages to track and report cost basis. If you transferred 500 shares of a stock you've held since 2005, the receiving brokerage may list the cost basis as "unknown" or use the transfer date as the acquisition date (which would overstate your gain and increase your tax bill). Maintaining personal records of every purchase — date, quantity, price, and commissions — protects against these errors. Spreadsheets or portfolio trackers like Sharesight or Stock Events provide consolidated cost basis tracking across all accounts and help calculate accurate average costs for tax reporting.
When selling only some of your shares, the IRS offers several methods for determining which shares you're selling, each producing a different taxable gain or loss. FIFO (first in, first out) assumes you sell your oldest shares first — these typically have the lowest cost basis and therefore produce the largest taxable gain. LIFO (last in, first out) sells newest shares first, which may have a higher cost basis and produce smaller gains during a rising market. Specific lot identification lets you choose exactly which shares to sell, optimizing for your tax situation: selling high-cost lots minimizes current-year gains, while selling low-cost lots in years when you have offsetting losses captures gains tax-efficiently. Most brokerages default to FIFO unless you specify otherwise. Actively choosing your lot identification method can save 2-5% in taxes on investment sales over a lifetime — a meaningful edge that compounds alongside your returns.
Tracking average cost across multiple purchases requires calculating the total cost and total shares at each step. Suppose you make four purchases of XYZ stock over a year: January — 50 shares at $80 ($4,000). April — 75 shares at $65 ($4,875). July — 100 shares at $55 ($5,500). October — 25 shares at $72 ($1,800). Total invested: $16,175 across 250 shares. Average cost per share: $16,175 ÷ 250 = $64.70. If XYZ trades at $70, your unrealized gain is ($70 - $64.70) × 250 = $1,325, or 8.2% return on investment. Notice that without the July purchase at $55 (the lowest price, where you bought the most shares), your average cost would be much higher. DCA naturally exploits this: fixed dollar amounts automatically purchase more shares at lower prices, reducing average cost more efficiently than buying fixed quantities would. If you had bought 50 shares each time instead (paying $80, $65, $55, $72 for 200 shares), your average cost would be $68 — higher than the DCA average of $64.70 despite buying the same stock at the same prices. This mathematical advantage of fixed-dollar investing is the core reason financial advisors recommend automatic investment plans over manual market-timing attempts.
→ DCA into index funds. The most reliable long-term wealth strategy.
→ Track cost basis for taxes. Verify broker reporting after splits or transfers.
→ Set position limits. Decide max allocation before first purchase.
→ Use specific identification. Sell highest-cost shares first to minimize gains.
See also: CAGR · Dividend · ROI · Compound Interest