Your Average Cost Per Share Isn't What the IRS Taxes You On (And That's a Bigger Deal Than It Sounds)
Buy 50 shares at $40, 30 more at $55, and 20 more at $30, and the average cost per share across all 100 shares comes to $42.50. That number is genuinely useful for tracking how a position is performing. It is very often not the number used to calculate the taxable gain or loss when those shares actually get sold, and the difference between the two can swing a sale from a taxable gain to an outright loss, on the exact same trade.
This calculator finds the average cost per share across multiple purchases. Here's how that number is calculated, why it's not automatically what gets reported to the IRS, and how to use it for the two things it's genuinely built for: tracking performance and averaging down.
The calculation itself is simple
Average cost per share is the total amount spent divided by the total number of shares owned, weighted by how many shares came from each purchase, not a simple average of the three prices paid.
Using the example above: total cost is (50 × $40) + (30 × $55) + (20 × $30) = $2,000 + $1,650 + $600 = $4,250, across 100 shares, for an average cost of $42.50 per share. Note that's not the same as averaging $40, $55, and $30 directly, which would incorrectly give $41.67; the weighting by share count matters whenever purchase sizes differ.
The detail that catches almost everyone off guard: this method usually isn't allowed for stocks
Here's the part a simple average-cost calculator doesn't tell you, and it matters the moment shares actually get sold. The IRS permits the average cost method for calculating taxable gains only on mutual fund shares, certain exchange-traded funds structured as regulated investment companies, and shares acquired through a dividend reinvestment plan (DRIP) after January 1, 2011. For ordinary purchases of individual company stock, average cost is not an available method at all. Brokers default to First In, First Out (FIFO), treating the earliest-purchased shares as the first ones sold, unless the account holder specifically elects a different method (such as specific lot identification) before the trade settles.
This isn't a minor technicality. Using the same three purchases above (50 shares at $40, 30 at $55, 20 at $30), suppose 40 shares get sold at $50 each, for $2,000 in proceeds. The taxable result depends entirely on which accounting method applies:
Under FIFO (the broker's default for stocks), the 40 shares sold come from the earliest lot, the $40 purchase. Basis is 40 × $40 = $1,600, so the taxable gain is $400.
If average cost were used (not permitted for this stock, but included for comparison), basis would be 40 × $42.50 = $1,700, for a gain of $300.
Under specific identification, selecting the highest-cost shares to sell first (30 shares from the $55 lot, plus 10 from the $40 lot), basis is (30 × $55) + (10 × $40) = $1,650 + $400 = $2,050, against $2,000 in proceeds, an actual loss of $50.
Same shares, same sale price, same day. One legitimate accounting choice produces a $400 taxable gain; another produces a $50 loss. That's the entire reason the IRS restricts which method applies to which security type, and it's also why a calculator's average cost figure, while useful for tracking, should not be assumed to be the tax basis without checking which method actually governs the specific stock being sold.
Specific identification has to happen before the trade, not after
Choosing to sell specific lots (rather than accepting the broker's FIFO default) generally has to be communicated to the broker at or before the time of the sale, in writing or through the platform's lot-selection tool, not decided afterward once the tax bill is being calculated. Most major brokers now offer a lot-selection screen at the time of sale specifically for this reason. Deciding after the fact which lots "should" have been sold doesn't change what actually gets reported unless the identification was made contemporaneously with the trade.
Covered vs. noncovered shares changes who's tracking what
Since 2011 for individual stocks (and 2012 for most mutual funds and ETFs), brokers are required to track and report cost basis directly to the IRS on Form 1099-B for what's called "covered" shares, generally anything purchased after those dates. Shares purchased earlier, "noncovered" shares, still need to be reported on a tax return, but the broker isn't required to have tracked or reported the basis, which means the account holder is on the hook for keeping their own purchase records. Anyone holding a position built up over many years, with purchases spanning both sides of that 2011 cutoff, may be dealing with two separate sets of records for the same stock.
Where average cost genuinely earns its keep: averaging down
The average cost figure is exactly the right tool for one very common question: how many more shares, bought at today's lower price, does it take to bring the average purchase price down to a specific target?
Take a position of 100 shares with an average cost of $60, now trading at $40. To bring the average cost down to $50 a share, the number of additional shares needed at $40 works out algebraically: (6,000 + 40x) / (100 + x) = 50, which solves to x = 100 additional shares, a $4,000 investment, bringing the total position to 200 shares at a blended $50 average. This is a purely mathematical exercise, useful for understanding the mechanics of a position, and it says nothing on its own about whether buying more of a declining stock is actually a good decision, that depends on why the price fell and whether the original thesis for owning it still holds.
The wash sale rule can undo a loss that averaging down was chasing
Selling shares at a loss and buying substantially identical shares within 30 days before or after that sale triggers the wash sale rule, which disallows the loss for tax purposes in that year (the disallowed loss gets added to the cost basis of the new shares instead, deferring rather than eliminating it). This becomes directly relevant to anyone using an average-cost calculator around a loss-harvesting sale: buying more shares of the same stock shortly after selling a losing lot, even with the intent of averaging down or rebalancing, can wipe out the tax benefit of that sale entirely if the timing falls inside the wash sale window.
How the sale eventually gets taxed once basis is settled
Once the correct basis and lot are determined, the resulting gain or loss is reported on Form 8949 and flows to Schedule D. Holding period matters as much as the dollar amount: shares held more than one year qualify for long-term capital gains rates (0%, 15%, or 20% for 2026, depending on total taxable income), while shares held one year or less are taxed as short-term gains at ordinary income rates up to 37%. Because FIFO, specific identification, and average cost (where allowed) can each point to a different original purchase date for the shares being sold, the accounting method doesn't just change the gain amount, it can change whether that gain qualifies as long-term or short-term in the first place.
Common questions
Can I use average cost basis when I sell individual stock shares? Generally no. The IRS restricts the average cost method to mutual fund shares, certain regulated-investment-company ETFs, and DRIP-acquired shares after 2011. Individual stock sales default to FIFO unless specific lots are identified at the time of sale.
If my broker's app shows one average cost number, is that what I'll be taxed on? Not necessarily. Many broker platforms display a single average cost figure for portfolio-tracking purposes even when the actual tax basis, once a sale happens, is calculated lot by lot under FIFO or specific identification. Check which figure appears on the 1099-B before assuming they match.
Does buying more shares after a loss always trigger the wash sale rule? Only if the repurchase happens within 30 days before or after the loss sale, and the shares are substantially identical. Waiting more than 30 days, or intentionally spacing out purchases, avoids the wash sale disallowance.
Is averaging down always a good strategy? Not automatically. It lowers the breakeven price mathematically, but it also increases the total dollar amount at risk in a position whose price has already fallen. Whether that's a reasonable decision depends on the specific situation, not on the math alone.
What happens to cost basis for shares I inherited or received as a gift? Those follow separate rules (generally a stepped-up basis to fair market value at the date of death for inherited shares, or a carryover basis with some exceptions for gifted shares), different from the purchase-based average cost calculation this calculator handles.
Purchase prices and sale prices used in the examples above are illustrative and not quotes from any real security. Cost basis method rules (average cost restricted to mutual funds, RIC ETFs, and post-2011 DRIP shares; FIFO as the broker default for individual stocks) reflect current IRS guidance under Publication 550 and are comparatively stable, though broker-specific default settings and available lot-selection tools can change. Capital gains tax rate thresholds reflect 2026 figures under IRS Revenue Procedure 2025-32 and are adjusted annually for inflation. This is not tax advice; cost basis elections and their consequences depend on your specific accounts and history, and are worth confirming with a tax professional or directly with your broker before a sale.