Days to Expiry — Options Portfolio Tracker logo
Days to Expiry
Options Portfolio Clarity
July 17, 2026Updated 3 days ago

Stock Sale Tax Calculator: Compute Your Capital Gains Tax Step by Step (2026)

Stock sale tax calculator: work out exactly how much tax you owe on a stock sale with the real formula, short-term vs long-term rates, NIIT, and a worked example with actual dollar figures.

Stock Sale Tax Calculator: The Exact Math Behind Your Capital Gains Bill

The tax on a stock sale is (sale proceeds − adjusted cost basis) × your capital gains rate, and the rate hinges on two things an online calculator can only handle if you feed it correctly: how long you held the shares and which specific lots you sold. Held one year or less, gains are taxed as ordinary income at 10%–37%. Held longer, they drop to 0%, 15%, or 20% — plus a 3.8% surtax for high earners. Below is the full calculation, worked through with real numbers, including the adjustments (wash sales, assigned options, reinvested dividends) that make your broker's 1099-B differ from what you expected.

This is the same math we apply when tracking premium-selling portfolios — as an active options trader, most of my stock sales come from covered calls and put assignments, where the basis is never just "what I paid."

Step 1: Start With Proceeds and Cost Basis

Every stock sale tax calculation reduces to this:

  • Proceeds = sale price × shares sold − commissions/fees
  • Adjusted cost basis = what you paid × shares + commissions, then adjusted for wash sales, reinvested dividends, splits, and option premiums folded in on assignment
  • Gain or loss = proceeds − adjusted cost basis

The word "adjusted" is where people go wrong. Your basis is not always the number on the trade confirmation:

  • Reinvested dividends add new lots at each reinvestment price — selling the whole position means adding up every lot.
  • A wash sale disallows your loss and adds it to the basis of the replacement shares. Run the wash sale calculator first if you repurchased within 30 days.
  • Put assignment sets your basis at strike price − premium collected, not the strike itself.
  • Covered call assignment adds the call premium to your proceeds, not your basis — see the covered call tax rules for that direction.

Step 2: Determine the Holding Period

The one-year line is the single biggest lever in the whole calculation. The holding period starts the day after you acquire the shares and includes the day you sell. One year plus one day is long-term; one year exactly is short-term.

Two traps specific to option sellers:

  • Shares acquired by put assignment start their holding period the day after assignment — the weeks or months you held the short put do not count.
  • Shares called away by a covered call keep the stock's own holding period, but a deep in-the-money call can suspend your holding period as a "qualified covered call" exception fails — rare, but it exists.

Step 3: Apply the Correct Rate

Holding periodTax treatmentFederal rate
1 year or lessShort-term — taxed as ordinary income10%–37% (your marginal bracket)
More than 1 yearLong-term capital gains0%, 15%, or 20% by taxable income
High earner, either+ Net investment income tax+3.8% above $200k single / $250k married filing jointly (MAGI)

The NIIT thresholds are fixed in statute and not inflation-adjusted — a fact worth knowing because more filers cross them every year. State tax stacks on top: most states tax capital gains as ordinary income, and nine states have no income tax at all.

Worked Example: Same Sale, $1,280 Difference

Say you bought 300 shares of a stock at $48 on March 3, 2025, and sold all 300 at $62.50 on March 10, 2026 — 372 days later, so the gain is long-term. No commissions.

  • Proceeds: 300 × $62.50 = $18,750
  • Basis: 300 × $48 = $14,400
  • Gain: $4,350, long-term

You're a single filer comfortably in the 15% long-term bracket: $4,350 × 15% = $652.50 federal tax.

Now the counterfactual: sell on February 27, 2026 instead — 361 days, short-term. Same prices, same gain, but it lands in your 24% ordinary bracket: $4,350 × 24% = $1,044. Waiting nine extra trading days saved $391.50 — a 37.5% lower bill on an identical sale.

Scale that up and the lever gets serious. On a $50,000 gain, the spread between 24% short-term and 15% long-term is $4,500, before NIIT and state. This is why every sale in my journal gets a "days held" column before it gets a sell order — a trading journal that tracks acquisition dates per lot pays for itself at tax time.

When Your Basis Isn't What You Paid: The Options-Seller Case

Generic stock sale tax calculators assume basis = purchase price. If you run the wheel or sell premium, that assumption breaks on day one.

Put assignment example. You sold a $45 put for $1.30 and got assigned. Your basis in the 100 shares is $4,370 ($4,500 − $130 premium), and your holding clock starts the day after assignment. Sell at $50 ten months later: proceeds $5,000, gain $630 — all short-term, including the embedded premium, because the shares themselves are under a year old. The complete options tax guide covers the assignment mechanics in full; how stock options are taxed walks every event type.

Covered call assignment example. You bought shares at $48, sold a $55 call for $2.00, and the shares get called away. Proceeds are $5,700 ($5,500 strike + $200 premium), basis $4,800, gain $900 — long-term if the shares themselves were held over a year.

If your broker's 1099-B doesn't match your records after assignments and rolls, reconcile it before filing — the 1099-B IB walkthrough shows where broker adjustments diverge from reality, and the IB tax statement guide covers the statement layout.

Choosing Which Lots to Sell: FIFO vs Specific ID

When you bought shares at different prices, which shares you sell changes the tax. Brokers default to FIFO (first in, first out), which usually forces the oldest — lowest-basis, most-likely-long-term — lots first. That's often fine for the rate but terrible for the size of the gain.

MethodWhat gets soldWhen it's the right call
FIFO (default)Oldest lots firstSmall positions, one or two lots, simplicity
Specific identificationYou name the lots at sale timeHarvesting losses, dumping high-basis lots, managing bracket thresholds
Highest cost (HIFO)Highest-basis lots firstMinimizing current-year gains systematically

Say you hold 100 shares bought at $40 (14 months ago) and 100 at $58 (4 months ago), price now $60. Sell 100 FIFO: $2,000 long-term gain ≈ $300 at 15%. Sell the $58 lot by specific ID: $200 short-term gain ≈ $48 at 24%. Same 100 shares out the door, $252 less tax. Specific ID must be communicated to your broker at the time of sale — you cannot re-designate lots after settlement.

Netting: Losses Reduce the Bill

Capital losses offset capital gains dollar for dollar, short-term against short-term first and long-term against long-term, then across categories. If losses exceed gains, up to $3,000 per year offsets ordinary income, and the remainder carries forward indefinitely. A $12,000 realized loss against $9,000 of gains wipes out the gains and deducts $3,000 against your salary.

One caution: harvesting a loss and repurchasing the same or a substantially identical security within 30 days either direction triggers the wash sale rules, disallowing the loss. Options count — buying a call on the same stock inside the window can wash the loss on the shares.

If you sell options on indexes rather than individual stocks, note that SPX and friends are Section 1256 contracts with a 60/40 blended rate and no wash sale exposure — a different calculator entirely, covered in SPX Section 1256 tax treatment. For option-specific math, use the options tax calculator rather than the stock formula above.

Frequently Asked Questions

Do I owe tax on a stock sale in an IRA or 401(k)?

No. Sales inside tax-advantaged accounts are not taxable events — no capital gains, no wash sales, no reporting. Tax applies only on withdrawal (traditional) or never (qualified Roth distributions). The calculator above applies to taxable brokerage accounts only.

What if I sell at a loss?

You owe nothing on that sale, and the loss offsets other capital gains, then up to $3,000 of ordinary income, with the rest carried forward. Check the 61-day wash sale window before re-entering the position or your loss gets disallowed and deferred.

Does my broker calculate this for me?

Partially. Your 1099-B reports proceeds and (for covered securities) basis, but brokers can't see across accounts — move brokers mid-year, and lot-level basis can arrive wrong or missing. Wash sales across two different brokers are never caught. Your own records are the source of truth.

Are dividends from the stock taxed at sale?

No — dividends are taxed in the year received (qualified dividends at long-term capital gains rates, non-qualified as ordinary income), completely separate from the gain on the share sale. Reinvested dividends create their own lots and do factor into basis when you eventually sell.

When is the tax due?

Capital gains are reported on Schedule D with your annual return, but large sales can create an underpayment penalty if you wait until April. If a single sale generates a five-figure gain, run the numbers the same week and make a quarterly estimated payment for that quarter.

Related Articles

Frequently Asked Questions

Written by Days to Expiry Trading Team

Options Strategy SpecialistTax Compliance Advisor

The Days to Expiry trading team brings together experienced options traders and financial analysts dedicated to helping investors generate consistent income through proven options strategies.

Apply The Tax Framework

Review the trade history behind the rule.

Assignments and exits
Broker data in context
Tax review workflow