Stock Average Calculator - Cost Basis
Enter up to five stock purchases - each with a share count and a price per share - and this calculator works out your weighted-average cost basis instantly. Add an optional commission per lot to fold trading fees into the cost, and enter the current market price to see your unrealized profit or loss and the percentage return on your position. The break-even price tells you exactly what the stock needs to reach for you to recover your full investment including fees.
Formula
Worked example
Investor buys 10 shares at $120 and then 15 shares at $105, both with no commission. Total cost = 10x120 + 15x105 = 1200 + 1575 = $2775. Total shares = 25. Average cost = 2775/25 = $111.00 per share. At a current price of $130, position value = 25x130 = $3250. Unrealized gain = 3250 - 2775 = $475 (17.12%).
What is cost basis and why does it matter?
Cost basis is the total amount you paid for a group of shares, including any brokerage commissions, divided by the number of shares you own. It is the starting line for calculating your profit or loss when you eventually sell. If you bought a stock once at a single price, the math is trivial. But most long-term investors buy the same stock multiple times at different prices, and the weighted-average approach this calculator uses blends all those purchases into a single per-share figure. That figure matters in two ways: it tells you whether you are currently sitting on a gain or a loss, and it is the number the IRS (or your country equivalent) uses to calculate your taxable gain when you sell.
How the weighted-average cost basis is calculated
The formula is straightforward: multiply the number of shares in each lot by its price per share, add any commission paid on that lot, sum all those amounts, then divide by the total number of shares across every lot. For example, buying 10 shares at $120 and then 15 more at $105 gives a total cost of $2,775 across 25 shares, an average of $111.00 per share. A simple arithmetic average of the two prices (($120 + $105) / 2 = $112.50) would be wrong because the second purchase was larger; the weighted average correctly weights each price by how many shares it represents. Commissions raise your cost basis, which reduces your taxable gain on a future sale, so it is worth recording them even when they are small.
Averaging down vs. averaging up
Averaging down means buying more shares after the price has fallen, which lowers your cost basis and reduces the price the stock needs to reach for you to break even. It is a common strategy, but it has risks: it increases your position size and therefore your total exposure to a stock that is already declining. Averaging up means adding shares after the price has risen, which raises your cost basis. This is often done by momentum investors who believe the trend will continue; the trade-off is that the stock now has to rise even further to be profitable on the newer shares. Neither strategy is inherently better - the right choice depends on your conviction in the investment and your overall risk budget.
Break-even price and unrealized profit or loss
Your break-even price is the average cost per share when commissions are included. The stock must trade at or above that level for your position to be profitable overall. Unrealized profit or loss is the difference between your current position value (current price x total shares) and your total cost. It is called unrealized because you have not yet sold; the gain or loss only becomes taxable when you close the position. Percentage return is the unrealized profit or loss divided by total cost, expressed as a percentage - the same figure you would see on a brokerage statement under "total return."
Cost basis methods - which one to use
| Method | How it works | Best when |
|---|---|---|
| Weighted average | Total cost of all shares divided by total shares held. Used by this calculator. | Mutual funds (required by IRS) or when you treat a position as a single block |
| FIFO (First In, First Out) | Oldest shares are considered sold first. | Share price is falling - selling older, higher-cost shares reduces taxable gain |
| LIFO (Last In, First Out) | Newest shares are considered sold first. | Share price is rising - selling newer, higher-cost shares reduces taxable gain |
| Specific identification | You choose exactly which lot to sell. | Maximum tax flexibility - requires good records; most brokers now support this |
| Highest cost | Highest-cost lot is sold first regardless of purchase date. | Minimizing current-year gain when prices have risen significantly |
The IRS recognizes several cost basis methods for stocks. Each can produce a different taxable gain on the same sale.
Frequently asked questions
What is the weighted-average cost basis?
It is the total amount you paid for all your shares - including commissions - divided by the total number of shares you hold. Because you may have bought shares at different prices over time, a simple average of the prices would ignore the fact that you bought different quantities at each price. The weighted average accounts for that by giving larger lots more influence on the final figure.
Does this calculator support fractional shares?
Yes. Enter any decimal number in the shares field, for example 2.5 shares. Many brokers now allow fractional share purchases, particularly for high-priced stocks, and the weighted-average formula handles them exactly the same way.
Should I include commissions in my cost basis?
Yes, for tax purposes. The IRS allows you to add brokerage commissions to your cost basis, which reduces your taxable gain when you sell. The commission fields in this calculator fold that cost into the per-share average. If your broker charges no commission (common with most modern retail brokers), simply leave those fields at zero.
What is the difference between averaging down and dollar-cost averaging?
Averaging down is a deliberate decision to buy more of a stock after its price has fallen, specifically to lower your cost basis. Dollar-cost averaging (DCA) is a scheduled investment strategy where you invest a fixed amount of money at regular intervals regardless of the price - sometimes buying more shares when the price is low and fewer when it is high. DCA is about discipline and removing emotion from timing decisions; averaging down is a tactical response to a price drop in a position you already hold.
Which cost basis method is best for taxes?
It depends on the situation. Specific identification gives you the most flexibility because you choose exactly which lot to sell, allowing you to minimize current-year gains or harvest losses as needed. FIFO is the IRS default for stocks if you do not specify a method. Weighted average is required for mutual funds and optional for ETFs. Talk to a tax adviser before choosing a method, as the decision can be locked in once you start selling a position.
Does cost basis reset after a stock split?
Yes. After a stock split, you divide your total cost basis by the new number of shares to get the adjusted per-share basis. For example, if you paid $2,000 for 10 shares ($200 each) and the stock does a 2-for-1 split, you now hold 20 shares with a total basis of $2,000, so $100 per share. Your brokerage should adjust this automatically, but it is worth verifying.
Can I use this calculator for ETFs, options, or crypto?
The weighted-average calculation itself works for any asset where you have a share count and a purchase price, so ETFs are a natural fit. For options, the concept of cost basis applies but the tax treatment is different. For cryptocurrency, the IRS treats crypto as property, and cost basis rules are similar to stocks, but the specific tracking requirements differ by jurisdiction. Always verify with a tax professional for non-stock assets.