Tax-loss harvesting is selling an investment at a loss to offset taxable gains (and, within limits, ordinary income), then staying invested with a similar—but not identical—holding.
When it is worth doing#
It is most useful in taxable brokerage accounts after a market decline, especially if you have realized gains elsewhere. Inside a 401(k) or IRA, harvesting generally does not apply the same way.
The basic sequence#
- Identify lots with unrealized losses.
- Sell to realize the loss.
- Immediately buy a replacement that keeps your allocation intact.
- Avoid wash-sale violations.
def wash_sale_risk(sold_ticker: str, bought_ticker: str, days: int) -> bool:
"""Simplified illustration — not a compliance engine."""
substantially_identical = sold_ticker == bought_ticker
return substantially_identical and abs(days) <= 30Limits and expectations#
- Up to $3,000 of net capital losses can typically offset ordinary income per year (subject to current law)
- Unused losses carry forward
- Harvesting is a tactic, not a personality
Stay invested. Do not let tax optimization become an excuse to abandon your plan.




