Finance / Investing

Stock Average Calculator

Calculate average cost from buys and sells with fees, then solve how many shares at a new price reach a target average.

Stock Average Calculator: Uses average-cost accounting. Buy fees increase the position basis. Sells remove a proportional share of that basis; sell fees reduce proceeds and realised profit. A sale leaves the average cost of the remaining position unchanged. The target-average solver allows fractional shares. This is bookkeeping arithmetic, not investment advice or a tax-lot election. Runs 100% locally in your browser with zero server file uploads.

Runs
In your browser
Cost
Free · no sign-up
Availability
Ready to use
Stock average calculatorLocal processing

Runs entirely in your browser

These are arithmetic tools, not investment advice. Enter every figure yourself; no market data is fetched.

Use buy or sell in the first column; the fee column is optional. Average-cost accounting includes buy fees in the position basis. A sale removes proportional basis; sale fees reduce realised proceeds. Remaining average cost stays the same after a sale. This is bookkeeping arithmetic, not a tax-lot rule.

Average cost of remaining shares$9.00
Shares remaining150
Remaining cost basis$1,350.00
Realised profit or loss$0.00
Shares needed to reach a target average

Buy 75 shares at the entered price, including the entered fee. Fractional shares are allowed.

New shares = (current basis + new fee − target × current shares) ÷ (target − new price).

2 rows
TradeSideSharesPriceFeeRemaining sharesRemaining basisAverage costCumulative realised profit
1Buy100$10.00$0.00100$1,000.00$10.00$0.00
2Buy50$7.00$0.00150$1,350.00$9.00$0.00

Currency changes formatting only. It does not convert amounts.

Average-cost method

The method is defined here for a single remaining position. New basis = old basis + purchase quantity × price + buy fee. Sale basis removed = old basis × sold quantity / old quantity. No tax-lot selection is performed.

Weighted average and target

NIST Dataplot Reference Manual, weighted mean: sum of weight × value divided by sum of weights. Here the weights are share quantities. Official source: https://www.itl.nist.gov/div898/software/dataplot/refman2/ch2/weigmean.pdf

Average cost = remaining basis / remaining shares. New quantity = (current basis + new fee − target average × current shares) / (target average − new price). Worked example: 100 shares at 10 plus 50 at 7 gives 1350 / 150 = 9. For equal cash purchases, compare the dollar-cost averaging calculator.

How to use it

  1. Paste chronological buy and sell rows with shares, price and an optional fee.
  2. Read the remaining shares, average cost, cost basis and realised profit or loss.
  3. Enter a new purchase price, target average and fee to solve for additional shares; export the trade table if needed.

Privacy & limitations

All figures are entered by you and stay in your browser. No market data, tickers or prices are fetched. These are arithmetic tools, not investment advice.

Related tools

Frequently asked questions

How are sells handled?

A sale removes sold shares multiplied by the average cost immediately before the sale. Sale proceeds less fees and removed basis give realised profit or loss. Selling more shares than held is rejected.

How do I average up or down?

Choose a target strictly between the current average and the new purchase price. The result solves the weighted-average equation, including a fee for the new purchase.

Is this a tax calculator?

No. Average cost is the stated bookkeeping method. Tax basis and allowable disposal methods depend on applicable rules and are outside this tool.

Free tool · runs in your browser · no account required