Stock Average (Cost Basis) Calculator
The stock average calculator finds the weighted average cost per share across multiple purchase lots. Enter each lot’s share count and purchase price, then enter a current stock price if you want an unrealized profit or loss estimate. The result includes total shares, total cost basis, market value, unrealized profit or loss, and unrealized return. It is informational only and is not trading advice or tax advice.
This page is about position arithmetic, not technical signals. If you are studying chart levels, use the RSI calculator, moving average calculator, or pivot point calculator. If a corporate action has changed your shares, use the stock split calculator before comparing per-share values. For a selling scenario, the stock calculator can help with broader stock return inputs.
What the inputs mean
Each purchase lot has two fields: shares bought and price per share. The calculator accepts fractional shares up to the precision supported by the calculator, so it can handle dividend reinvestment or fractional brokerage purchases. It requires each counted lot to have shares greater than zero and a price that is zero or positive. The current stock price is used only for market value and unrealized return. It does not change the average cost.
One calculation detail matters: invalid lot rows are skipped rather than causing the whole result to fail. If one row has zero shares, a negative price, or a non-number, the calculator ignores that row and still uses the remaining valid rows. If all rows are invalid or total shares are zero, it returns an invalid result.
Formula
Scope: The equations below describe arithmetic for this scenario, not a sourced legal, tax, lending, investment-performance, health, payroll, accounting, or policy standard. Inputs are user assumptions; the calculation defines its own conditions and rounding rules.
Total cost basis is the sum of every counted lot’s shares times its price:
Weighted average cost per share is:
Market value at the current price is:
Unrealized profit or loss and return are:
The calculatorula is weighted because a large purchase should influence average cost more than a small purchase. Buying 100 shares at one price and 1 share at another should not be treated as a simple two-price average.
Checking the primary result
Use the default lots: 10 shares at 100, 5 shares at 90, and 15 shares at 80. The first lot costs 1,000. The second costs 450. The third costs 1,200. Total cost basis is 2,650 and total shares are 30. The weighted average cost is 2,650 divided by 30, or 88.33 per share when displayed as currency.
With the default current price of 95, market value is 95 times 30, or 2,850.00. Unrealized profit or loss is 2,850 minus 2,650, or 200.00. Unrealized return is 200 divided by 2,650, times 100, or about 7.55%. The lot breakdown shows each counted lot in the calculatorat shares times price equals cost, matching the component’s calculation.
Now suppose a fourth row accidentally has zero shares at 70. The calculation method does not add it to total shares or total cost. The average remains 88.33 because zero-share rows are skipped. That behavior is convenient for editing a list, but you should remove bad rows before saving or sharing results so the calculation is easy to audit.
How investors use average cost
Average cost helps answer practical questions: what price would bring the position back to breakeven before taxes and fees, how much exposure has been added by averaging down, and how far the current market price sits above or below the blended entry. It can also help compare planned purchases. Buying more below the current average lowers the average cost, while buying above it raises the average cost.
That does not make additional buying safer. Averaging down can concentrate risk in a declining security. Averaging up can add exposure after a strong move. A lower average cost may feel better psychologically, but the portfolio still depends on future market prices, business fundamentals, liquidity, and your time horizon. Past purchase prices do not predict future returns.
For taxes, treat this calculator as a rough reconciliation tool. Brokerage statements may adjust basis for wash sales, corporate actions, reinvested dividends, commissions, returns of capital, or transfers between accounts. Different tax lots may also have different holding periods. Before filing, compare the result with official broker records and relevant tax guidance.
Common mistakes
- Averaging the prices themselves instead of weighting each price by shares.
- Forgetting fees or commissions when they are part of your basis.
- Mixing different tickers, share classes, or accounts in one calculation.
- Using split-adjusted prices with unadjusted share counts, or the reverse.
- Treating unrealized profit as locked in before an actual sale.
Sources
No external document is asserted as authority for this calculator’s arithmetic, branch policy, thresholds, rounding, or result interpretation. Add only sources whose frozen exact passage directly supports a separately mapped bounded claim.