🧰 UtlKit

How to Calculate Stock Profit: Cost Is Price Times Shares Plus Buy Commission, Revenue Is Price Times Shares Minus Sell Commission, Tax Applies Only to a Positive Gross, and the Annualized Figure Raises One Plus the Net Return to 365 over Holding Days

Walk through the Stock Profit Calculator with its exact behaviors: cost and revenue netting, the commission added on the way in and subtracted on the way out, tax that only applies when the gross is positive, the percent return measured against total cost, and the annualized line that reads zero while holding days is empty.

The Stock Profit Calculator answers one question about a single stock trade: after commission and tax, how much money is actually left? You enter the buy price, the sell price, the number of shares, optional holding days, the two commissions, and a tax rate, you press Calculate, and the page shows total cost, total revenue, gross profit, tax, net profit, percent return, and annualized return. It runs in your browser: the arithmetic is pure client-side JavaScript and no price or position data is sent to a server.

Seven fields, three required

Three fields must be filled before anything appears: buy price, sell price, and share count. Pressing Calculate with any of them empty, or with shares at zero or less, shows nothing at all. There is no error message and no red state. The result section simply does not appear, and whatever was on screen before stays. The other four fields are optional. Holding days, buy commission, sell commission, and tax rate each fall back to zero when left blank, so a minimal three-field run still produces a full seven-line result.

How cost and revenue are computed

Total cost is buy price times shares plus buy commission. Total revenue is sell price times shares minus sell commission. The asymmetry is deliberate: the fee you pay to enter the trade is added to what the position cost, and the fee you pay to exit is subtracted from what the position returned. Gross profit is then simply revenue minus cost. In a worked example, buying 100 shares at 100.00 with a 5.00 buy commission and selling at 110.00 with a 5.00 sell commission gives a total cost of 10,005.00, a total revenue of 10,995.00, and a gross profit of 990.00.

When the tax line applies

Tax is charged only when the gross profit is positive. The tool multiplies the gross by the tax rate you enter, as a percentage, and subtracts the product from the gross to get net profit. If the gross is zero or negative, the tax line is exactly 0.00, whatever rate you typed, and the net profit equals the gross. A flat trade still loses money through fees: buying and selling 100 shares at 100.00 with a 10.00 buy commission and a 5.00 sell commission produces a gross of minus 15.00, a tax of 0.00, and a net of minus 15.00. The percent return on that total cost is about minus 0.15 percent.

Percent return and annualized return

The percent return is net profit divided by total cost, times 100, so it measures the trade against everything you actually put in, commissions included. The annualized return takes one plus that same net-over-cost ratio, raises it to the power of 365 divided by holding days, and subtracts one. In the worked example, a 30-day hold turns the 7.92 percent net return into an annualized figure of about 152.67 percent, which is the point of the metric: it makes a two-week trade comparable to a two-year position. If you leave holding days blank, the annualized line reads 0.00 percent by design, because the exponent is undefined without a holding period. A trade that loses its entire cost, a sell price of zero, shows minus 100 percent on both lines.

What you can copy out

When a result exists, the copy button puts all seven lines on your clipboard as plain text, each line a field name followed by a colon and the formatted value, like netProfit: 792.00. Values are formatted with thousands separators and exactly two decimals. The four profit-oriented lines, gross profit, net profit, percent return, and annualized, are colored green when they are zero or above and red when negative, so a losing trade is visible at a glance before you read the numbers.

What is not here, and where to go next

The tool is deliberately narrow: one buy price, one sell price, one position, no portfolio and no cost basis per lot. If you want to size the position so a stop loss risks a fixed percentage of the account, the Position Sizing tool starts from the risk you can afford. If the trade is in crypto rather than a listed stock, the Crypto Tax Calculator applies short and long term rates to each transaction separately, and if the question is what the whole balance sheet looks like after the trade, the Net Worth Calculator tracks the assets side. The position sizing walkthrough pairs with this one: it decides how many shares to buy, and this one prices what the trade was worth once it is closed.

Related Tools

Frequently Asked Questions

Are the commissions part of the calculation?

Yes, both of them. The buy commission is added to total cost, and the sell commission is subtracted from total revenue, so the gross already has both fees taken out before any tax is applied. Leaving either one blank is treated as a zero fee, and the line still appears in the result.

What happens when the trade is a loss?

The tax line becomes exactly 0.00, because tax is only charged on a positive gross profit. Net profit then equals the gross, the percent return is negative, and the profit lines turn red. A loss is never taxed in this tool.

Why does the annualized return show 0.00 percent?

Because holding days is blank or zero. The annualized figure is one plus the net return raised to the power of 365 over the days, and with no holding period the tool reports zero instead of guessing. Enter the days from buy to sell to see the real number.

Can I use fractional shares?

Yes. The share field accepts any positive number, including fractions, because the only checks are that it parses as a number and that it is greater than zero. There is no whole-number requirement anywhere in the calculation.

Is my trade data sent to a server?

No. All the arithmetic runs in your browser from the code bundled with the page. Prices, share counts, commissions, and the result stay on your machine, and nothing is stored between visits.

Related Articles