Cost basis & stock average calculator
A cost basis calculator works out the average price you paid per share across every purchase of the same stock, what the position cost in total, and what it is worth now.
Bought the same stock more than once? This free stock average calculator takes each purchase and returns your weighted average cost per share — the number your gain is measured from.
Your purchases
Add every buy of the same stock. Fractional shares are fine.
Enter today's price to see market value and unrealized gain.
Runs in your browser. Nothing is saved or sent anywhere.
How the average cost calculator works
Every purchase of the same stock has its own price. To get a single cost per share, you weight each purchase by how many shares it bought — a plain average of the prices would be wrong whenever the purchases were different sizes. In full:
total cost = sum of (shares × price paid) over every purchase total shares = sum of shares over every purchase average cost per share = total cost ÷ total shares market value = total shares × current price unrealized gain = market value − total cost
Worked example
You buy 10 shares at $500 and later 10 more at $600.
- Total cost:
(10 × $500) + (10 × $600) = $11,000 - Total shares:
20 - Average cost per share:
$11,000 ÷ 20 = $550
Sell 5 shares at $620 and your gain, on the average method, is 5 × ($620 − $550) = $350.
The two prices happen to be attached to equal share counts here, so the answer matches the simple midpoint. Change the second purchase to 30 shares and it stops being $550 — which is exactly why the weighting matters. For the concept in full, read what cost basis actually means, or compare the methods in average cost vs. FIFO vs. specific lots. When you do sell, the stock profit calculator measures the sale against this average, commissions and partial sales included, and the annualized return calculator turns the gain into a yearly rate from the dates you bought.
What this calculator can't do
It answers for one holding, once. It does not remember the answer, it does not know today's price unless you type it in, and it will not notice when you buy more next month or reinvest a dividend. Every one of those events changes your average, and the number you just worked out goes stale.
That is the whole reason StoxDeck exists: enter each holding once and it keeps the basis, fetches live prices, and shows the gain measured from what you actually paid — across every account, without connecting to your brokerage.
Build your first deckLooking at the whole portfolio rather than one holding? The portfolio rebalancing calculator shows how far each position has drifted from its target weight. If one of your holdings has been through a split, the stock split calculator adjusts the share count and per-share cost on each lot first.
More free tools
- Stock profit calculatorProfit or loss, return on cost and break-even price on a sale, fees netted out.
- Portfolio rebalancing calculatorHow far each holding has drifted from its target weight, and what to buy or sell.
- Stock split calculatorNew share count and corrected cost basis per lot after a forward or reverse split.
- Annualized return calculatorThe rate per year a holding has earned, from dated purchases and today's price.
- Portfolio tracker spreadsheetA free Google Sheets and Excel template with live price lookups wired in.
Common questions
How do you calculate the average cost of a stock?
Multiply the shares in each purchase by the price you paid, add those amounts together for your total cost, then divide by the total number of shares. That weighted average is your cost basis per share. Buying 10 shares at $500 and 10 at $600 gives $11,000 across 20 shares, or $550 per share.
Is average cost the same as cost basis?
Average cost is one way of figuring cost basis. Cost basis is simply what you paid to acquire shares, including commissions. When you have bought the same holding several times, you can blend every purchase into one average or track each purchase as a separate lot. This calculator uses the average method.
Does this calculator include fees and commissions?
Not separately. If you want commissions counted, add them into the price per share for that purchase, or enter the fee as its own line with a share count of zero and the fee as the price. Most US brokers no longer charge per-trade commissions on stocks and ETFs.
Should I use average cost or specific lots?
Average cost is far easier to keep straight by hand. Specific-lot identification gives you more control over which shares you sell, which can matter at tax time. Which one applies to you depends on your broker's settings and your own situation, so check with a tax professional before relying on either.
Does anything I type get saved or sent anywhere?
No. The calculator runs entirely in your browser. Nothing is transmitted, stored, or logged, and there is no account to create to use it.
Disclaimer. This calculator is informational only and is not investment, tax, or financial advice. Cost basis rules differ by account type and by how your broker reports lots — check your own situation with a tax professional. StoxDeck is a portfolio-tracking tool, not a broker or an adviser.