Calculator
Stock profit calculator
Add the shares, buy price, sell price and commissions of each trade to see the profit or loss, the return on cost and the price each position needed to break even. The arithmetic is exact: no floating point touches your numbers.
Calculator
One row per round trip: shares bought, then the same shares sold. Leave a commission empty if there was none. Digits and a decimal point only, no thousands separators.
Paste trades from a spreadsheet or broker CSV
One trade per line: shares, buy price, sell price, buy commission, sell commission (the commissions are optional). Comma, tab or semicolon between columns. A header line is skipped. Nothing is uploaded; the text is read in this page.
- Net profit or loss, after commissions
- –
- Return on cost
- –
- Total cost, with buy commissions
- –
- Total proceeds, after sell commissions
- –
- Profit before commissions
- –
- All commissions
- –
Arithmetic only. Not tax, financial or investment advice. Nothing you enter leaves your browser.
The formulas
For each round trip, meaning shares bought and then the same shares sold:
cost = shares × buy price + buy commission
proceeds = shares × sell price − sell commission
profit = proceeds − cost
The totals add the exact values of every row and round once at the end. Return on cost is the net profit divided by the total cost, times 100. When the total cost is zero, for example shares received as a gift with no commission, there is nothing to divide by and the calculator shows a dash.
Worked example
Two invented round trips of made-up stocks, one gain and one loss. The "Load the example" button above fills these same rows. Each figure in the table was produced at build time by the function the calculator runs.
| Trade | Shares | Buy | Sell | Commissions | Cost | Proceeds | Profit |
|---|---|---|---|---|---|---|---|
| 1 | 100 | 48.20 | 52.65 | 4.95 + 4.95 | 4824.95 | 5260.05 | 435.10 |
| 2 | 50 | 41.75 | 39.10 | 4.95 + 4.95 | 2092.45 | 1950.05 | -142.40 |
| Total | 19.80 | 6917.40 | 7210.10 | 292.70 |
Net profit is 7210.10 − 6917.40 = 292.70, which is 4.23% of the 6917.40 cost. Before commissions the same two trades made 312.50; the 19.80 of commissions account for the difference.
The break-even price
Each row also shows the sell price at which that trade would have made exactly zero after both commissions:
break-even sell price = (shares × buy price + buy commission + sell commission) ÷ shares
In the first example trade that is 48.2990 per share, slightly above the 48.20 paid, because the two commissions have to be earned back across the shares. Fixed commissions weigh more on small positions: spread across fewer shares, the same commission moves the break-even price further.
Rounding and exactness
- Rounding rule: half up on the size of the number, so a tie goes away from zero. Money is rounded to 2 decimals, the break-even price to 4 and the return on cost to2.
- One rounding step per figure. The totals come from the exact sums of the rows, not from rounded rows, so a total can differ by a cent from the sum of the displayed row profits.
- No negative zero. A result that rounds to zero is shown as 0.00, never as -0.00.
- No floating point. Each number you type is read as exact decimal text and held as a scaled whole number (BigInt). Sums and products are whole-number arithmetic.
- Input limits. Digits and one decimal point, at most 40 characters per number, shares above zero, prices and commissions zero or more. Anything else is flagged, never guessed.
- Tested against a reference. The page's function is run against 39 test vectors (gains, losses, fractional shares, very large numbers, rounding ties, invalid input) computed independently with Python's
decimalmodule.
What it does not do
Every row is one purchase followed by one sale of the same shares. The calculator has no tax field and does not calculate tax. It also does not model short sales, options, dividends, stock splits, currency conversion, interest on borrowed money or fees other than the two commissions you enter. A figure from another source may differ if it handles fees, lots or timing differently, so compare the method, not just the number. For buying in several steps, the stock average calculator gives the average price per share across buys.
Embed it
You can place this calculator on your own page. Copy the snippet; it loads a small page from this site and keeps the attribution link.
Have 200 trades?
Typing a handful of trades is fine. If they sit in a broker statement PDF, Statementizer reads supported broker statements into a spreadsheet, splits out every commission and lets you check each row against the page it came from. See what it reads from Interactive Brokers Activity Statements.
See how Statementizer worksSources
The formulas are arithmetic, so there is no regulator or vendor to cite for them. These are the references for how it is implemented and checked.
Verified on 2026-10-18 by the Statementizer Team.