Realized profit calculator guide

How to Calculate Profit on a Partial Stock Sale

Selling part of a stock position requires more than multiplying the sale price by the number of shares sold. You must assign the correct purchase cost and buy commission to those shares, then keep the remaining shares and their cost basis separate.

Quick answer

What is the partial stock sale profit formula?

First calculate Net proceeds from the shares sold. Then subtract only the Cost basis of shares sold, not the cost basis of the entire position.

Net profit or loss=Net proceeds-Cost basis of shares sold

Cost basis of shares sold includes the purchase value assigned to those shares and the proportional buy commission. The calculator leaves the unsold portion in Remaining cost basis.

Calculator walkthrough

How to enter a partial stock sale

Open the stock profit calculator, enter the position exactly as it was purchased, and then define the shares included in the sale.

Partial stock sale inputs showing multiple purchases, FIFO selection, and 60 shares to sell
Enter purchases first, choose Partial sale, select the lot method, and specify Shares to sell so the Stock Profit Calculator can separate realized profit from Remaining cost basis.
  1. Choose Partial sale. The calculator will separate the sold shares from the shares that remain invested.

  2. Select the purchase lots. For multiple purchases, choose FIFO, LIFO, or Specific lots.

  3. Enter Shares to sell. The quantity must be smaller than the Total shares owned.

  4. Review the allocation. Confirm Cost basis of shares sold, Shares remaining, and Remaining cost basis before adding the sale price and fee.

One purchase example

Calculate profit when part of one purchase is sold

Suppose you own 100 shares bought at $50 and paid a $10 buy commission. You sell 40 shares at $65 and pay a $5 sell commission. Because all shares came from the same purchase, 40% of the original purchase value and buy commission belongs to the sale.

1. PURCHASE VALUE SOLD

Allocate the share cost

40 shares x $50 = $2,000

2. BUY COMMISSION

Allocate the fee

$10 x 40 / 100 = $4

3. COST BASIS SOLD

Add cost and fee

$2,000 + $4 = $2,004

4. NET PROCEEDS

Subtract the sale fee

(40 x $65) - $5 = $2,595

5. NET PROFIT

Compare proceeds with basis

$2,595 - $2,004 = $591

6. REMAINING BASIS

Keep the unsold cost separate

$5,010 - $2,004 = $3,006

Complete result

Realized profit is $591 and ROI is 29.49%

The ROI denominator is the $2,004 Cost basis of shares sold. The remaining 60 shares and $3,006 of cost basis are not included in realized profit from this sale.

Shares sold
40
Cost basis of shares sold
$2,004
Net proceeds
$2,595
Net profit
$591
ROI
$591 / $2,004 = 29.49%
Shares remaining
60
Remaining cost basis
$3,006

Multiple purchase example

Calculate a partial sale across multiple stock purchases

Now assume 50 shares were bought at $40 with a $5 commission, followed by 50 shares at $60 with another $5 commission. You sell 60 shares at $70 and pay a $6 sell commission. The result changes depending on which purchase lots supply those shares.

Partial stock sale results showing FIFO profit, cost basis of shares sold, shares remaining, and remaining cost basis
FIFO assigns the first 50 shares and 10 shares from the second purchase lot to the sale, then reports Cost basis of shares sold, Shares remaining, and Remaining cost basis.
  1. Realized result. FIFO produces $1,588 in Net profit and 60.94% ROI.

  2. Cost basis sold. The 60 shares carry $2,606 in purchase cost and allocated buy commissions.

  3. Position remaining. The unsold 40 shares remain visible instead of disappearing from the calculation.

  4. Remaining cost basis. The second lot retains $2,404 in basis for a later sale.

FIFO net profit=($4,200 - $6)-$2,606 = $1,588

Cost basis selection

FIFO vs LIFO vs specific lots

Purchase-lot selection does not change the sale proceeds. It changes the cost basis assigned to the shares sold, which can change calculated profit, ROI, and the cost basis left in the position.

FIFO

The first purchase entered supplies shares first. Enter purchases from oldest to newest so the order matches first-in, first-out treatment.

LIFO

The last purchase entered supplies shares first. In the example, LIFO assigns $3,406 of basis and produces $788 in profit, or 23.14% ROI.

Specific lots

Enter the exact number of shares sold from each purchase. Use this when your broker confirmation identifies the lots included in the transaction.

Why no average-cost option?

Average basis is not generally available for individual stocks under U.S. tax rules, except in limited categories such as certain mutual funds and dividend reinvestment plans.

Choosing LIFO in this calculator models a sale from the newest entries. It does not itself identify shares with a broker or establish the method accepted for a tax return.

How lot selection changes a partial stock sale result
Lot methodShares sold from lotsCost basis of shares soldNet proceedsNet profit or lossROI
FIFO50 from lot 1, 10 from lot 2$2,606$4,194$1,58860.94%
LIFO50 from lot 2, 10 from lot 1$3,406$4,194$78823.14%
Specific lotsChosen manuallyDepends on entered shares$4,194Depends on selected basisDepends on selected basis

Planning a partial exit

Find a target sell price for only the shares being sold

Partial sale also works with Find required sell price. The calculator uses Shares sold and Cost basis of shares sold to solve for a price that reaches the entered target profit or ROI. Shares remaining do not inflate the target calculation.

Required sell price=(Cost basis sold + Target profit + Flat sell fee - Dividends)/Shares sold

When Previous sales have been entered, the target calculation starts with the shares and cost basis remaining after those completed transactions. It solves for the current modeled sale only; cumulative realized profit from earlier sales remains in Position sale history.

Calculation scope

This is a profit estimate, not a tax calculation

Included

Shares sold, execution prices, allocated purchase costs, proportional buy commissions, sell commission, dividends, realized ROI, and remaining cost basis.

Not included

Capital gains tax rates, wash-sale adjustments, stock split tax treatment beyond the calculator's direct ratio adjustment, return of capital, inherited or gifted basis, currency conversion, slippage, and broker-specific rounding.

Specific identification

U.S. guidance generally requires timely identification of the shares with the broker and written confirmation. A calculator selection is not a substitute for that record.

FIFO fallback

IRS guidance states that when shares bought at different times cannot be adequately identified, the basis of the earliest acquired shares is used first.

Before relying on the estimate

Common partial stock sale mistakes

Using the entire position basis

Subtract only the basis assigned to shares sold. Including unsold shares understates realized profit.

Ignoring the buy commission allocation

A buy-side flat fee belongs partly to sold shares and partly to remaining shares. The calculator allocates it by share quantity within each purchase.

Entering purchases in the wrong order

FIFO and LIFO use the displayed purchase order. Enter lots from oldest to newest before selecting either method.

Comparing unrealized and realized profit

This result describes the modeled sale. It does not include the current unrealized gain or loss on shares remaining.

Combining previous and current sales

Enter completed sales from oldest to newest. The headline result describes the current modeled sale, while Position sale history reports cumulative realized proceeds and profit across all entered sales.

Methodology and references

Verify purchase lots against brokerage records

The calculator exposes the allocation method and remaining basis so the estimate can be compared with trade confirmations and account statements. Tax treatment depends on jurisdiction, account history, and records outside this calculator.

Related calculator guides

Connect partial-sale profit with cost basis and per-share results

Partial sales rely on the same Net proceeds and cost basis terms used throughout the Stock Profit Calculator, but only the shares sold are included in the realized result.

Ready to calculate a partial stock sale?

Use the Stock Profit Calculator