Guides

Does Selling Shares Change Your Average Cost?

Selling part of a position feels like it should change your average cost. You locked in a gain or a loss, so surely the number on the remaining shares moves too. Under the average cost method it does not. This guide works through a partial sale by hand, calculates the realized gain including fees, and explains why your broker may show a different cost basis.

A partial sale under average cost

Take the example from the formula guide: 40 shares bought at $120 and 40 more at $90. That is 80 shares for $8,400, an average of $105.00. Now you sell 30 shares at $115.

Under average cost, every share carries the same cost of $105, so the 30 shares sold had a cost of 30 × $105 = $3,150. What stays behind is $8,400 − $3,150 = $5,250 spread over 50 shares.

Before the saleAfter selling 30
Shares8050
Remaining cost$8,400$5,250
Average cost$105.00$105.00

$5,250 ÷ 50 = $105.00. The share count drops; the cost per share does not. That holds whether you sell above or below your average. The difference between the sale price and the average goes into realized gain or loss instead.

Realized gain on the shares sold

Realized gain = (sale price − average cost) × shares sold − sell fees − buy fees on those shares

Using a 0.25% commission each way:

  • Proceeds: 30 × $115 = $3,450. Sell commission: $8.63 (0.25% of $3,450).
  • Cost of the shares sold: $3,150. Their share of the original buy commission: 0.25% × $3,150 ≈ $7.88.
  • Gain before fees: ($115 − $105) × 30 = $300.
  • Realized gain after fees: $300 − $8.63 − $7.88 ≈ $283.50.

With $0 commissions the realized gain is simply $300. Small rounding differences against your broker's figures are normal.

FIFO and specific lots give different numbers

Average cost is one of several ways to decide which shares you sold. Your two purchases are separate tax lots, and the method picks which lot the 30 shares come from:

MethodCost of 30 soldGain before feesAverage of remaining 50
Average cost$3,150+$300$105.00
FIFO (oldest $120 lot first)$3,600−$150$96.00
Specific lot ($90 lot)$2,700+$750$114.00

Same trade, same cash, but the reported gain ranges from a $150 loss to a $750 gain, and the cost shown on the remaining shares moves with it. Across the sold and remaining shares the total cost is always $8,400; the methods only split it differently.

This is the most common reason a broker's cost basis differs from a hand calculation. In the US, average cost is generally available for mutual funds and some reinvested shares, while individual stocks usually default to FIFO unless you choose specific lots. Brokers in other countries often display a moving average instead. The tax side, including holding periods and the wash-sale rule, is covered in the fees and tax guide.

Buying again after a sale

If you later buy more, the new average starts from what remains, not from the original position. Under average cost you hold 50 shares at $105. Buying 30 at $100 gives:

(50 × $105 + 30 × $100) ÷ 80 = $8,250 ÷ 80 ≈ $103.13

The $300 realized earlier does not lower this number; it is already booked separately. Under FIFO the same purchase would start from 50 shares at $96, giving ($4,800 + $3,000) ÷ 80 = $97.50, which is why the method matters even for later buys.

Using the calculator

To check a new average after a sale, enter the shares you still hold and the average your broker shows for them, then the price and quantity of the new purchase. The numbers here only illustrate the arithmetic; they are not a suggestion to buy or sell.

→ Back to the calculator