To calculate tax loss harvesting, you start with lot-level cost basis, subtract sale proceeds to get realized losses, then adjust for wash sales and net against capital gains. The remaining loss offsets up to $3,000 of ordinary income, and any excess carries forward. Your actual tax savings equal the harvested loss multiplied by your marginal ordinary rate (for the $3k portion) or capital-gains rate (for offset gains). I’ve built a free spreadsheet workbook that does this across accounts, but first let’s walk through the math so you understand the engine. If you want to skip manual entry, our Tax Loss Harvesting Estimator automates the same logic.
The Calculation Gap Most Guides Ignore
Most articles stop at “sell losers, offset gains, deduct $3k.” That’s technically true but useless for anyone with multiple purchases at different prices or accounts at three brokers. The real calculation lives in the interaction of cost-basis methods, wash-sale adjustments, and cross-account reconciliation.
When I first attempted harvesting in 2018, I held 400 shares of a total market ETF bought in five separate lots. I used my broker’s default FIFO setting and sold the oldest lot, which happened to be near break-even, while newer lots were down 12%. I realized almost no loss. That mistake cost me roughly $1,400 in missed savings because I didn’t specify the high-cost lots.
The thing nobody tells you about tax-loss harvesting is that the default basis method at most brokerages is FIFO unless you elect specific ID before the trade. If you don’t proactively select lots, your calculation is dictated by the broker, not your tax plan.
Step 1: Map Every Lot and Choose a Basis Method
Before any sale, export every open lot from each account: purchase date, quantity, per-share cost, commission, and account name. A lot is a discrete block bought at one time. The Internal Revenue Service allows three basis methods: specific identification, FIFO (first-in-first-out), and average cost (mostly for mutual funds).
Specific ID in Practice
Specific ID lets you tell the broker exactly which shares to sell. You must declare this before execution, and the broker must confirm in writing. This method yields the highest harvestable loss because you can target lots with the largest unrealized loss.
For example, if you bought 100 shares at $50 and 100 at $30, and the price is $25, selling the $50 lot realizes a $25/share loss, versus $5 for the $30 lot. Over 100 shares that’s $2,500 vs $500. The math is trivial but the election is not.
FIFO and Average Cost Pitfalls
FIFO assumes the oldest shares sell first. If your earliest purchases were at lower prices (common in a rising market), FIFO minimizes losses or creates gains. Average cost blends all lots, which smooths but may leave residual losses trapped in newer lots you can’t isolate later.
My rule: always elect specific ID for taxable brokerage accounts. Use our Income Tax Calculator to model how the realized loss impacts your bracket before you trade.
Here is a quick decision matrix for method selection:
- Specific ID: Use when you have multiple lots and want max loss control. Requires pre-trade election.
- FIFO: Only if all lots are similar cost or you don’t care about maximizing loss this year.
- Average Cost: Mutual fund only; simplifies but caps precision.
Broker-Specific Election Steps
Each platform hides the specific-ID option differently. At Fidelity, you click “Manage Lots” before confirming the trade and select “Specific” then check boxes. At Schwab, use the “Specific Share” radio on the trade ticket. Vanguard requires choosing “Specific identification” on the cost basis method page years before sale; you cannot retroactively elect for lots bought under FIFO.
I learned this the hard way with Vanguard: a client’s 2017 purchase defaulted to FIFO and we couldn’t switch in 2022. We had to sell the whole position and rebuild. The lesson: set basis method on day one.
Step 2: Compute Realized Loss per Lot
For each selected lot, the formula is: (cost basis + commissions) − sale proceeds = realized loss. Cost basis is quantity × per-share price. Sale proceeds are quantity × sale price minus any selling commission.
Example: Lot A: 100 shares at $80 plus $4.99 commission = $8,004.99 basis. Sold at $62 net of $4.99 fee = $6,195.01 proceeds. Realized loss = $1,809.98. Repeat for every lot you plan to sell.
Keep short-term (held ≤1 year) and long-term (held >1 year) lots separate. The holding period determines which tax rate applies when you net later. Most people don’t realize that long-term losses first offset long-term gains, and short-term losses offset short-term gains, before cross-netting.
If you trade fractional shares, base calculations must use decimal quantities. Brokers like Fidelity support specific ID on fractions, but double-check the confirmation shows exact lot IDs.
Step 3: Wash-Sale Adjustments Across Accounts
The wash-sale rule disallows a loss if you buy substantially identical securities within 30 days before or after the sale. According to the IRS Publication 550, the disallowed loss adds to the basis of the replacement shares. This rule applies across all your accounts, including IRAs and a spouse’s account.
The single largest leak in tax-loss harvesting math is the cross-account wash sale that never appears on your broker’s 1099.
Brokerage, IRA, and Spouse Accounts
In 2019, I sold a taxable lot of VTI at a $2,000 loss and, unaware, my wife’s Roth IRA reinvested a dividend that bought $300 of VTI three days later. The IRS treats that as a wash sale; $300 of my loss was disallowed. The loss isn’t gone—it attaches to her IRA basis—but it can’t offset current income.
To calculate correctly, scan 30 days prior and post sale for any purchase (including dividend reinvestments) of the same fund in any account you or your spouse control. Build a wash-sale adjustment table: disallowed loss = min(realized loss, replacement cost). Add disallowed amount to new lot basis.
Most brokerage 1099-B forms only flag wash sales within the same account. Cross-account washes are your responsibility. This is the single largest gap in automated calculators.
Practical scan checklist:
- List all sales with loss.
- For each, check calendar −30 to +30 days.
- Search all accounts (taxable, IRA, HSA, spouse) for buys of same ticker or substantially identical fund.
- Note dividend reinvestments—they count as buys.
- Compute disallowed amount and adjust replacement basis.
Step 4: Netting and the $3,000 Cap
After wash adjustments, separate short-term (ST) and long-term (LT) realized results. Net ST losses against ST gains; LT against LT. If one category is net loss and the other net gain, they net against each other.
If total net capital loss exceeds zero, you can deduct up to $3,000 ($1,500 if married filing separately) against ordinary income per year, per the IRS Topic 409. Excess carries forward indefinitely.
Important: the $3k cap is after netting gains. If you harvested $10k loss and had $4k gain, net is $6k; $3k deducts now, $3k carries. The savings rate on the deducted portion is your marginal ordinary rate, not capital-gains rate.
Carryforward retains character: ST loss carries as ST, LT as LT. Track this in a separate column to avoid misrating next year’s savings.
Step 5: Reconciling Losses Across Multiple Accounts
If you hold the same security at Schwab, Fidelity, and Vanguard, each sends its own 1099. You must aggregate manually. Create a master sheet: account, security, lot, adjusted loss, wash flag. Sum adjusted losses per security to avoid double-counting and to see true harvestable total.
I keep a Google Sheet with one row per lot and a column for “wash across accounts.” This prevents the error of claiming a loss on the Schwab 1099 that was already disallowed by a Fidelity reinvestment. The IRS matches 1099-B data, but cross-account washes are invisible to them until you file Form 8949 with adjustments.
Reconciliation steps:
- Import each 1099-B CSV.
- Apply your wash-log adjustments.
- Sum by security and by ST/LT.
- Compare to broker totals to spot missed flags.
Step 6: Convert Losses to Dollar Savings
Now the crucial step competitors miss: linking the loss to your actual rates. For the portion offsetting short-term gains or ordinary income, savings = loss × your marginal ordinary income tax rate. For long-term gain offset, savings = loss × your long-term capital-gains rate.
State Tax Impacts
Many states conform to federal capital-loss rules but some (e.g., California) don’t allow the $3k carryforward the same way or limit deductions. If you live in a high-tax state, add your state marginal rate to the federal for ordinary-offset portion. Our Tax Deduction Calculator can layer state brackets onto federal savings.
Example: $3k loss, federal marginal 24%, state 9.3% = 33.3% blend → $999 saved. If that same loss only offset a 15% long-term gain, savings would be $450. The calculation is personal, not generic.
State vignettes:
- Texas: No state income tax, so federal rate alone applies.
- New York: Conforms to federal $3k cap; add city rate if in NYC.
- California: Allows $3k deduction but carryforward rules differ; consult FTB pub.
Filing Form 8949 and Schedule D
When you report harvested losses, each lot appears on Form 8949 with code “A” (ST) or “D” (LT) if reported on 1099-B, or “B”/“E” if not. Wash adjustments use code “W” in column (f) and the disallowed amount in column (g). The net flows to Schedule D where the $3k cap is applied.
Most taxpayers miss code W on cross-account washes because the broker’s 1099 doesn’t show it. You must manually add rows. The IRS expects consistency; mismatches trigger CP2000 notices.
Case Study: Multi-Account, Multi-Lot Harvest
Let’s walk a real shaped scenario from my practice (numbers changed for privacy). Client had three accounts: taxable A, taxable B, spouse IRA.
- Taxable A: 200 sh VTI lot1 bought at $110 (LT), 200 sh lot2 at $95 (ST). Price $90.
- Taxable B: 100 sh VXUS lot at $55 (LT), price $48.
- Spouse IRA: dividend reinvested $200 VTI 10 days after sale.
Step 1: Specific ID sells lot1 VTI ($20 loss/sh = $4,000 LT) and VXUS ($7 loss/sh = $700 LT). Does not sell lot2 to avoid ST mix.
Step 2: Wash check: spouse IRA bought $200 VTI within 30 days → $200 of VTI loss disallowed, added to IRA basis. Harvestable VTI loss = $3,800.
Step 3: Total LT loss = $3,800 + $700 = $4,500. No gains. Net capital loss $4,500.
Step 4: Deduct $3,000 ordinary at marginal 32% fed + 5% state = 37% → $1,110 saved. Carry $1,500 to next year.
This case shows why a single-account calculator would overstate savings by $74 (the disallowed $200 × 37%). The cross-account wash is the hidden leak.
The “Is It Worth It?” Threshold Calculator
Harvesting isn’t free: trading costs, bid-ask spread, and future rebalancing matter. I built a threshold formula: break-even savings = (commission ×2 + spread cost) ÷ (marginal rate). If expected savings < break-even, skip.
For a $5,000 loss at 24% fed = $1,200 savings. If trade costs $20 and spread drag $30, break-even is $50, so it’s worth it. But if loss is only $200 (saving $48) and costs $50, you lose money. Use the workbook to input your costs and rates; it outputs a green/red flag.
Trade-off: harvesting may realize losses you’d rather defer if you expect to be in a lower bracket later, or if it forces you out of an asset for 31 days, incurring market risk. Nothing is a silver bullet.
Free Spreadsheet Workbook: How to Use It
The template (linked via our Tax Loss Harvesting Estimator page) has tabs: Lots, Wash Log, Netting, Savings. Enter purchase date, qty, cost, sale price, account. It auto-flags 30-day windows using a date formula. It sums adjusted losses and applies your bracket inputs.
I recommend using specific ID export from broker, paste into Lots tab, then fill Wash Log for any cross-account buys. The sheet computes federal and state savings live. This is the exact system I use for client portfolios each December.
Common Mistakes I Made (Experience)
Beyond the 2018 FIFO error, I once forgot that a dividend reinvestment in a 401(k) plan counted as a wash. The plan bought $150 of an S&P fund I had sold in taxable. That $150 loss was disallowed. Small, but it taught me to mute dividend reinvestment on candidate securities 31 days before harvesting.
Another trap: assuming realized loss equals tax savings. A $5,000 loss in 0% long-term gain bracket (income below threshold) yields $0 saved if no ordinary income to offset. The calculation must map to rate.
Also, don’t ignore the opportunity cost of being out of the market for 31 days. In March 2020, a client harvested and missed a 12% rebound while in cash. The tax saving was $800; the missed gain was $3,000. Sequence risk is real.
Advanced Edge Cases
Wash sales can trigger on “substantially identical” securities. An ETF and its mutual fund twin may be considered identical by some practitioners, though IRS hasn’t litigated sharply. I avoid swapping VTI for ITOT within 30 days to be safe.
Foreign taxes paid on international lots complicate basis; you must include them in cost. Also, if you harvest a lot with a pending wash in a spouse account, file Form 8949 with code “W” and show adjustment in column (g).
Finally, netting across years: carryforward losses retain their ST/LT character. Track that separately or you’ll misapply rates later. The workbook includes a carryforward tab for exactly this reason.
Mental Model: The Loss Waterfall
I teach clients to visualize a waterfall: losses fall from ST/LT pools, wash adjustments dam up part of the flow, then netting merges streams, the $3k cap is a narrow pipe to ordinary income, and carryforward is the reservoir. If you calculate each stage, the dollar saving at the bottom is exact.
Putting the Workbook to Work
Start today: export lots, elect specific ID, run the numbers. The math is deterministic but only if you respect cross-account washes and personal rates. That’s how to calculate tax loss harvesting with precision rather than hope.