Cost basis calculator guide

How to Calculate Stock Profit with Multiple Purchases

When shares were bought at different prices, a useful stock profit estimate must combine every purchase quantity, execution price, and buy commission before comparing the position with its sale proceeds. This guide shows the complete calculation.

Quick answer

How do you calculate stock profit from multiple purchases?

Add the value and commission of every purchase to find Total cost basis. Add all purchased shares to find Total shares. Then apply one Sell price per share to the combined position and subtract the expected Sell commission from Gross sale value.

Net profit or loss=Net proceeds-Total cost basis

Weighted average buy price is useful for describing the position, but commissions are added separately to cost basis. That distinction prevents broker fees from disappearing inside a rounded average price.

Calculator walkthrough

Step 1: enter each stock purchase separately

Open the stock profit calculator and choose Multiple purchases. Add one entry for each buy. Every entry accepts fractional shares, a Buy price per share, and either a flat or percentage Buy commission.

Multiple-purchase stock profit calculator with 40 shares bought at 80 dollars and 60 shares bought at 100 dollars
Each purchase lot keeps its own Number of shares, Buy price per share, and Buy commission; the Stock Profit Calculator combines them before the sale is modeled.
  1. Enter the first purchase. Add its share quantity, execution price, and actual buy-side commission.

  2. Add another purchase. Repeat the process for every buy that belongs to the position you want to evaluate.

  3. Review the combined basis. The summary shows Total shares, Weighted average buy price, Purchase value, Buy commissions, and Total cost basis.

  4. Model the exit. Enter a Sell price per share and Sell commission just as you would for one purchase.

Position math

Step 2: calculate the weighted average buy price

Do not average the two prices by adding them and dividing by two unless the share quantities are equal. Weight each price by the number of shares purchased at that price.

1. PURCHASE ONE

Find the first value

40 shares x $80 = $3,200

2. PURCHASE TWO

Find the second value

60 shares x $100 = $6,000

3. COMBINE

Add value and shares

$3,200 + $6,000 = $9,200; 40 + 60 = 100 shares

4. WEIGHTED AVERAGE

Divide value by shares

$9,200 / 100 = $92.00 per share

5. BUY COMMISSIONS

Add transaction fees

$5 + $5 = $10

6. COST BASIS

Add value and fees

$9,200 + $10 = $9,210

Weighted average buy price in the calculator excludes buy commissions. Total cost basis includes them. Cost basis per share in this example is therefore $92.10, even though the weighted average execution price is $92.00.

Multiple-purchase position values before the stock sale
Purchase lotSharesBuy price per sharePurchase valueBuy commissionTotal cost basis
Purchase 140$80$3,200$5$3,205
Purchase 260$100$6,000$5$6,005
Combined position100$92 weighted average$9,200$10$9,210

Worked sale scenario

Step 3: calculate net stock profit and ROI

Continue the example with a Sell price per share of $110 and a flat $10 Sell commission. No dividends are included. The combined 100 shares produce an $11,000 Gross sale value and $10,990 in Net proceeds.

Multiple-purchase stock profit results showing 1780 dollars profit, 19.33 percent ROI, and 9210 dollars total cost basis
The Stock Profit Calculator result panel applies Sell price per share to the combined position and explains Net profit or loss, ROI, Total cost basis, Net proceeds, and Total fees.
  1. Net profit and ROI. The position earns $1,780 after both buy commissions and the sell commission, equal to 19.33% ROI.

  2. Break-even sell price. A $92.20 sale price would recover the $9,210 Total cost basis plus the $10 Sell commission.

  3. Total cost basis. The result retains the $9,200 Purchase value and $10 of buy-side commissions.

  4. Plain-English explanation. The dynamic summary states the combined shares, weighted average price, proceeds, price gain, fees, and final result.

Complete result

Net profit is $1,780 and ROI is 19.33%

Gross sale value exceeds Purchase value by $1,800. Total fees are $20, leaving $1,780 after costs. ROI compares that result with the full $9,210 Total cost basis.

Purchase value
$9,200
Buy commissions
$10
Total cost basis
$9,210
Gross sale value
100 x $110 = $11,000
Net proceeds
$11,000 - $10 = $10,990
Net profit
$10,990 - $9,210 = $1,780
ROI
$1,780 / $9,210 = 19.33%

Planning an exit

Use multiple purchases with a target sell price

The same combined position works in Find required sell price mode. If the target is $2,000 in Net profit and the expected Sell commission is $10, the sale must produce $11,220 before that fee. Dividing by 100 shares gives a Required sell price of $112.20.

Required sell price=($9,210 + $2,000 + $10)/100 = $112.20

A percentage Sell commission changes the denominator because the fee grows with Gross sale value. The calculator handles that adjustment automatically after the commission type is selected.

Different purchase dates

How XIRR measures annualized return for multiple purchases

One holding period cannot accurately describe capital added on several dates. Treating every dollar as if it had been invested on the first date can overstate or understate the yearly return. Instead, add a Purchase date to every entry and a Sale date to the current calculation. The calculator then estimates Annualized return with XIRR.

XIRR treats each Purchase value and Buy commission as a dated negative cash flow. Net proceeds from dated Previous sales and the current sale are positive cash flows. Dividends entered in the current scenario are included with the current sale. The result remains unavailable until all required dates are valid and chronological.

Profit per share remains a separate result because it divides Net profit or loss for the current modeled sale by Shares sold; see how to calculate profit per share for that per-share workflow.

Calculation scope

What the multiple-purchase calculation includes

Included

Separate share quantities, buy prices, flat or percentage buy commissions, a current modeled sell price, Previous sales with their own prices and commissions, and optional dividends.

Combined automatically

Total shares, Purchase value, Buy commissions, Weighted average buy price, and Total cost basis.

Partial sale support

Choose Partial sale to allocate shares using FIFO, LIFO, or Specific lots while preserving Shares remaining and Remaining cost basis.

Position history

Previous sales are applied sequentially before the current calculation. The calculator reports remaining shares and basis alongside cumulative realized proceeds and profit.

Stock split adjustment

One forward or reverse split ratio scales entered share quantities and per-share prices while preserving position value and fee amounts.

Taxes remain excluded

Lot selection changes the estimated realized basis, but the calculator does not calculate capital gains tax or replace brokerage records.

Selling fewer than the Total shares requires a separate cost basis allocation. Read How to Calculate Profit on a Partial Stock Sale for FIFO, LIFO, and specific-lot examples.

Before relying on the estimate

Common multiple-purchase calculation mistakes

Using a simple average

Weight each buy price by its share quantity. A simple average is correct only when every purchase contains the same number of shares.

Combining commissions incorrectly

Enter each buy fee with the matching purchase. Percentage fees are calculated from that purchase's value, not from the final combined position.

Mixing currencies

Keep every purchase, commission, dividend, and sale value in the same currency. The calculator does not perform FX conversion.

Confusing ROI with annualized return

ROI measures profit against Total cost basis without timing the separate cash flows. XIRR uses the date of each purchase and sale; missing or out-of-order dates prevent a valid annualized result.

Methodology and references

Cost basis and commissions remain visible

The calculator keeps Purchase value and Buy commissions separate so the weighted execution price can be checked without losing transaction costs. IRS basis guidance and Investor.gov fee education both reinforce the importance of retaining purchase costs and fees in investment records.

Related calculator guides

Use multiple purchases with partial sales and per-share results

Once several purchase lots are entered, the same Stock Profit Calculator can calculate full-position profit, partial-sale realized profit, target sell price, Profit per share, dated XIRR, and cumulative results after Previous sales.

Ready to combine your own stock purchases?

Use the Stock Profit Calculator