How to Calculate Tax Loss Harvesting in Plain Math
If you want to know how to calculate tax loss harvesting, here is the compressed answer: sum the realized losses across every tax lot you sell, subtract any disallowed wash-sale losses and add them to the replacement lot’s basis, net short-term versus long-term results using the IRS ordering rules, apply the $3,000 annual ordinary-income cap (or $1,500 if married filing separately), and carry the remainder forward. State tax codes may diverge from federal treatment, changing the real saving.
The break-even point depends on your marginal tax rate, transaction fees, and the size of the harvested loss. That 60-word summary is what I wish someone had handed me before my first harvest in 2019, when I accidentally omitted a dividend-reinvestment lot and under-reported my loss by $340.
Below, I walk through a real calculation with numbers from a portfolio I managed, including a wash-sale mistake that deferred a $4,200 deduction into an IRA where it became useless. You will see exactly how to handle multi-lot cost basis, specific-ID elections, and carryforward formulas.
What the Textbook Definition Misses About Real Portfolios
Most brokerage articles show a single lot purchase and sale. Real portfolios accumulate dozens of lots via auto-investing, dividend reinvestments, and rolling contributions, each with its own acquisition date and basis.
The thing nobody tells you about: your default accounting method—usually average cost for mutual funds but specific-ID for stocks—changes the math dramatically. Average cost smooths basis but hides tax-rate arbitrage; specific-ID lets you cherry-pick high-basis lots to harvest, but requires you to instruct the broker precisely at trade time.
I learned this when I assumed my broker used specific-ID, only to discover the default was average cost, blending a 2021 lot with a 2023 lot and shrinking my deductible loss by 40% on a $10,000 position.
Why Holding Period Clock Matters
The clock starts the day after you acquire the lot and ends on the sale date. A lot held 364 days is short-term; 366 days is long-term. Fractional days from dividend reinvestments on weekends can trip you up if you sell on the exact anniversary.
Brokers now track this automatically, but if you use specific-ID across multiple accounts, you must manually verify the dates. Misconception: transferring shares between brokers does not reset the clock, but some custodians mislabel the acquired date as the transfer date, creating false short-term status.
Specific-ID vs Average Cost Comparison
| Method | Best For | Calculation Complexity | Wash-Sale Risk |
|---|---|---|---|
| Specific-ID | Taxable accounts with many lots, seeking to isolate losses | High – must tag lots at sale | Lower if you avoid repurchase |
| Average Cost | Long-term mutual fund investors who never trade | Low – broker computes blend | Higher because whole position basis shifts |
For ETFs and stocks, always opt into specific-ID in your broker settings. For mutual funds, you can often switch, but verify with a 1099-B that reports lot detail. The IRS requires consistency once you elect a method for a security, per IRS Publication 550.
My First Wash-Sale Mistake: A $4,200 Lesson
In March 2022, I harvested a $6,000 loss on a tech ETF but bought a similar (not identical) fund in my IRA two days later. I thought the IRA purchase was safe because it was a different account and different ticker.
Wrong: the wash-sale rule looks at indirect ownership including IRAs, and the loss was disallowed on $4,200 of the sale because the replacement was substantially identical within 30 days. The IRS treats IRAs as related accounts under Publication 550.
The loss isn’t gone—it’s deferred into a basis that may never be deducted in a taxable account. That’s the wash-sale trap most calculators hide.
Most people don’t realize that a disallowed wash sale doesn’t kill the loss—it attaches to the new lot’s basis. So my IRA basis rose by $4,200, deferring the deduction until I sell that IRA lot, likely decades later and tax-free on withdrawal if Roth. That’s a terrible trade I made under time pressure.
The calculation adjustment is simple but easy to miss: subtract disallowed loss from the realized loss column, then add it to the replacement lot’s cost basis. If you ignore this, your spreadsheet will overstate the current-year deduction and invite an audit adjustment.
Step 1: Build the Multi-Lot Calculation Table
Open a spreadsheet or use our Tax Loss Harvesting Estimator to log each lot. Columns: security, lot date, acquired date, shares, cost basis per share, sale date, sale price, proceeds, realized loss = (sale price – basis)*shares, term (ST/LT).
For a realistic example, consider three lots of VTI purchased over two years:
- Lot A: 50 shares, bought 2023-02-01 at $200, sold 2023-11-15 at $180 → ST loss $1,000
- Lot B: 30 shares, bought 2022-01-10 at $220, sold 2023-11-15 at $180 → LT loss $1,200
- Lot C: 20 shares, bought 2023-08-01 at $210, sold 2023-11-15 at $180 → ST loss $600
Total realized loss before wash adjustment: $2,800 (ST $1,600, LT $1,200). This matches what a broker 1099-B would show if no wash occurred.
Retrieving Data From Broker Statements
Most brokers now provide a realized gain/loss report with lot-level detail. Export to CSV. Watch for corporate actions: a 2-for-1 split halves basis per share but doubles shares; if unadjusted, your loss calc breaks.
If you use dividend reinvestment, each drip creates a miniature lot. I once found 47 separate lots in a single fund because of weekly drips. You must include all or switch to average cost before sale.
Applying Wash-Sale Adjustments in the Math
Suppose you repurchase 40 shares of VTI in a taxable account on 2023-11-20 (within 30 days). The IRS treats the replacement as substantially identical. Allocate the disallowed loss proportionally: the repurchase covers 40/100 of the sold shares, so 40% of each lot’s loss is washed.
Disallowed: Lot A $400, Lot B $480, Lot C $240. Allowed loss: ST $960 ($1,600-$640), LT $720 ($1,200-$480). New basis in replacement lot increases by $1,120 total. This is the precise calculation competitors omit.
If the replacement is in an IRA, the disallowed amount is added to the IRA basis, but since IRA contributions are after-tax or pre-tax, the effect is a permanent deferral mismatch. The math is identical but the economic result differs.
Step 2: Netting Short-Term and Long-Term Losses
Federal rules require you to net losses within each category first, then cross-net. If total ST loss > ST gain, the excess offsets LT gain, and vice versa. In our example we have no gains, so we have net ST loss $960 and LT loss $720.
Per IRS Topic 409, you deduct up to $3,000 ($1,500 MFS) of total net capital loss against ordinary income. Our total net loss is $1,680, well under the cap, so the entire amount reduces taxable income this year.
Now consider a more complex case: you also sold a different stock for ST gain $500 and LT gain $300. Net ST = $960 loss – $500 gain = $460 ST loss. Net LT = $720 loss – $300 gain = $420 LT loss. Total net $880, still under cap.
If total exceeded $3,000, the excess carries forward indefinitely. The carryforward formula: CF_next = Max(0, TotalNetLoss – 3000) + PriorCF. You report this on Schedule D, and the carryforward retains its character (ST vs LT) for future netting.
Step 3: Calculate Loss Carryforward and State Tax Impact
Carryforward is not just a lump sum; the IRS preserves whether the excess was short-term or long-term. In year two, you net new gains against the carried ST first, then LT. This character preservation is a subtlety many spreadsheets flatten incorrectly.
Example: Year 1 net loss $5,000 ($2,000 ST, $3,000 LT). Cap uses $3,000, leaving $2,000 carry (assume allocated to LT for illustration). Year 2 you have $1,500 ST gain. You offset with $0 carried ST, pay tax on gain, then carry LT remains.
State tax divergence: California conforms to federal carryforward but requires a separate state Schedule D. New York also conforms but taxes carried losses at state rates. States with no income tax (e.g., Texas, Florida) give zero state benefit, so your federal saving is the whole story.
When I calculated for a client in CA, we found state carryforward could offset state ordinary income up to the same $3,000 cap. However, states like New Hampshire only tax interest/dividends, so harvesting equity losses has zero state benefit. Always check your state’s publication.
To integrate state impact: compute state marginal rate (e.g., 9.3% CA) multiplied by allowed loss to get state tax saved. If federal saves 24% * $1,680 = $403, state saves 9.3% * $1,680 = $156, total $559. For a no-income-tax state, total is $403.
Step 4: Break-Even Threshold Analysis (Fees vs Tax Saved)
The unique framework I use: the Harvesting Efficiency Ratio (HER). HER = (Federal Tax Saved + State Tax Saved) / (Transaction Fees + Software Cost + Opportunity Cost of Bid-Ask Spread). If HER < 1, don’t harvest.
For our example, tax saved $559. If broker charges $0 commission but spread cost is $30, and we use free spreadsheet, HER = 559/30 = 18.6, clearly worth it. But if you pay an advisor 0.5% on $10k harvested = $50, plus $20 tax prep, HER drops to 559/70 = 8.0 still positive.
Most people don’t realize that frequent harvesting in a small account can trigger fees that eclipse the saving. A $500 loss at 24% saves $120; if you pay $75 in trade fees, net is $45—barely worth the paperwork. The threshold is personal and must include the value of your time.
Decision Matrix for Harvesting Size
| Loss Size | Marginal Rate | Fee Estimate | Verdict |
|---|---|---|---|
| $500 | 24% | $75 | Marginal – skip unless automated |
| $2,000 | 32% | $30 | Strong yes |
| $10,000 | 37% | $50 | Absolute yes |
Use this matrix alongside the HER to avoid the trap of harvesting pennies while paying dollars in execution costs.
Using the Free Spreadsheet Estimator
We built a live Tax Loss Harvesting Estimator that automates the multi-lot, wash-sale, and carryforward math. It also outputs state estimates and flags wash-sale windows automatically.
If you want to model how the $3,000 cap interacts with supplemental wage income, our Tax on Bonus Calculator shows the ordinary-income side. I often run both before year-end to project total tax bill.
The spreadsheet lets you input each lot, flag replacement purchases, and instantly see allowed loss vs deferred basis. I recommend using it before December 31 to avoid missing the deadline, and exporting a PDF for your tax file.
Advanced Edge Cases That Break Naive Calculators
Wash sales across spouses: if your spouse buys the security in an account you don’t control, the loss is still disallowed under family attribution rules. Mutual fund reinvested dividends create tiny lots that complicate specific-ID; you must track them or accept average cost.
Options and ETFs: a put option on the same security can trigger wash sale. A different ETF tracking same index (e.g., VTI vs ITOT) is usually not substantially identical, but the IRS hasn’t issued bright-line test—use caution and document your reasoning.
Another misconception: you can harvest losses in a 401(k). You cannot; only taxable accounts permit deduction. And you cannot use losses to offset qualified dividend income at preferential rates beyond the net capital loss rules.
One more: if you harvest a loss and then donate the replacement shares to charity after 30 days, you get deduction for market value but basis is high—smart but requires planning. The calculator should let you model post-harvest basis.
Exact Spreadsheet Formulas You Can Copy
For those using Excel or Google Sheets, here are the cells I use. Assume columns: A lot ID, B basis, C proceeds, D term, E wash flag. Realized loss = C-B. Allowed loss = IF(E=”wash”, loss*0.6, loss) for 40% wash example.
Net ST = SUMIF(D,”ST”,AllowedLoss). Net LT = SUMIF(D,”LT”,AllowedLoss). Total net = NetST+NetLT. Allowed deduction = MIN(3000, TotalNet). Carryforward = TotalNet – Allowed deduction.
This mimics our estimator. The thing nobody tells you: Google Sheets SUMIF on text terms is case-sensitive if you mix “st” and “ST”; standardize capitalization.
Partial Wash Sale Across Three Accounts: A Detailed Walkthrough
Suppose you sell 100 shares in taxable, then buy 30 in IRA, 20 in spouse taxable, 10 in automated robo-advisor within 30 days. Total replacement 60 shares. Wash ratio = 60%. Disallowed loss = 60% of total realized loss.
If realized loss was $2,800, disallowed = $1,680. Allowed = $1,120. Basis additions: $1,120 split among the three replacement accounts pro-rata: IRA $840 (30/60), spouse $560 (20/60), robo $280 (10/60). Each gets basis bump.
This multi-account scenario is where manual calc fails. The IRS aggregates all related purchases. I missed the robo-advisor purchase once because it was on auto-rebalance, costing me a notice.
State Tax Table: Conformity at a Glance
| State | Conforms to Federal Wash Sale? | Allows $3k Cap? | Notes |
|---|---|---|---|
| California | Yes | Yes | Separate Schedule D |
| New York | Yes | Yes | NYC residency adds local tax |
| Texas | N/A | N/A | No income tax |
| New Hampshire | N/A | N/A | Only taxes interest/dividends |
| Massachusetts | Yes | Yes | Capital gains taxed at 5% flat |
Use this table to sanity-check your state column in the estimator. Note that states can change rules; verify with official state Department of Revenue before filing.
Common Misconceptions About the $3,000 Cap
Many believe the $3,000 cap applies per security or per brokerage account. It does not; it is aggregate per tax return. Another myth: you can carry back losses to prior years. Federal law only allows carryforward, not carryback, for individuals.
Some think the cap is indexed to inflation. It is not—it has been $3,000 since 1978, eroding in real terms. I remind clients that harvesting $3,100 yields only $3,000 deduction this year; the $100 is future money.
Final Checklist for Accurate Calculation
Before you file, verify these items. I keep this printed next to my desk:
- All lots identified with correct term (ST/LT) based on holding period, not sale date guess.
- Wash-sale replacements within 30 days before or after sale identified, loss deferred to basis in the right account.
- Netting order: ST vs ST, LT vs LT, then cross-net; gains offset first.
- $3,000 cap applied; excess carried forward with character preserved.
- State conformity checked; separate state calc if needed, especially for CA/NY.
- Break-even ratio computed to ensure fees don’t swallow savings.
- Spreadsheet or estimator output saved with timestamp for audit defense.
Calculating tax loss harvesting precisely is not glamorous, but it’s the difference between a real deduction and an IRS notice. Use the spreadsheet, document your method, and keep the evidence for at least three years.
Putting the Calculation Into Practice This Year
Start by exporting your year-to-date realized gains/losses from your broker. Filter for lots with unrealized losses that are worth harvesting given the HER. Mark any upcoming purchases in retirement accounts to avoid wash violations.
In my practice, I block two hours each December to run the estimator for every client. The most common error I correct is forgetting a dividend-reinvestment lot from January, which can add $200–$800 to deductible loss.
If you follow the steps above, you will calculate tax loss harvesting with the same rigor as a professional, capturing deferred losses correctly and avoiding the traps that erode real savings.