> Quick Answer: Selling a position with an $18,000 unrealized loss can offset $12,000 of other capital gains and up to $3,000 of ordinary income, saving roughly $2,520 in taxes at a 15% capital-gains rate and a 24% ordinary bracket, but only if you avoid repurchasing a substantially identical security within the 61-day wash-sale window.
Overview
Tax-loss harvesting is the practice of deliberately selling an investment that has lost value in order to realize a capital loss that can offset capital gains, and to a limited extent ordinary income, elsewhere in your tax picture. It does not require you to actually believe the investment is a bad one going forward; the strategy is purely about timing the realization of a loss that has already happened on paper, converting an unrealized decline into a usable tax deduction while keeping your overall market exposure roughly intact by reinvesting the proceeds elsewhere.
The mechanics are governed by the capital loss ordering rules under the Internal Revenue Code. A realized loss first offsets capital gains realized in the same tax year, dollar for dollar, with no cap. If losses exceed gains, up to $3,000 of the excess ($1,500 if married filing separately) can offset ordinary income such as wages in that same year. Anything left over does not disappear; it carries forward to future tax years indefinitely under IRC Section 1212(b), available to offset future gains or future ordinary income under the same $3,000 annual limit.
The single biggest trap in tax-loss harvesting is the wash-sale rule under IRC Section 1091, which this calculator models explicitly. If you sell a security at a loss and then buy back a "substantially identical" security within a narrow window around the sale, the IRS disallows the loss for current-year tax purposes. Harvesting a loss only to immediately buy back the same position defeats the purpose from the IRS's perspective, since your economic position barely changed; the rule exists specifically to prevent that.
How This Is Calculated
Step 1: Realize the loss. Unrealized Loss = Cost Basis − Current Market Value.
Step 2: Check the wash-sale window. The window spans 30 calendar days before the sale, the day of the sale itself, and 30 calendar days after the sale, a 61-day span in total. If a repurchase of a substantially identical security falls anywhere in that window, the loss is disallowed for this year's taxes and is instead added to the cost basis of the replacement shares, effectively deferring the tax benefit rather than eliminating it.
Step 3: Allocate the allowed loss. If the loss is not disallowed, it first offsets other capital gains realized this year, dollar for dollar. Any remaining loss offsets up to $3,000 of ordinary income. Anything still remaining carries forward to future years.
Step 4: Compute tax savings. The portion of the loss offsetting capital gains saves tax at your marginal long-term capital gains rate (0%, 15%, or 20% under current law, based on where the top of your stacked ordinary income plus capital gains falls). The portion offsetting ordinary income saves tax at your marginal ordinary bracket, looked up from the 2026 federal bracket table.
$$\text{Tax Savings} = (\text{Loss Offsetting Gains} \times \text{LTCG Rate}) + (\text{Loss Offsetting Ordinary Income} \times \text{Marginal Ordinary Rate})$$
Worked Example
An investor holds a position with a $50,000 cost basis, now worth $32,000, an $18,000 unrealized loss. They have already realized $12,000 of other capital gains this year, have $150,000 of other taxable income, and file single.
Step 1: Unrealized Loss = $50,000 − $32,000 = $18,000.
Step 2: Assume no repurchase within the window, so the full loss is allowed.
Step 3: Gains offset = min($18,000, $12,000) = $12,000. Remaining loss = $6,000. Ordinary offset = min($6,000, $3,000) = $3,000. Carryforward = $3,000.
Step 4: $150,000 of taxable income falls in the 24% ordinary bracket. Stacked income of $150,000 + $12,000 = $162,000 falls in the 15% long-term capital gains tier. Tax savings = ($12,000 × 15%) + ($3,000 × 24%) = $1,800 + $720 = $2,520.
If, instead, the investor had repurchased the same security 15 days after the sale, the entire $18,000 loss would be disallowed this year under the wash-sale rule, producing $0 in current-year tax savings, with the $18,000 added to the cost basis of the replacement shares instead.
The 61-Day Wash-Sale Window, Explained
The wash-sale window is easy to miscount because it is not simply "30 days." It runs:
- 30 calendar days before the sale date, plus
- the sale date itself, plus
- 30 calendar days after the sale date
That totals 61 calendar days. The rule applies symmetrically: buying the replacement shares before the loss sale triggers the rule exactly the same way as buying them afterward, which surprises investors who assume only forward-looking repurchases count. It also applies across accounts, meaning a repurchase in a spouse's account, an IRA, or an automatic dividend reinvestment plan can all trigger a wash sale even though no single brokerage statement shows the full picture.
"Substantially identical" is not precisely defined by statute and is judged case by case; buying back the exact same stock or a fund that tracks the same index is squarely within the rule, while swapping into a different fund tracking a meaningfully different index or asset class is a common way advisors keep market exposure while avoiding the wash sale, though this calculator does not evaluate whether any specific substitute security counts as substantially identical.
What This Does Not Account For
This calculator estimates federal ordinary and long-term capital gains tax savings only; it does not include state income tax, which can meaningfully change the total benefit since most states tax capital gains as ordinary income without federal-style preferential rates. It assumes the loss is a long-term capital loss for the "gains offset" tax-rate calculation; short-term losses offsetting short-term gains would instead use the ordinary rate for that portion, and the loss-ordering rules that pair short-term losses against short-term gains first, then long-term against long-term, before crossing categories, are more granular than this simplified model. It does not account for the Net Investment Income Tax, alternative minimum tax interactions, state wash-sale conformity (most states follow the federal rule but a few do not), or the fact that a large disallowed wash-sale loss added to replacement-share basis only produces its tax benefit later, when those replacement shares are eventually sold at a gain or loss of their own.
Common Pitfalls
- Repurchasing too soon. The most common wash-sale trigger is simply buying back the same position within 30 days because the investor forgot the rule runs both backward and forward from the sale date.
- Triggering a wash sale through automatic reinvestment. Dividend reinvestment plans (DRIPs) that automatically repurchase shares of the same security can silently trigger a wash sale on a portion of the loss without the investor placing any manual trade.
- Overlooking cross-account repurchases. Buying the same or a substantially identical security in a spouse's account or a tax-advantaged account like an IRA still counts, even though the loss and the repurchase appear on entirely separate statements.
- Assuming the loss disappears. A wash sale defers the loss rather than destroying it; the disallowed amount is added to the replacement shares' cost basis, so the benefit eventually surfaces when those shares are sold.
- Forgetting the $3,000 ordinary-income cap. Large harvested losses well in excess of realized gains only offset a modest $3,000 of ordinary income per year; the rest carries forward, sometimes for many years, before it is fully used.
Frequently Asked Questions
What counts as a "substantially identical" security?▸
Does the wash-sale rule apply to gains, or only losses?▸
Can I harvest a loss and buy a similar, but not identical, investment right away?▸
What happens to a disallowed loss?▸
Is there a wash-sale rule for cryptocurrency?▸
Sources
- Internal Revenue Code, Section 1091 (wash sales of stock or securities).
- Internal Revenue Code, Section 1211(b) and Section 1212(b) (limitation on capital losses; capital loss carryovers).
- Internal Revenue Service, Publication 550, Investment Income and Expenses.
- IRS Revenue Procedure 2025-32 (Internal Revenue Bulletin 2025-45), 2026 inflation-adjusted federal income tax brackets and thresholds.