HomeFinance › Stock Profit Calculator

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.

When to use

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.

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.

Inputs

ParameterTypeUnitRequiredDescription
buy_pricenumberyesPurchase price per share. Range: > 0, ≤ 10000000
sell_pricenumberyesSale price per share. Range: ≥ 0, ≤ 10000000
sharesnumberyesShares bought and sold (fractional allowed). Range: > 0, ≤ 1000000000000
buy_commissionnumberdefault 0Fees paid on the purchase. Range: ≥ 0, ≤ 10000000
sell_commissionnumberdefault 0Fees paid on the sale. Range: ≥ 0, ≤ 10000000
capital_gains_tax_percentnumber%default 0Tax rate applied to a positive net gain (0 for none; losses are not taxed). Range: ≥ 0, ≤ 100

Outputs

OutputTypeUnitDescription
total_costnumberbuy_price × shares + buy_commission.
total_proceedsnumbersell_price × shares − sell_commission.
gross_profitnumber(sell_price − buy_price) × shares, before commissions and tax.
net_profit_before_taxnumbertotal_proceeds − total_cost.
capital_gains_taxnumbermax(0, net_profit_before_tax) × capital_gains_tax_percent / 100.
net_profitnumbernet_profit_before_tax − capital_gains_tax.
return_percentnumber%net_profit / total_cost × 100.
break_even_sell_pricenumber(total_cost + sell_commission) / shares: the sale price at which net profit before tax is zero.

Example

100 shares bought at 50, sold at 60, 10 commission each way, 15 % tax: {"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: {"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

Machine access

Sources

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 calculators