Can You Trade One Stock for Another Without Paying Taxes?

Trading one stock for another almost always has tax consequences. The stock market has no mechanism to swap Share A for Share B in a single transaction, so your broker sells the first position for cash and then uses that cash to buy the second. The IRS treats the sell leg as a realization event the moment it fills, which means any gain is taxable and any loss is deductible even though the money never leaves your brokerage account. Two narrow exceptions exist, corporate stock-for-stock mergers and trades inside retirement accounts, but the ordinary rotation from one holding to another triggers capital gains tax.

Why a “Trade” Is Really Two Transactions

Centralized exchanges and broker-dealers sit between every buyer and seller. When you move from Stock A to Stock B, your broker sells Stock A on the open market at the current price, deposits the cash proceeds in your account, and then uses those proceeds to buy Stock B. No one on the other side needs to want the opposite swap. Liquidity makes the process feel seamless, but legally and financially, two distinct transactions have occurred.

Peer-to-peer stock swaps are technically legal through private contracts, but the administrative overhead and difficulty of agreeing on fair value make them impractical for publicly traded securities. The exchange-mediated system guarantees you receive the current market price and creates a clean audit trail for tax reporting.

One boundary worth clearing up: Section 1031 like-kind exchanges, which allow deferral of gain on swaps of similar assets, apply exclusively to real property. Stocks, bonds, and other securities do not qualify.1Office of the Law Revision Counsel. 26 USC 1031 – Exchange of Real Property Held for Productive Use or Investment There is no “trade it and defer the tax” option for regular stock in a taxable account.

What You Owe on the Sale

The gain or loss on the sale leg equals the difference between your proceeds and your adjusted cost basis in the shares you sold. This is true even if the cash sits in the account for seconds before purchasing the replacement stock.

The holding period on the shares you sold determines the rate on any gain. Shares held one year or less produce short-term gains, taxed as ordinary income at your marginal rate, which can reach 37% for 2026. Shares held more than one year produce long-term gains, taxed at 0%, 15%, or 20% depending on taxable income.

For 2026, single filers pay 0% on long-term gains up to $49,450 of taxable income, 15% from $49,451 to $545,500, and 20% above $545,500. Married couples filing jointly reach the 15% rate at $98,901 and the 20% rate above $613,700.

If the sale produces a loss, it offsets other capital gains dollar for dollar. Any net loss beyond that can offset up to $3,000 of ordinary income per year, or $1,500 if married filing separately, with unused losses carrying forward to future years.2Internal Revenue Service. Topic No. 409, Capital Gains and Losses

You report each sale on Form 8949 and carry the totals to Schedule D. Your broker sends Form 1099-B with the details, but the reporting obligation is yours.3Internal Revenue Service. Instructions for Form 8949

The 3.8% Surtax at Higher Incomes

Capital gains can also trigger the Net Investment Income Tax, an additional 3.8% on the lesser of your net investment income or the amount by which modified adjusted gross income exceeds $200,000 for single filers or $250,000 for married filing jointly. Those thresholds are not inflation-adjusted, so more taxpayers cross them each year.4Office of the Law Revision Counsel. 26 USC 1411 – Imposition of Tax A high-income single filer selling a long-term position can face a combined 23.8% federal rate. State income tax on capital gains typically stacks on top.

The Wash Sale Rule When You Rotate at a Loss

This is where investors accidentally trip up. If you sell a stock at a loss and buy a “substantially identical” security within 30 days before or after the sale, the IRS disallows the loss. The window runs in both directions, creating a 61-day danger zone around the loss.5Office of the Law Revision Counsel. 26 USC 1091 – Loss From Wash Sales of Stock or Securities

The disallowed loss is not gone forever. It gets added to the cost basis of the replacement shares, effectively deferring the tax benefit until you eventually sell those new shares. If you sold at a $500 loss and bought back the same stock for $2,000, your basis in the new shares becomes $2,500.6Internal Revenue Service. Publication 550, Investment Income and Expenses

“Substantially identical” is narrower than many investors assume. Stocks of two different companies are generally not considered substantially identical, even if they operate in the same industry. Selling one tech stock at a loss and immediately buying a different tech stock is usually fine. Buying back the same stock, or purchasing convertible securities that closely track it, triggers the rule. So does a repurchase by your spouse, or a repurchase inside your IRA.6Internal Revenue Service. Publication 550, Investment Income and Expenses

To safely claim the loss, wait at least 31 days after the sale before repurchasing the same or a substantially identical security.

Retirement Accounts Are the Real Exception

Inside a traditional IRA, Roth IRA, or 401(k), selling one stock to buy another triggers no capital gains tax at the time of the trade. Amounts inside a traditional IRA, including earnings and gains, are not taxed until you take a distribution.7Internal Revenue Service. Traditional IRAs Qualified Roth withdrawals in retirement are generally tax-free, so gains inside a Roth may never be taxed at all. This makes retirement accounts the natural home for frequent rebalancing.

These accounts do carry their own restrictions. You cannot borrow from an IRA, use IRA funds to buy property for personal use, or engage in transactions between yourself and the account. A prohibited transaction can cost the IRA its tax-advantaged status retroactively to the first day of the year, creating an immediate tax bill.8Internal Revenue Service. Retirement Topics – Prohibited Transactions Ordinary stock trades within the account are fine. The prohibited transaction rules target self-dealing, not routine investing.

Stock-for-Stock Mergers

The one scenario where you genuinely receive new stock in exchange for old stock without selling first is a corporate reorganization. When Company A acquires Company B in an all-stock deal, Company B’s shareholders receive shares of Company A directly. Under Section 354, the exchange is treated as a tax-free continuation of the original investment. No gain or loss is recognized, and the cost basis from your old shares carries over to the new ones.9Office of the Law Revision Counsel. 26 USC 354 – Exchanges of Stock and Securities in Certain Reorganizations

Many mergers include cash alongside the new stock. That cash portion, called “boot,” is taxable. You recognize gain up to the amount of boot received, even though the stock portion remains tax-deferred. When the math doesn’t produce a round number of new shares, companies typically pay cash in lieu of issuing a fractional share, and that small payment is also a taxable disposition based on your allocated basis in the fraction.

You don’t need to do anything manually. Your broker converts the shares once the deal closes and adjusts the cost basis records.

Choosing Which Shares to Sell

When you own shares of the same stock purchased at different times and prices, the shares you designate for sale can dramatically change your tax bill. Say you bought 100 shares at $30 last year and another 100 at $50 this year. Selling 100 shares at $55 produces either a $25-per-share long-term gain or a $5-per-share short-term gain, depending on which lot you pick.

The IRS default is first-in, first-out.10Internal Revenue Service. Stocks, Options, Splits, Traders That’s often the worst choice for tax purposes because older shares typically carry the lowest basis and the largest embedded gain. The alternative is specific identification, where you tell your broker exactly which lot to sell before the trade settles. Most online brokers let you select the lot at order entry. If you want to switch from the average cost method to specific identification, you generally need to elect out in writing before making the trade.

Before placing any sell order in a rotation, pull up your brokerage’s tax lot detail screen. Check the acquisition date and per-share basis for each lot. Selling a lot held longer than one year qualifies the gain for the lower long-term rate, and choosing higher-basis lots reduces the taxable gain. A few minutes of comparison can save hundreds or thousands.

Donating Appreciated Stock Instead of Selling

If you are rotating out of a position with large unrealized gains and you are charitably inclined, donating the appreciated shares directly to a qualified charity can be far more tax-efficient than selling and donating the cash. When you donate stock held longer than one year, you generally deduct the full fair market value on the date of donation, and neither you nor the charity pays capital gains tax on the appreciation.11Internal Revenue Service. Publication 526, Charitable Contributions

Compare that to selling first: you would owe capital gains on the profit, then donate a smaller after-tax amount. Donating the stock directly avoids the tax entirely and still produces the deduction. The strategy works best for shares with large built-in gains that you would otherwise sell as part of a portfolio rebalance.