Calculate your average stock cost per share across multiple buys, including optional fees and current price gain or loss.
Table of contents
How to use our Stock Average Cost Calculator
- In Buy entries (shares, price paid, and fee), enter each purchase as its own row.
- Use the fee box in each row for any commission or purchase fee; leave it at 0 if there was no fee.
- Enter Current share price ($ per share, optional) only if you want current value, gain or loss, and the price gap to break-even.
- Click Calculate and read Average cost per share after fees first, because it is the fee-adjusted break-even price before taxes and selling fees.
- Sanity-check the result: Total shares owned should match your brokerage share count, and Total purchase cost after fees should match what you paid before any sales.

Definitions
Buy entries (shares, price paid, and fee): The list of stock purchases. Each row has shares bought, price paid per share, and an optional purchase fee.
Shares: The number of shares bought in a row. Fractional shares can be used if your brokerage allows them.
Price paid: The purchase price for one share in that row, before any separate fee.
Fee: A commission or other purchase fee tied to that buy. Blank fees are treated as 0.
Average cost per share before fees: Total share purchase cost divided by total shares, without fees.
Average cost per share after fees: Total share purchase cost plus entered fees, divided by total shares. This is the fee-adjusted break-even price before taxes and selling fees.
Cost basis: The amount used to measure gain or loss for an investment. Purchase costs can be part of basis depending on the investment and account records [1].
Current price above or below fee-adjusted break-even: Current share price minus the fee-adjusted average cost per share. Positive means the price is above break-even; negative means it is below break-even.
Common mistakes and quick fixes
Mistake: Putting all purchases into one line in Buy entries (shares, price paid, and fee) when the prices were different.
Fix: Add one row for each buy so the weighted average uses the right shares and price paid.
Mistake: Entering the total dollar cost as the price paid in Buy entries (shares, price paid, and fee) .
Fix: Enter the price per share in the price box, not the total order amount.
Mistake: Forgetting fees and then using Average cost per share before fees as the break-even price.
Fix: Enter each buy fee so Average cost per share after fees includes those purchase costs.
Mistake: Entering a negative fee in Buy entries (shares, price paid, and fee) to show a rebate or adjustment.
Fix: Use 0 or a positive fee only; handle rebates outside the calculator if your brokerage statement shows them separately.
Mistake: Treating Gain or loss after fees as a tax result.
Fix: Use it only as a simple market-value comparison; taxes, wash sales, dividends, and selling fees are not included.
Mistake: Using an old price in Current share price ($ per share, optional) and expecting live market results.
Fix: Type the current price you want to test, or leave it blank to calculate average cost only.
Limitations & Key Assumptions / Boundary Conditions
- The calculator uses only the buy rows you enter. It does not connect to a broker or pull live market prices.
- All buy rows should be for the same stock or fund. Do not mix different tickers in one calculation.
- For stock splits, enter split-adjusted shares and split-adjusted prices. The calculator does not adjust old share counts or prices for you.
- Taxes, wash sales, dividends, dividend reinvestment, return of capital, and selling fees are not included.
- Gain or loss after fees is a simple current-value comparison, not a realized taxable gain or loss.
- If your brokerage uses special tax-lot accounting, its tax basis may differ from this weighted-average calculation.
- Rounding on statements can cause small differences, especially with fractional shares or many rows.
Methodology
Weighted average calculation
The calculator first multiplies each row's shares by its price paid per share. It adds those row costs to get raw purchase cost, then divides by total shares. This is the standard weighted-average idea used for average cost calculations [2].
raw_cost = sum(shares_i * price_i)
total_shares = sum(shares_i)
raw_average_cost = raw_cost / total_shares
Fee-adjusted average
Next, the calculator adds the fee from each buy row. Blank fees count as 0. The fee-adjusted average spreads those entered purchase fees across all shares.
total_fees_entered = sum(fee_i)
fee_adjusted_average_cost = (raw_cost + total_fees_entered) / total_shares
Current price results
If you enter a current share price, the calculator multiplies it by total shares. It then compares that current value with total purchase cost after fees. Negative results stay negative because they mean the position is below the fee-adjusted cost.
current_position_value = total_shares * current_price
gain_loss_after_fees = current_position_value - (raw_cost + total_fees_entered)
price_gap_to_break_even = current_price - fee_adjusted_average_cost
Mini example
Suppose you bought 100 shares at $20 with a $4.95 fee, then 50 shares at $24 with another $4.95 fee. Raw purchase cost is $3,200, total shares are 150, and fees are $9.90. The average before fees is $21.3333 per share. The average after fees is $3,209.90 divided by 150, or $21.3993 per share. If the current share price is $25, current position value is $3,750, gain after fees is $540.10, and the price is $3.6007 above fee-adjusted break-even.