If you accidentally sold stock, you can’t undo the trade — but you CAN buy it back immediately. Be aware of the tax consequences: the sale is a taxable event regardless of whether it was intentional.

What to Do Right Now

Step Action Why
1 Check if the trade actually executed Pending/open orders can still be canceled
2 If executed: decide whether to buy back At current market price (may be higher or lower)
3 Consider tax implications before repurchasing Wash sale rule may apply
4 Document what happened In case you need to explain to a tax advisor
5 Contact your broker if you believe there was a platform error They may investigate

Can You Cancel the Trade?

Situation Can You Cancel?
Market order already executed ❌ No — it’s final
Limit order not yet filled ✅ Yes — cancel in your brokerage app
After-hours order not yet executed ✅ Yes — cancel before market opens
Broker-assisted trade before execution ⚠️ Maybe — call immediately
Trade executed but you think it was a platform error ⚠️ File a complaint with the broker

Tax Consequences of the Accidental Sale

Scenario Tax Impact
Sold at a gain (held over 1 year) Long-term capital gains tax: 0%, 15%, or 20%
Sold at a gain (held under 1 year) Short-term capital gains tax: taxed as ordinary income (10-37%)
Sold at a loss (not repurchasing within 30 days) Can deduct loss against gains + $3,000 against income
Sold at a loss (repurchasing within 30 days) Wash sale rule — loss disallowed, added to new cost basis
Sold at breakeven No tax impact

The Wash Sale Rule Explained

Rule Detail
What triggers it Selling at a loss and buying same/substantially identical stock within 30 days before or after
What happens The loss is disallowed for tax purposes
Where does the loss go Added to cost basis of replacement shares
Is the loss permanently lost? No — deferred until you sell the replacement shares (without triggering another wash sale)
Does it apply to gains? No — wash sale rule only applies to losses

Should You Buy Back the Shares?

Factor Buy Back Don’t Buy Back
You sold at a loss and want the deduction Wait 31 days to avoid wash sale Buy back immediately (but lose the tax deduction this year)
You sold at a gain and want the same position Buy back immediately Wait if you think the price will drop
Stock price went up since you sold Buy back ASAP to limit further price increase Accept the loss if price is much higher
Stock price went down since you sold Lucky — buy back at a lower price Consider if you still want to own it

How to Prevent Accidental Trades

Prevention How
Use confirmation prompts Most brokerages have a “review order” screen — actually read it
Avoid trading on mobile (for large orders) Small screens increase error risk
Use limit orders instead of market orders Control the exact price; easier to cancel before fill
Lock your brokerage app Use biometric or PIN to prevent pocket trades
Don’t trade immediately after waking up or while distracted Most accidental trades happen during inattentive moments

The Bottom Line

The trade is done — you can’t undo it. If you want the shares back, buy them. If you sold at a loss, wait 31 days before repurchasing to preserve the tax deduction. If you sold at a gain, you’ll owe capital gains tax regardless. Going forward, use limit orders and always review the confirmation screen before executing trades.

Related: I Panic Sold My Investments | I Invested in the Wrong Fund