Skip to content
insiderbid
CalculatorCalculators & Tools

Stock Cost Basis & Capital Gains Calculator

Work out the cost basis, gain or loss, return, and short- vs long-term holding period for a stock sale. Commissions folded in the way the IRS treats them.

The InsiderBid Team3 min read

The arithmetic of a stock sale is simple and easy to get slightly wrong — usually by forgetting commissions, or by miscounting the holding period around the one-year line.

Cost basis
$2,415.00
Proceeds
$3,140.00
Capital gain
$725.00
+30.0%
Held 2y 29d — long-term

General rule only. Long-term means held more than one year. Wash-sale disallowance, inherited or gifted lots, and specific-lot vs average-cost accounting all change the result. Not tax advice.

How the numbers work

Cost basis is the total you paid to acquire the shares: shares times purchase price, plus the commission on the buy. Commissions increase your basis, which reduces your taxable gain.

Proceeds are what you received: shares times sale price, minus the commission on the sell.

Gain or loss is proceeds minus basis. A positive number is a capital gain; a negative one is a capital loss, which can offset other gains and, up to a limit, ordinary income.

Holding period decides the tax rate. One year or less from purchase is short-term, taxed as ordinary income. More than one year is long-term, taxed at the lower capital-gains rates. The clock starts the day after you buy and runs through the sale date, so a purchase on 1 February one year and a sale on 2 February the next is long-term by a day.

What this does not cover

  • Wash sales. Realising a loss and rebuying substantially identical shares within 30 days (either side) disallows the loss for now and rolls it into the basis of the new shares.
  • Multiple lots. If you accumulated a position over time, each purchase is its own lot with its own basis and holding period. Which lots you are deemed to sell (FIFO, specific identification, average cost for funds) changes the result.
  • Inherited and gifted shares. Inherited shares generally get a stepped-up basis to the value at the date of death; gifted shares usually carry the donor's basis.
  • State tax, the net investment income tax, and anything specific to your situation.

This is a general-case calculator, not tax advice. For anything with lots, losses near the 30-day boundary, or an inheritance, check with a tax professional.

The short version

Basis is price paid plus buy commission; proceeds are price received minus sell commission; gain is the difference. Hold more than a year — not exactly a year — for the long-term rate. Wash sales, multiple lots and inherited shares each break the simple formula.

Related: how to read a Form 4, field by field · the Section 16 deadline calculator · is insider buying a bullish signal?

Common questions

How do you calculate cost basis for a stock sale?
Cost basis is what you paid for the shares plus any purchase commission. When you sell, the gain or loss is your sale proceeds (minus the sale commission) less that basis. If you bought in several lots at different prices, each lot has its own basis unless you use average-cost accounting for a fund.
What is the difference between short-term and long-term capital gains?
A holding period of one year or less produces a short-term gain, taxed at your ordinary income rate. More than one year is long-term, taxed at preferential rates (0%, 15% or 20% federally for most filers). The one-year line runs from the day after purchase to the sale date.
Does this calculator handle wash sales?
No. A wash sale — selling at a loss and buying substantially identical shares within 30 days before or after — disallows the loss and adds it to the basis of the replacement shares. Inherited and gifted lots also have special basis rules. This tool computes the general case.

The InsiderBid Team — We parse every SEC Form 4 as it is filed and write about what insider trading data actually shows — and what it does not.

Keep reading