The 30-day rule in the stock market -- commonly referred to as the "wash sale" rule" -- affects the taxable gains and losses on stocks you sell. The purpose of the rule is to prevent you from selling stock for a tax loss and buying it right back because you still like the stock. An understanding of the aspects of the wash sale rule will prevent you from unintentionally running afoul of the rule and increasing your income tax bill.
If you sell an investment at a loss, the loss is called a capital loss and can be used to reduce your taxable income. Capital losses are credited against any capital gains you have for the year and excess losses can be used to reduce the amount of your regular taxable income. The wash sale rule prevents you from selling shares of stock and buying the stock right back just to take a loss you can write off on your taxes. The wash sale rule does not apply to gains. If you sell a stock for a profit and buy it right back, you still owe taxes on the gain.
The time limit for a sale and stock repurchase to not be a wash sale is 30 days before and after the date you sold your shares for a loss. If you own 100 shares of stock, buy 100 more and 10 days later sell the first 100 shares for a loss, the loss will be disallowed. Buying back a "substantially identical" investment within the 30 days triggers the wash sale rule. For example, if you sell stock shares and buy a stock option on the same company, it would trigger a wash sale and invalidate any tax loss from the sale of the shares.
The shares purchased within 30 days before or after the sale for a loss must be replacement shares for the wash sale rule to be effective. You can buy shares and a week later sell them for a tax-deductible loss. This is because the initial purchase was not to replace shares already owned. In most cases, a wash sale is triggered when you sell an investment and then buy the same investment again within 30 days after the sale.
You cannot try to get around the wash sale rule by buying back the shares in a different account, such as selling shares out of your regular brokerage account to book the loss and then buying the shares in your IRA account. Don't try to bend the rules by selling shares out of your individual brokerage account and buying them in a joint account. These transactions still would be classified as wash sales and the tax loss not allowed.