When you buy the same stock or ETF on more than one occasion — a starter position, a dollar-cost-averaging add, a dip-buy — you do not own a single-price lot. You own a blended position, and the price that actually matters for taxes and for deciding whether to sell is your average cost basis per share. This stock average calculator takes every buy you entered, weights each price by the number of shares you took, and returns the true average price you paid, your total invested, your total share count, and (if you enter the current price) your unrealized gain or loss.
This is the same weighted-average method most US brokerages (Fidelity, Schwab, Vanguard) use as their default cost-basis reporting. It is not a simple arithmetic mean of your prices — that would understate the basis when you buy more shares at the lower price. The math below weights each lot by its size, which is what your 1099-B will actually show.
How to Use
- Type your first buy into Buy 1 — Shares and Buy 1 — Price per Share. For example, 100 shares at $50.00.
- Add your second buy in the Buy 2 row — for example, another 100 shares at $60.00. The result card updates instantly.
- If you have bought the same ticket three, four, or five times, fill in rows Buy 3, Buy 4, and Buy 5 only as needed. Leave unused rows at 0; they are ignored.
- Optionally enter the Current Share Price to see your market value and unrealized gain or loss. Leave it at 0 if you only want the cost-basis math.
- Read the result card from top to bottom: total shares held, total invested (your cost basis), the highlighted average cost per share, and — if you entered a current price — market value, dollar P&L, and percentage P&L.
The calculator is symmetric: it does not matter which order you enter the buys in, because weighted average depends only on the total shares and total dollars, not on the sequence of trades.
The Average Cost Formula
Your average cost per share is the total dollars invested divided by the total shares acquired:
Average Cost = (Shares₁ × Price₁ + Shares₂ × Price₂ + … + Sharesₙ × Priceₙ) / (Shares₁ + Shares₂ + … + Sharesₙ)
This is a weighted arithmetic mean. Each purchase price is weighted by how many shares you bought at that price, so a 200-share lot counts twice as much as a 100-share lot at the same price.
Worked example: 100 shares at $50.00 plus 100 shares at $60.00. Total invested = 100 × $50 + 100 × $60 = $5,000 + $6,000 = $11,000. Total shares = 200. Average cost = $11,000 / 200 = $55.00 per share. Notice that $55.00 is exactly halfway between $50 and $60 — but only because the two lot sizes are equal. If you had bought 200 shares at $50 and only 100 at $60, the average would drift toward the cheaper price.
If you enter a current price, the engine computes:
- Market Value = total shares × current price.
- Unrealized Gain/Loss = market value − total invested.
- Unrealized P&L % = (current price − average cost) / average cost × 100.
If no shares have been entered (total shares = 0), the calculator raises an error rather than dividing by zero.
Why Weighted Average, Not a Simple Mean?
A common mistake is to average the prices you paid and ignore the share counts. Suppose you bought 300 shares at $20 and then 100 shares at $40. A simple average of $20 and $40 is $30 — but that is wrong. Your true basis is (300 × $20 + 100 × $40) / 400 = ($6,000 + $4,000) / 400 = $25 per share. Because most of your shares were bought at the lower price, the real basis sits closer to $20 than to $40. Filing taxes on the wrong basis means overpaying (if you think you made less) or underpaying (if you think you made more) your capital gains.
How Brokers Report Cost Basis
US brokerages are required by the IRS to track and report cost basis on Form 1099-B for covered securities purchased after 2011. The default method is usually average cost for mutual funds and ETFs, and FIFO (first-in, first-out) for individual stocks — but you can often switch to specific-identification (specifying which lot you sell) inside your brokerage settings. This calculator mirrors the average-cost method. If your broker uses FIFO or specific-lot accounting, your realized gain on a partial sale may differ from what this page shows; the average-cost figure is still the right break-even price for the whole position.
Examples
Example 1 — Two equal buys (the default). You buy 100 shares at $50.00, then 100 more at $60.00. Total invested is $11,000, total shares 200, and your average cost is $55.00 per share. If the stock now trades at $65.00, market value is $13,000 and you are sitting on an unrealized gain of +$2,000 (+18.18%).
Example 2 — Dollar-cost averaging into a dip. You buy 50 shares at $20.00, 150 shares at $30.00, and 200 shares at $45.00. Total invested = 50×$20 + 150×$30 + 200×$45 = $1,000 + $4,500 + $9,000 = $14,500. Total shares = 400. Average cost = $14,500 / 400 = $36.25 per share. Adding the dip at $45 still pulled your average up to $36.25 because you bought the largest lot at the highest price.
Example 3 — A large position, scaled up. You accumulate 1,000,000 shares of a low-priced stock at $50.00. Total invested is $50,000,000 and average cost stays $50.00 (single lot). The calculator handles positions this large without rounding or overflow.
Example 4 — Zero-share row ignored. You enter 0 shares on Buy 1 (a placeholder) and 100 shares at $60 on Buy 2. The empty row contributes nothing: total shares 100, total invested $6,000, average cost $60.00.
FAQ
What is a stock average calculator?
It is a tool that combines all of your buys in the same ticker into a single weighted-average cost per share. Instead of tracking each lot separately, you enter shares and price for every buy, and the calculator returns the average price you paid, your total invested, and your total share count — the figures you need to judge a sale.
How do I calculate average cost per share?
Divide the total dollars you invested by the total number of shares you hold. For example, 100 shares at $50 plus 100 shares at $60 is $11,000 invested across 200 shares, or $55.00 per share. This is a weighted average, not a simple average of the prices.
Is average cost the same as cost basis?
Yes, under the average-cost accounting method. Your cost basis is the total dollars you put into the position (plus any commissions), and your per-share basis is that total divided by your share count. When you sell, your taxable gain is sale proceeds minus that basis.
Should I use average cost, FIFO, or specific identification?
Average cost is simple and the default for most mutual funds and ETFs. FIFO sells your oldest lot first, which can matter for long-term vs. short-term capital-gains holding periods. Specific identification lets you pick exactly which lot to sell, which is the most tax-flexible but requires you to instruct your broker at trade time. This calculator shows the average-cost figure; check your brokerage's default before you assume it.
Does this calculator include commissions and fees?
By default it does not. If your trades carried commissions, add them into the price per share or add them to the total invested. For example, a $5 commission on a 100-share buy at $50 effectively raises your cost by $0.05 per share.
What if I bought the same stock at five different prices?
Enter each buy on its own row — Buy 1 through Buy 5. The calculator weights each lot by its share count, so the result is the same whether you enter the trades in chronological order or not. If you have more than five lots, combine the smallest ones or use a spreadsheet; the math is identical.
What if I enter 0 shares for a row?
That row is skipped. The calculator ignores any (0 shares, $0 price) row, so you can leave unused buy rows blank without affecting the average. If every row is 0, the engine returns an error because there are no shares to average.
How do I know my break-even price?
Your average cost per share is your break-even price on the whole position (before commissions and taxes). If the current price is above your average cost, you are in the green; below it, you are underwater. Enter the current price in the optional field to see the exact dollar and percentage P&L.
Disclaimer
This stock average calculator is provided for informational purposes only and does not constitute financial, tax, or investment advice. Cost-basis figures are estimates based on the inputs you enter; actual brokerage cost-basis accounting may use FIFO, LIFO, or specific identification and may include commissions, dividends reinvested, and corporate actions (splits, mergers, spin-offs) that this tool does not model. Capital-gains tax treatment depends on your holding period, tax bracket, and jurisdiction. Always verify your true cost basis with your broker and consult a qualified tax professional before selling.