What this calculator does
Find out how much money a stock trade really made or lost, after fees and dividends. It looks simple: sell price minus buy price. Then commissions, dividends and how long you held the shares come in.
This calculator puts all of them together. It finds the cost basis, which is everything you paid for the shares. It finds the net amount the sale brings in, and the profit or loss in dollars. And it gives the return as a percentage of what you put in.
Add the dividends (cash payments the company made to shareholders) you collected. Then you'll see your total return for the time you held the shares, not just the price gain. Add how long you held the shares to turn the return into a yearly (annualized) figure. You can compare that with other investments. The break-even sell price tells you what the shares need to sell for so you come out even after costs.
Where it's used
Why this math matters outside the classroom:
- Personal investing. An investor who bought 100 shares at $50 and sold at $65 finds a $1,500 gain, a 30% return on $5,000.
- Math class projects. Students track a pretend portfolio and compute each stock's percent gain or loss from its purchase price.
- Checking a sale price. A seller works out the break-even price that covers both commissions before placing a sell order.
- Comparing trades. Annualizing a 10% gain over six months gives 21% a year, which can be compared with a full-year return.
- Investment clubs. Club members total each position's price gain plus dividends to report the year's holding-period returns.
Grade level and standards: Grade 7; Common Core State Standards for Mathematics 7.RP.A.3, 7.EE.B.3. © Copyright 2010. National Governors Association Center for Best Practices and Council of Chief State School Officers. All rights reserved.
How to use it
- Enter the number of shares and the price per share you paid and sold at.
- If you have them, enter the commissions or fees paid on each side of the trade. Add any dividends received while you held the shares.
- To get a yearly return, enter how long you held the shares in years (for example, 0.5 for six months).
- Read the profit or loss, the return on cost and the break-even sell price. Follow the steps to see how each is found.
What the inputs mean
- Number of shares
- The number of shares bought and later sold. Fractional shares work the same way.
- Commission or fees to buy
- Commissions, transaction fees or other costs of buying. They're added to the cost basis.
- Commission or fees to sell
- Commissions and fees on the sale, which reduce what you receive.
- Dividends received while held
- Cash dividends received on these shares while you held them. They count toward your total return even though they aren't part of the sale.
- Holding period
- How long you held the shares. It's used only for the annualized return. Leave it blank to skip it.
Formula and method
cost basis = shares × buy price + buying fees net proceeds = shares × sell price − selling fees profit = net proceeds − cost basis + dividends return = profit ÷ cost basis × 100 annualized return = (1 + return)^(1 ÷ years) − 1 break-even sell price = (cost basis + selling fees − dividends) ÷ shares
In the annualized formula, return is written as a decimal (31% is 0.31), and years is how long you held the shares.
The cost basis is everything you paid to own the shares. Net proceeds are what reaches you after the sale. The difference, plus any dividends, is your total gain or loss before tax. Divide it by the cost basis to get the holding-period return, your return for the whole time you held the shares.
The annualized return spreads that total return evenly across the years held. It allows for compounding, where each year's gain builds on the last. That way a 31% gain over 18 months and a 20% gain over one year can be compared fairly. The break-even price is the sell price at which the profit would be exactly zero.
Worked example
You buy 100 shares at $50 with a $4.95 commission, collect $80 in dividends, and sell 18 months later at $65, paying another $4.95.
- Cost basis: 100 × $50 + $4.95 = $5,004.95.
- Net proceeds: 100 × $65 − $4.95 = $6,495.05.
- Profit: $6,495.05 − $5,004.95 + $80 = $1,570.10, of which $1,490.10 came from the price rise.
- Return: $1,570.10 ÷ $5,004.95 × 100 = 31.37%.
- Annualized over 1.5 years: 1.3137^(1 ÷ 1.5) − 1 ≈ 19.95% a year.
- Break-even sell price: ($5,004.95 + $4.95 − $80) ÷ 100 = $49.30.
Result: The trade made $1,570.10, a 31.37% return, or about 19.95% a year.
Understanding the result
A positive result is a gain, and a negative one is a loss, both before tax. The return on cost lets you compare trades of different sizes. The annualized return lets you compare trades held for different lengths of time.
Sometimes the break-even price is below your buy price, as in the example. That means dividends have more than covered your fees. When fees are large compared with the trade, the break-even price can sit well above what you paid.
Assumptions and limitations
- All shares are bought at one price and sold at one price. For several purchases at different prices, use the dollar-cost averaging calculator to find the average cost first.
- Dividends are counted as cash received, not used to buy more shares.
- Results are before any tax on gains or dividends.
- Taxes aren't included. Use the capital gains tax calculator to estimate tax on the gain.
- Short sales, options, margin interest, stock splits and currency conversion aren't modeled.
- This is an educational calculation, not investment advice.
Frequently asked questions
Should I include dividends in my profit?
Yes, if you want your total return. Dividends are part of what the investment paid you. Leaving them out shows only the price gain. That makes the return on dividend-paying stocks look smaller than it really is.
What is a holding-period return?
It's the total return over the whole time you owned an investment: price change plus income, divided by what you paid. It doesn't take into account how long you held it. That's why the annualized return is useful for comparisons.
Why does my broker show a different gain?
Brokers may report only the price gain, leave dividends out, or use an average cost across several purchases. Some also show unrealized gains, meaning gains on paper for shares you still hold. Match the inputs to what your broker includes, so you compare like with like.
How do I enter a trade I held for a few months?
Enter the holding period as a fraction of a year: 3 months is 0.25, and 9 months is 0.75. Annualizing a short holding can give a large figure. That's because it assumes the same pace keeps going for a full year.
How this calculator is checked
Method: Standard definitions of cost basis, net proceeds, holding-period return (price change plus income over cost) and compound annualization. The calculation is covered by automated tests with known reference values and edge cases. Last updated 2026-10-18. Found a problem? Tell us.
Embed this calculator
Put this Stock Profit Calculator on your own website or blog for free. Paste this code where you want it to appear: