Calculator

How stock profit is calculated, with commissions and dividends

The exact arithmetic behind the StockFly stock profit calculator: the cost with commission, what a sale brings in, the profit and percentage return, the break-even price, dividends while you held, the yearly rate, and why past prices are adjusted for splits.

The stock profit calculator takes the number of shares, the two prices and the two commissions, and tells you what the trade made. This page shows every step, so you can check the answer yourself.

Profit is what the sale brought in minus everything you paid, with the broker's commission counted on both sides.

The formulas

cost        = shares × buy price + buy commission
proceeds    = shares × sell price − sell commission
profit      = proceeds − cost
return      = profit ÷ cost
break-even  = (cost + sell commission) ÷ shares

The return is measured against everything you paid, commission included, because that is the money that was actually at risk. The break-even price is the sell price at which the profit is exactly zero: the sale has to cover the purchase, the buy commission and its own commission.

A worked example

100 shares bought at 50 with a 10 commission, sold at 60 with a 10 commission:

cost        = 100 × 50 + 10    = 5,010.00
proceeds    = 100 × 60 − 10    = 5,990.00
profit      = 5,990.00 − 5,010.00 = 980.00
return      = 980.00 ÷ 5,010.00   = 19.6%
break-even  = (5,010.00 + 10) ÷ 100 = 50.20

Dividends

When you pick the stock and the dates, the calculator also adds up the dividends paid while you held it: every dividend whose ex-date falls after the day you bought and on or before the day you sold. Those are the ones a shareholder is entitled to. They are shown on their own line, on top of the price gain, because they reached you as cash rather than as a higher share price.

If the trade above had been held for three years and paid 4.20 a share in dividends, that is 420.00 on 100 shares, so 1,400.00 in all, a 27.9% return. Dividends are counted before any tax withheld from them.

The yearly rate

For a holding kept a year or more, the total return is turned into the steady yearly rate that would have produced it:

yearly rate = (1 + total return) ^ (365 ÷ days held) − 1

For the three-year example (1,096 days), that is (1 + 27.9%) raised to the power 365 ÷ 1,096, minus 1: 8.6% a year. It is not shown for holdings under a year, where stretching a few months into a yearly figure gives a misleading number.

Where the prices come from, and splits

The filled-in prices are the closing prices on the two dates. A weekend or holiday uses the last close before it, which is the price a buyer could actually have got. Past prices are adjusted for later stock splits so they compare with today's shares: after a 4-for-1 split, a share bought at 400 shows as 100. The calculator says so when a split happened in between; enter your shares as you hold them today and the profit comes out the same.

This page explains the arithmetic. It is not tax advice, and the profit shown is before tax.

Track all of this automatically

StockFly does this for your whole portfolio, in any currency. Free to use, no credit card.

Rather look first? Open the live demo, no account needed.