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.

What 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