What is a wash sale (and why the IRS cares)
A wash sale happens when you sell a security at a loss and buy the same or substantially identical security within 30 days before or after the sale. The IRS disallows the entire loss deduction. You don't reduce your tax bill—you increase your audit risk.
Here's the thing: the IRS doesn't treat this as an honest mistake. When they find a wash sale, they dig. And when they dig into traders, they find everything.
According to IRS Topic 409, wash sales appear on Form 1099-B from your broker. The IRS has automated systems that cross-reference 1099 data with your tax return. One mismatch triggers an audit flag.
Why traders keep triggering wash sales without realizing it
Most traders don't track wash sales at all. They sell at a loss. Market rebounds. They buy back in. They think the 30-day window is flexible. It's not.
The window is 30 days BEFORE the sale and 30 days AFTER. That's 61 days of lockout total. Traders forget this. Traders sell on Monday, buy back on day 25, and think they're clean. They're not.
The second mistake: confusing "substantially identical." You think it means similar. The IRS means the exact same security. Different share class? Still a wash sale. Same ticker, different market? Still a wash sale.
- Sold Apple at a loss January 2nd
- Market rebounded January 10th
- Bought Apple back January 25th (29 days later)
- Audit notice arrives December, same year
- IRS disallows $10K loss + penalties
How the IRS detects wash sales
Brokers report every buy and sell on Form 1099-B with dates and prices. The IRS imports this data. Their system matches sells-at-loss with subsequent identical buys within 61 days. Any match = audit flag.
No human is reviewing your file yet. It's algorithmic. The system finds the violation, puts you on a list, and triggers a notice.
The cost compounds. The IRS disallows the loss, meaning you pay capital gains tax on that $10K. Then they add penalties (20-75% of the underpaid tax). Then interest accrues at 8% per year. A $10K wash sale can cost $15K-$25K when the IRS is done.
And that's if they don't dig deeper. Wash sales often trigger full account audits, where the IRS reviews every trade for unreported income, missing 1099s, and other violations.
How automation prevents wash sales automatically
An algorithm monitors your account in real time. Before you execute a buy order, it checks: Is this security in your wash sale lockout window right now? If yes, it either blocks the trade or sends an alert with the exact countdown.
The algorithm tracks:
- Every security you sold at a loss
- Exact sale dates
- The 30-day pre-window and 30-day post-window
- Every attempted repurchase
- Substantially identical securities (same stock, ETF, fund, or index)
You harvest losses. The algorithm prevents the violation. Your 1099-B is clean. The IRS never audits.
Custom trading algorithms from Alorny can be built to monitor compliance rules like this automatically. Once deployed, they run 24/7 without your input. No manual tracking. No spreadsheet mistakes. No $50K surprises.
The real cost math: automation vs. penalties
A custom algorithm that prevents wash sales costs $300-$500 upfront. Premium versions with full tax-compliance logic cost $500-$1,000.
A single wash sale violation costs $15,000-$25,000 in disallowed losses, penalties, and interest. One prevented trade pays for the algorithm 15-50 times over.
If you harvest losses quarterly or monthly, the math is obvious: automation is mandatory. If you're a casual trader who sells a few positions per year, you might track manually. But serious loss harvesters can't afford to.
The IRS publishes no statistics on how many traders they catch, but broker compliance reports show wash sale violations are the #1 tax-rule violation found in audited trading accounts. It's not rare. It's endemic.
Building a wash-sale-proof system
The system has three components:
- Real-time monitoring: The algorithm watches every pending trade. Before execution, it queries the wash sale register.
- Lockout calendar: 61-day windows are tracked per security. Any buy-back attempt within the window triggers a warning or block.
- Clean 1099 export: At tax time, the algorithm generates a compliance report showing zero violations. You have documentation if audited.
Manual tracking fails because of one thing: human error. A typo in a date, a misremembered security code, or a forgotten sale from three years ago. That's how traders end up in audit.
Automation removes the human variable. The algorithm never forgets. Never miscalculates. Never misreads a date.
If you're harvesting losses as part of your trading strategy, let's build a custom algorithm that prevents wash sales. We design, test, and deploy in hours. Full live backtesting included. You deploy, it runs forever, the IRS never calls.