Cost basis & stock average calculator
Bought the same stock more than once? Enter each purchase and get 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 average cost is calculated
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.
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.
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 deckCommon 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.