ForHosting KIT · Finance & money

Stock profit calculator

Buying 100 shares at 50 and selling at 65 with 9.95 in fees leaves a net gain of 1,490.05, a return of 29.7418% on the cash you put in. Enter your fills and see profit, loss or break-even after commission. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Buy price
50
Sell price
65
Shares
100
Commission
9.95
You get
Cost basis
5,000
Proceeds
6,500
Gross gain
1,500
Net gain
1,490.05

A completed stock round trip is four numbers: the price you paid per share, the price you received per share, how many shares actually filled, and what you paid the broker in commission fees. This stock profit calculator turns those four inputs into net gain and return percentage, plus a profit, loss, or break-even outcome after fees. Gross proceeds equal sell price times share count; cost basis equals buy price times share count; net gain subtracts the round-trip commission from that difference. Return percent divides net gain by cash at risk — cost basis plus commission — so a fixed ticket charge hurts a small lot more than a large one at the same prices. Share count must be greater than zero: a zero lot is not a trade and fails as invalid input instead of a hollow zero-dollar success.

How net gain and return percent are computed after commissions

A stock trade that you have already closed has a cash story that a mark-to-market snapshot cannot tell. You paid a buy price, you later received a sell price, a number of shares changed hands, and the broker charged commission fees on the way in, the way out, or both. Cost basis is share count times buy price: that is the cash you spent on the shares themselves.

Proceeds are share count times sell price: that is the cash the sale returned before fees. Gross gain is proceeds minus cost basis, which is also share count times the per-share move. Net gain subtracts the total round-trip commission from gross gain, so a winning price move can still be a losing trade once ticket charges are included, and a small loss on price can become a larger loss after the same ticket.

Return percentage is net gain divided by invested cash, times one hundred. When commission is zero the percent collapses to the familiar price return, sell minus buy over buy, independent of lot size. When commission is a fixed dollar ticket, a one-hundred-share fill and a ten-share fill at the same prices no longer share a return, because the fee is a larger fraction of the small lot.

Money totals are rounded half-up to two decimal places, matching cents on a dollar-denominated confirmation. Return percent is rounded half-up to four decimal places so a few cents of fee still show on a large position. A rounded net gain above zero is a profit, below zero is a loss, and exactly zero is break-even.

Where a stock profit calculator earns its keep

Trade journals and blotter exports often store fills without computing the fee-adjusted return that a human actually felt. Dropping buy price, sell price, share count, and combined commissions into this calculator produces a net gain you can paste next to the ticket, and a percent you can compare across names that traded in different lot sizes.

Educators teaching realized versus unrealized P&L can seed classroom examples that show how a two-dollar ticket turns a scratch into a loss on ten shares but barely moves a thousand-share fill at the same prices, without standing up a brokerage sandbox. Failed validation does not consume balance. Keep share count positive, pin the rounded money fields in tests, and you get reproducible stock P&L for widgets, LMS modules, and edge workers without a market-data feed of your own.

The contract is deliberately small: four numbers in, net gain and return out, so clients can wrap it in their own symbol pickers and statement parsers without fighting hidden state.

Journal a closed round trip

Enter the buy fill, the sell fill, how many shares, and the combined broker fees to record net gain and return percent next to the ticket in a trade log.

See how a fixed commission hits a small lot

Compare the same prices at ten shares versus two hundred shares to show students or clients why a ticket charge changes percent return when the lot is small.

Pre-check realized P&L before a worksheet

Run one closed trade through the calculator before pasting figures into a spreadsheet so cost basis, proceeds, and net gain agree with the confirmation.

How is net gain calculated on a stock trade?

Gross gain is the price move times the lot; round-trip commission fees are then subtracted so the result is cash after the broker.

How is the return percentage calculated?

When commission is zero this equals the familiar price return (sell − buy) / buy × 100.

What happens if share count is zero?

A zero lot is not a trade, so the calculator rejects it instead of returning a hollow zero-dollar success. Those failures are not billed.

Are buy and sell commissions both included?

Pass the combined round-trip amount in commission (buy ticket plus sell ticket, plus any flat fees you want in the P&L). Use zero when the fills were fee-free. The field cannot be negative.

Why does a small lot show a lower return at the same prices?

Because a fixed commission is a bigger share of a small purchase. Return divides net gain by the cash at risk, including fees, so 10 shares and 100 shares only match when no commission was paid.

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.

POSThttps://api.kit.forhosting.com/fin/stock

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.

curl -X POST https://api.kit.forhosting.com/fin/stock \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"buy_price":50,"sell_price":65,"shares":100,"commission":9.95}'
{
  "buy_price": 50,
  "sell_price": 65,
  "shares": 100,
  "commission": 9.95
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "fin.stock",
  "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.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

How net gain and return percent are computed after commissions

Invested cash is cost basis plus commission: you wired the purchase and you paid the broker, so both belong in the denominator of a realized return.

Input contract, response shape, and error behaviour

If share count is zero the task fails with a message that share count is zero — that is the contract error, and those failures are not billed. A negative share count is also rejected. Commission cannot be negative; pass zero when the round trip was fee-free. Example: one hundred shares bought at fifty and sold at sixty-five with nine dollars and ninety-five cents of fees yield cost basis five thousand, proceeds six thousand five hundred, gross gain one thousand five hundred, net gain one thousand four hundred ninety dollars and five cents, and a return of about twenty-nine point seven four percent. POST a JSON body with four required finite numbers: buy_price (strictly greater than zero; aliases purchase_price, cost_per_share), sell_price (greater than or equal to zero; aliases sale_price, exit_price), shares (strictly greater than zero; aliases share_count, qty, quantity), and commission (greater than or equal to zero; aliases commissions, fees, commission_fees, total_commission). Each field may arrive as a JSON number or as a numeric string. Missing fields, empty strings, and non-finite values fail with invalid_input naming the field. If sell_price is negative the request fails because a fill cannot be negative in this model; a sell price of zero is allowed and means the position's market value was wiped out. Share counts above one trillion, prices above one billion, or commissions above one trillion are rejected as overflow guards so a typo cannot produce a non-finite JSON number. On success the body echoes the four inputs and returns cost_basis, proceeds, gross_gain, net_gain, return_percent, an outcome of profit, loss, or break_even, and a formula string restating the identities. Pair the result with your own tax-lot engine if you need wash-sale matching or holding-period lots; this endpoint values one round trip from four numbers only and does not emit tickers, charts, or tax forms.

Where a stock profit calculator earns its keep

Spreadsheet users who already track lots can call the same pure module from the browser for a free preview and from the API when storing scenarios, so the number a reader saw on a landing page matches the number stored after they save a close.

What does the stock profit calculator cost?

The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.

Read the full KIT documentation →