Stock profit loss calculator
Buy 100 shares at 50, sell at 65, pay 7.5 in commission each way, and your net profit is 1,485, a 29.66% return on cost. Fees on both sides are counted, so the result matches your actual cash. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Buy price
- 50
- Sell price
- 65
- Shares
- 100
- Buy commission
- 7.5
- Sell commission
- 7.5
- Total cost
- 5,007.5
- Total proceeds
- 6,492.5
- Gross profit
- 1,500
- Total commissions
- 15
Traders, educators, and portfolio tools need a clear answer after every closed stock position: how much money was made or lost after commissions, and what percent return that represents on capital tied up in the trade. Spreadsheet formulas differ on whether fees come out of proceeds or cost, and hand calculators often ignore one side of the commission. This stock profit loss calculator accepts buy price per share, sell price per share, share count, and optional buy and sell commissions, then returns total cost, total proceeds, gross profit before fees, total commissions, net profit or loss, percent return on cost, per-share price change, and a simple outcome label of profit, loss, or breakeven.
How stock trade profit and loss is defined here
A long stock trade has two cash legs that matter for net performance: what you paid to open the position and what you received when you closed it. Total cost is the buy price times the number of shares plus any buy-side commission or fee. Total proceeds are the sell price times the number of shares minus any sell-side commission.
Net profit equals total proceeds minus total cost; a negative value is a net loss. Percent return is net profit divided by total cost, times one hundred, so the denominator includes capital used for shares and the opening fee. Gross profit is the price change times shares before commissions, which helps you see how much of the move fees consumed.
Total commissions is the sum of buy and sell fees. Per-share price change and price-change percent describe the underlying move independent of size. Outcome is the word profit when net is positive, loss when negative, and breakeven when net rounds to zero at the chosen decimal precision.
Example: buy one hundred shares at fifty, sell at sixty-five, with seven dollars fifty cents on each side. Cost is five thousand plus seven point five equals five thousand seven point five; proceeds are six thousand five hundred minus seven point five equals six thousand four hundred ninety-two point five; net is about one thousand four hundred eighty-five dollars, a healthy double-digit percent return on cost.
What you can do with it
Closed-trade performance check
After selling shares, enter buy price, sell price, size, and both commissions to see net profit and percent return on cost.
Classroom and content widgets
Embed the free browser calculator on education pages so learners verify textbook long-trade examples with commissions.
FAQ
Why is my return 29.66% when the price rose 30%?
Because commissions count. The price moved from 50 to 65, a 30% change, but the 15 in fees and the buy commission included in your cost bring the net down to 1,485 on a cost of 5,007.5.
Are commissions taken from the cost or from the proceeds?
From both, each on its own side. The buy commission is added to what you paid for the shares and the sell commission is subtracted from what you received, so neither fee is forgotten.
When is a trade labelled breakeven?
When its net profit rounds to zero at the decimals you chose. A positive net is labelled profit and a negative one loss, so you can sort your closed positions at a glance.
Does it handle short sales, dividends or taxes?
No. It gives the cash result of one ordinary buy and sell with explicit fees. Short sales, wash sales, dividends, taxes and currency conversion are outside its scope, so handle them separately.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/finance/stock-profit-loss \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"buy_price":50,"sell_price":65,"shares":100}'const res = await fetch("https://api.kit.forhosting.com/finance/stock-profit-loss", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"buy_price": 50,
"sell_price": 65,
"shares": 100
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/finance/stock-profit-loss",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"buy_price": 50,
"sell_price": 65,
"shares": 100
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/finance/stock-profit-loss", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"buy_price":50,"sell_price":65,"shares":100}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"buy_price":50,"sell_price":65,"shares":100}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/finance/stock-profit-loss", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"buy_price": 50,
"sell_price": 65,
"shares": 100
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "finance.stock_profit_loss",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
How stock trade profit and loss is defined here
Short sales, wash sales, taxes, dividends, and currency conversion are out of scope—this endpoint answers the cash P&L question for a single long-style open and close with explicit fees.
Input contract, rounding, and error behaviour
Half-up rounding is applied once to each output field from the raw floating computation so goldens stay stable across runtimes. POST a JSON object with three required finite numbers: buy_price greater than zero, sell_price greater than or equal to zero, and shares greater than zero. Optionally send buy_commission and sell_commission as non-negative finite numbers (each defaults to zero when omitted), and decimals as an integer from zero through eight controlling half-up rounding of money-style and percent fields (default two). Numeric strings that parse to finite values are accepted the same way as JSON numbers. Missing fields, non-finite values, non-positive buy_price or shares, negative sell_price or commissions, and out-of-range decimals fail with invalid_input and are not billed. On success the body echoes the rounded inputs, total_cost, total_proceeds, gross_profit, total_commissions, net_profit, percent_return, price_change, price_change_percent, outcome, and a short formula string you can show next to the numbers. If sell commission exceeds sell notional, total_proceeds can be negative; that edge case is still computed rather than rejected, because some fee schedules charge fixed tickets on tiny positions. Pair this API with your own tax module if you need capital-gains brackets; the calculator does not estimate tax.
Where a stock P&L calculator earns its keep
Brokerage education pages and personal-finance blogs rank for stock profit loss calculator when they offer a live tool that matches the story next to the article. Coaching platforms let students enter textbook buy and sell prices and check net percent return including realistic ticket fees. Fintech onboarding sandboxes show first-trade P&L without standing up a full order-management system. Internal ops scripts batch-close paper trades and need a deterministic parse endpoint instead of a spreadsheet paste step. Sweep sell_price or commission in a loop from your own code to build what-if tables; pin net_profit and percent_return in tests; keep requests small. The free browser path uses the same pure module as the API, so demo landings and production automation never drift. This tool does not fetch live quotes, support multi-leg options, average cost over partial fills, or report wash-sale adjustments—only the closed-form cash P&L and percent return for one buy and one sell with optional commissions.
Integration use cases
Fee impact what-ifs
Hold prices fixed and vary buy_commission or sell_commission to show how ticket fees change net P&L on small lots.
Technical questions
How do I calculate stock profit or loss with commissions?
Send buy_price, sell_price, and shares (all required). Optionally set buy_commission and sell_commission (default 0). Net profit is (sell_price×shares − sell_commission) − (buy_price×shares + buy_commission).
How is percent return defined?
percent_return is net_profit divided by total_cost times 100. total_cost includes buy-side commission so the return reflects capital and opening fees tied up in the trade.
What does the outcome field mean?
outcome is profit when net_profit is positive, loss when negative, and breakeven when net is zero after half-up rounding at the chosen decimals.
Can sell_price be zero?
Yes. sell_price may be zero (total loss of the equity leg). buy_price and shares must still be greater than zero so total cost is positive.
What does the stock profit loss calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.