# Stock Profit Calculator

> Computes the profit or loss on a share trade from buy and sell prices, number of shares, commissions on each side and an optional capital-gains tax rate, with the percentage return on the total cost and the sell price needed to break even.

- Calculator id: `stock-profit` · Category: Finance (`finance`) · Tool name: `calculate_stock_profit`
- Canonical page: https://tttkmbb.com/finance/stock-profit · This document: https://tttkmbb.com/finance/stock-profit.md · JSON definition: https://tttkmbb.com/finance/stock-profit.json

## Purpose

Computes the profit or loss on a share trade from buy and sell prices, number of shares, commissions on each side and an optional capital-gains tax rate, with the percentage return on the total cost and the sell price needed to break even.

**Use when:** You want to know what you made (or lost) on a stock sale after fees and tax, or the price at which a position becomes profitable.

**Do not use when:** You want dividend income or reinvestment (use dividend-yield), an annualized return over the holding period (use roi or cagr), or tax lots with different purchase dates.

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `buy_price` | number |  | required | Purchase price per share. (> 0, max 10000000) |
| `sell_price` | number |  | required | Sale price per share. (min 0, max 10000000) |
| `shares` | number |  | required | Shares bought and sold (fractional allowed). (> 0, max 1000000000000) |
| `buy_commission` | number |  | optional, default 0 | Fees paid on the purchase. (min 0, max 10000000) |
| `sell_commission` | number |  | optional, default 0 | Fees paid on the sale. (min 0, max 10000000) |
| `capital_gains_tax_percent` | number | % | optional, default 0 | Tax rate applied to a positive net gain (0 for none; losses are not taxed). (min 0, max 100) |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `total_cost` | number |  | buy_price × shares + buy_commission. |
| `total_proceeds` | number |  | sell_price × shares − sell_commission. |
| `gross_profit` | number |  | (sell_price − buy_price) × shares, before commissions and tax. |
| `net_profit_before_tax` | number |  | total_proceeds − total_cost. |
| `capital_gains_tax` | number |  | max(0, net_profit_before_tax) × capital_gains_tax_percent / 100. |
| `net_profit` | number |  | net_profit_before_tax − capital_gains_tax. |
| `return_percent` | number | % | net_profit / total_cost × 100. |
| `break_even_sell_price` | number |  | (total_cost + sell_commission) / shares: the sale price at which net profit before tax is zero. |

## Formula

`total_cost = buy_price × shares + buy_commission; total_proceeds = sell_price × shares − sell_commission; net_before_tax = total_proceeds − total_cost; tax = max(0, net_before_tax) × capital_gains_tax_percent/100; net_profit = net_before_tax − tax; return = net_profit / total_cost × 100; break_even = (total_cost + sell_commission) / shares`

Single lot, no dividends, and a flat tax rate on the gain; actual capital-gains rules (holding period, allowances, loss offsets) vary by country.

## Data Sources

- IRS – Topic no. 409, Capital gains and losses — https://www.irs.gov/taxtopics/tc409 (government, retrieved 2026-09-24)
- Investopedia – Capital Gains Tax: What It Is, How It Works and Current Rates — https://www.investopedia.com/terms/c/capital_gains_tax.asp (reference, retrieved 2026-09-24)
- Wikipedia – Rate of return — https://en.wikipedia.org/wiki/Rate_of_return (reference, retrieved 2026-09-24)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/stock-profit?buy_price=…&sell_price=…&shares=…`
- `POST https://tttkmbb.com/api/v1/calculate/stock-profit` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/stock-profit · OpenAPI operationId `calculate_stock_profit` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "stock-profit", "inputs": {…}}`

## Example

- 100 shares bought at 50, sold at 60, 10 commission each way, 15 % tax: inputs `{"buy_price":50,"sell_price":60,"shares":100,"buy_commission":10,"sell_commission":10,"capital_gains_tax_percent":15}` → `{"total_cost":5010,"total_proceeds":5990,"gross_profit":1000,"net_profit_before_tax":980,"capital_gains_tax":147,"net_profit":833,"return_percent":16.63,"break_even_sell_price":50.2}`
- 50 shares bought at 120, sold at 100, no fees: inputs `{"buy_price":120,"sell_price":100,"shares":50}` → `{"total_cost":6000,"total_proceeds":5000,"gross_profit":-1000,"capital_gains_tax":0,"net_profit":-1000,"return_percent":-16.67,"break_even_sell_price":120}`

```
GET https://tttkmbb.com/api/v1/calculate/stock-profit?buy_price=50&sell_price=60&shares=100&buy_commission=10&sell_commission=10&capital_gains_tax_percent=15
```

## Limitations

You want dividend income or reinvestment (use dividend-yield), an annualized return over the holding period (use roi or cagr), or tax lots with different purchase dates. Single lot, no dividends, and a flat tax rate on the gain; actual capital-gains rules (holding period, allowances, loss offsets) vary by country. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Why is the break-even price above the buy price?**

Commissions on both sides must be recovered: with 10 paid to buy and 10 to sell 100 shares bought at 50, the shares must sell at 50.20 just to get the money back.

**Which tax rate applies?**

In the US, assets held over a year are taxed at long-term rates (0, 15 or 20 % in 2024–2025 depending on income) and shorter holdings at ordinary income rates; other countries have their own rates and allowances.

## Related

- [ROI Calculator](https://tttkmbb.com/finance/roi.md) — Annualized return over the holding period.
- [Percentage Change Calculator](https://tttkmbb.com/math/percentage-change.md) — Percent change between the two prices.
- [Dividend Yield Calculator](https://tttkmbb.com/finance/dividend-yield.md) — Income from the shares while held.
