How the stock profit calculator works
Transparency matters on financial topics. This page explains exactly what the calculator includes, what it leaves out, and why.
Core formula
For a full sale, Net profit or loss = Net proceeds - Total cost basis. For a partial sale, Net profit or loss = Net proceeds - Cost basis of shares sold. Net proceeds = Gross sale value - Sell commission + Dividends.
- Purchase value
- Shares purchased x Buy price per share
- Cost basis
- Purchase value + Buy commission
- Net proceeds
- Gross sale value - Sell commission + Dividends
- Net profit or loss
- Net proceeds - Cost basis assigned to shares sold
- ROI
- Net profit or loss / Assigned cost basis x 100
- Profit per share
- Net profit or loss / Shares sold
ROI = Net profit or loss / Total cost basis x 100. Annualized return for one purchase uses the entered Holding period when no exact dates are supplied. Exact Purchase date and Sale date inputs use the Actual/365 Fixed day-count convention. For multiple purchases or a position with Previous sales or dated dividends, the calculator uses XIRR when every relevant cash flow has a valid date.
Position history, sale allocation, and planning
XIRR treats purchase values and allocated Buy commissions as negative cash flows. Net proceeds from Previous sales and the current modeled sale are positive cash flows. In Position history mode, each dated dividend is a separate positive cash flow on its payment date. XIRR is not shown when dates are missing, out of order, or do not create a valid return solution.
Partial sales allocate purchase value and Buy commissions to the shares sold. With multiple purchases, FIFO uses the first entries, LIFO uses the last entries, and Specific lots uses the quantities entered for each purchase. Enter purchases from oldest to newest when FIFO or LIFO is selected. Remaining cost basis stays with the unsold shares.
Find shares to sell works in the opposite direction: at an entered sell price, it finds the share quantity that reaches a target Net proceeds, Net profit or loss, or shares remaining. Choose an exact fractional result, whole shares that meet the target, or the closest whole-share result. Multi-lot positions support FIFO, LIFO, and explicit per-lot limits. For Specific lots, the entered limits define the available shares and the shown purchase order defines the sequence; the calculator never guesses a tax-lot preference.
Previous sales marked Included are processed from oldest to newest before the current calculation. A draft sale does not change any result until it is included. Each included sale removes shares and the matching cost basis from the position using its selected FIFO, LIFO, or Specific lots method. The current result therefore uses only the shares and basis that remain, while Position sale history reports cumulative realized proceeds and profit separately.
Profit at different sell prices holds the position assumptions constant and recalculates results at 20% and 10% below and above the entered sell price. The chart and compact table use the same five calculations. A percentage Sell commission changes with each scenario; a flat Sell commission remains fixed.
Adjust for a stock split multiplies purchase and sale share quantities by the entered ratio and divides their per-share prices by the same ratio. This preserves modeled position value and fee amounts. It is an input-normalization aid, not a complete treatment of every corporate action or tax-basis adjustment.
How each calculation is performed
Use these focused guides when you want the formula, a worked example, and the exact calculator workflow for one task.
Stock profit formula
Calculate profit or loss from shares, prices, commissions, dividends, and cost basis.
Read the guideFees and commissions
See how buy-side and sell-side fees change proceeds, profit, ROI, and break-even.
Read the guideTarget sell price
Work backward from a target profit or ROI to the sell price required.
Read the guideMultiple purchases and XIRR
Combine separate purchase lots and use dated cash flows for annualized return.
Read the guidePartial sales and lot allocation
Assign cost basis to shares sold with FIFO, LIFO, or explicitly selected lots.
Read the guideProfit per share
Understand the net result contributed by each share included in the sale.
Read the guideShares to sell for a target
Find an exact or whole-share quantity for target proceeds, profit, or shares remaining.
Read the guideBreak-even stock price
Solve the zero-profit sell price after fees, dividends, and assigned cost basis.
Read the guideAnnualized return and XIRR
Compare one-trade annualization with dated, irregular position cash flows.
Read the guideStock profit with dividends
Include total or dated dividends in proceeds, profit, ROI, and break-even.
Read the guideAverage stock cost basis
Calculate weighted purchase price and per-share basis across multiple lots.
Read the guideFIFO vs LIFO profit
See how lot order changes realized profit and the basis left in the position.
Read the guideStock split adjustment
Normalize shares and per-share prices while preserving value and commissions.
Read the guideWhat is included
- Number of shares
- Shares sold and Shares remaining for a partial sale
- Buy price per share and Sell price per share
- Multiple purchases with separate prices and Buy commissions
- FIFO, LIFO, and Specific lots for partial sales
- Shares-to-sell planning for proceeds, profit/loss, or shares remaining with exact and whole-share policies
- Buy commission and Sell commission
- Flat-fee or percentage-fee commission models
- Total dividends received
- Dated dividend payments in Position history mode
- Holding period in months or exact Purchase date and Sale date
- XIRR from fully dated purchases and sales
- Previous sales and cumulative realized position results
- A chronological position timeline
- Nearby sell-price profit scenarios
- Up to five named comparison scenarios stored on the device
- Forward and reverse stock split input adjustments
Saved inputs and shared scenarios
The calculator automatically saves the current draft in the browser on the device being used. The draft is not sent to an account or synced between devices. Reset clears the working scenario and restores the default example.
A shared calculation stores the calculator inputs in the generated URL so another browser can reproduce the scenario. Up to five named comparison scenarios stay in the browser on the current device and do not create a brokerage or transaction record.
Results are marked as Recorded only when the user identifies the sale as completed. Target-price and shares-to-sell workflows are always marked Estimated because they model a future or hypothetical outcome.
What is not included
- Taxes and after-tax return
- Foreign exchange conversion
- Bid-ask spread and slippage
- Borrow fees, margin interest, or option overlays
- Mergers, spin-offs, return of capital, and wash-sale adjustments
- Automatic synchronization with brokerage or tax records
Editorial and formula review
The page stays intentionally narrow. It tries to improve accuracy in the areas that most often distort a simple stock profit estimate while still loading quickly and remaining easy to understand on first visit.
A research and product team that develops practical financial tools for traders and investors, with a focus on stock returns, trading costs, cost basis, and investment performance.
Stock Profit Calculators Research Team checks formulas, worked examples, labels, and limitations whenever calculator behavior or supported inputs change. Automated regression tests cover the reusable math, allocation and conservation rules, inverse solvers, stock-split normalization, and dated-return validation before release.
If a calculation error is confirmed, the formula, regression coverage, methodology, and affected guides are corrected together. Read the complete editorial review and corrections process, including the reference calculation used to check core results. The latest public site update appears in the footer.
Reference points
IRS Topic no. 703: Basis of assets
IRS guidance explains that stock basis generally starts with the purchase price plus additional costs such as commissions and transfer fees.
Read sourceInvestor.gov: Understanding Fees
Investor.gov emphasizes that fees can materially change long-term investment outcomes, which is why the calculator includes them directly.
Read sourceInvestor.gov: Stocks FAQ
Investor.gov notes that stock investing may involve both commissions and dividends, two inputs that often change the true result of a trade.
Read source