Capital Gains vs Losses: The Tax Math Most Investors Get Wrong
Capital gains and capital losses are the tax consequences of selling investments for more or less than you paid for them. Understanding how capital gains tax works, and how capital losses can offset them, is essential for any investor who wants to keep more of their returns. The difference between smart and naive tax management can easily amount to 1-2% of portfolio value annually.
This guide covers everything you need to know about capital gains and losses in 2026: how they are calculated, how they are taxed, and how to use them strategically.
What Are Capital Gains?
A capital gain occurs when you sell an asset for more than your cost basis (what you paid for it, including commissions and fees).
Simple example:
- You buy 100 shares of AAPL at $150/share = $15,000 cost basis
- You sell those 100 shares at $200/share = $20,000 proceeds
- Capital gain = $20,000 - $15,000 = $5,000
Realized vs. Unrealized Gains
- Unrealized gains: Your investment has appreciated in value but you have not sold it. No tax is owed. Often called "paper gains."
- Realized gains: You have sold the investment and locked in the profit. Tax is now owed for the year of the sale.
This distinction is critically important: you control when (and whether) to realize gains. This timing flexibility is the foundation of tax-efficient investing.
Short-Term vs. Long-Term Capital Gains
The IRS treats capital gains very differently based on how long you held the asset:
| Holding Period | Classification | Tax Rate |
|---|---|---|
| 1 year or less | Short-term capital gain | Taxed as ordinary income (up to 37%) |
| More than 1 year | Long-term capital gain | 0%, 15%, or 20% preferential rate |
2026 Long-Term Capital Gains Tax Rates:
| Filing Status | 0% Rate | 15% Rate | 20% Rate |
|---|---|---|---|
| Single | Up to $48,350 | $48,351 - $533,400 | Over $533,400 |
| Married Filing Jointly | Up to $96,700 | $96,701 - $600,050 | Over $600,050 |
Net Investment Income Tax (NIIT): An additional 3.8% surtax applies to investment income for individuals earning over $200,000 ($250,000 married). This brings the effective top rate on long-term gains to 23.8%.
What Are Capital Losses?
A capital loss occurs when you sell an asset for less than your cost basis.
Example:
- You buy 200 shares of XYZ at $50/share = $10,000 cost basis
- The stock drops and you sell at $35/share = $7,000 proceeds
- Capital loss = $7,000 - $10,000 = -$3,000
How Capital Losses Offset Gains
Capital losses directly offset capital gains dollar-for-dollar:
- Short-term losses first offset short-term gains (most beneficial: offsets income taxed at up to 37%)
- Long-term losses first offset long-term gains (offsets income taxed at 15-20%)
- Net losses of one type offset gains of the other type
- If net losses exceed gains: Deduct up to $3,000 against ordinary income per year
- Remaining losses: Carry forward indefinitely to future years
Example of loss offset:
| Transaction | Type | Amount |
|---|---|---|
| Gain from selling Stock A | Short-term | +$8,000 |
| Loss from selling Stock B | Short-term | -$5,000 |
| Gain from selling Stock C | Long-term | +$12,000 |
| Loss from selling Stock D | Long-term | -$15,000 |
| Net short-term gain | +$3,000 | |
| Net long-term loss | -$3,000 | |
| Overall net gain | $0 (no tax owed) |
In this example, the investor realized $20,000 in total gains but owes zero capital gains tax because losses perfectly offset gains.
Tax-Loss Harvesting: Turning Losses into Tax Savings
Tax-loss harvesting is the practice of deliberately selling investments at a loss to offset gains elsewhere in your portfolio, then reinvesting the proceeds in a similar (but not identical) investment to maintain your market exposure.
How Tax-Loss Harvesting Works
- Identify positions with unrealized losses in your portfolio
- Sell the losing position to realize the capital loss
- Immediately reinvest in a similar but not "substantially identical" security
- Use the harvested loss to offset realized gains or up to $3,000 of ordinary income
The Wash Sale Rule
The IRS prevents you from selling at a loss and immediately rebuying the same security. The wash sale rule disallows the loss if you purchase a "substantially identical" security within 30 days before or after the sale. The disallowed amount is added to the basis of the replacement shares, so in the ordinary case the deduction is deferred to the sale of those shares rather than lost. The wash sale calculator works out the split for a specific sale, and the rule in full covers the cases where the deduction does not come back.
What triggers a wash sale:
- Buying the same stock within 30 days (before or after the loss sale)
- Buying a call option on the same stock
- Buying the stock in another account (IRA, spouse's account)
- Receiving the stock via DRIP (dividend reinvestment) within 30 days
What does NOT trigger a wash sale:
- Selling a Vanguard S&P 500 fund and buying a Schwab S&P 500 fund (different fund, same index: the IRS has not explicitly ruled this is "substantially identical," though this is debated)
- Selling an individual stock and buying a sector ETF that contains it
- Waiting 31 days to repurchase
Tax-Loss Harvesting Example
| Action | Details |
|---|---|
| Current holding | VTI (Vanguard Total Stock Market), down $8,000 from purchase |
| Sell VTI | Realize $8,000 capital loss |
| Buy ITOT | iShares Core S&P Total US Stock Market (similar exposure, different fund) |
| Tax benefit | $8,000 loss offsets other gains or $3,000/year against income |
| Portfolio impact | Minimal: still holds broad US stock market exposure |
When Tax-Loss Harvesting Makes Sense
- You have realized gains elsewhere (from rebalancing, RSU sales, or profitable exits)
- You have significant unrealized losses in taxable accounts
- You are in a high marginal tax bracket (32%+ federal)
- You can maintain similar market exposure without triggering wash sale rules
When It Does NOT Make Sense
- You are in the 0% capital gains bracket (no tax to offset)
- Transaction costs exceed the tax benefit (very small losses)
- You cannot find an adequate replacement investment
- The position is in a tax-advantaged account (IRA, 401k): losses are not deductible
Cost Basis Methods
When you sell shares you purchased at different prices over time, you must determine which shares you are selling. The method you choose affects your taxable gain or loss:
FIFO (First In, First Out)
Default method. Assumes you sell the oldest shares first. Often results in the largest gain (since oldest shares typically have the lowest cost basis due to appreciation over time).
Specific Identification
You choose exactly which lot to sell. Optimal for tax planning: sell highest-cost-basis shares first to minimize gains, or sell lots with losses for harvesting.
Average Cost
Only available for mutual funds. Averages the cost basis of all shares. Simple but inflexible.
Recommendation: Always use specific identification and sell highest-cost-basis lots first (unless you are deliberately harvesting a loss from a low-cost lot). Most brokerages support this if you specify at the time of sale.
Capital Gains Strategies for Different Situations
For RSU Holders
When RSU shares vest, your cost basis equals the market price on the vesting date. If the stock subsequently drops below your vesting price, you have a harvestable capital loss, even though you never "bought" the shares in the traditional sense.
This is one of the most commonly missed tax-loss harvesting opportunities for tech workers.
For Rebalancing
Portfolio rebalancing often requires selling appreciated assets. Offset these gains by simultaneously harvesting losses elsewhere in the portfolio. The net tax impact of a rebalancing event can be reduced to near-zero with planning.
For Concentrated Positions
If you hold a large concentrated stock position with substantial unrealized gains, consider:
- Selling in installments across multiple tax years to stay in lower brackets
- Donating appreciated shares directly to charity (avoid capital gains entirely)
- Using qualified opportunity zone investments to defer gains
- Gifting appreciated shares to family members in lower tax brackets
For Retirement Accounts
Capital gains and losses inside IRAs, 401(k)s, and other tax-advantaged accounts have NO tax consequences of their own. Holding periods and cost basis do not matter inside the account, and all tax impact happens at withdrawal (traditional) or never (Roth). One thing does reach outside, though: buying a security inside a retirement account within 30 days of selling it at a loss in a taxable account disallows that loss, and under Rev. Rul. 2008-5 no basis is restored anywhere, so the deduction is gone rather than deferred. An automatic contribution is enough to do it.
This is why aggressive rebalancing and tax-inefficient strategies belong in tax-advantaged accounts.
Tracking Capital Gains and Losses
Effective capital gains management requires knowing:
- Cost basis of every lot: When you bought it and at what price
- Holding period of every lot: Has it crossed the 1-year threshold for long-term treatment?
- Unrealized gains/losses: Where do harvesting opportunities exist?
- Year-to-date realized gains: How much offset do you need?
When holdings are spread across multiple brokerage accounts, this tracking becomes complex. Each brokerage reports its own 1099-B, but none can see your tax picture across all accounts.
Helm Terminal aggregates your holdings across all accounts and tracks current market values, making it straightforward to identify which positions have unrealized losses available for harvesting and which have gains you might want to defer.
Year-End Capital Gains Checklist
Before December 31 each year:
- Calculate year-to-date realized gains across all taxable accounts
- Identify positions with unrealized losses for potential harvesting
- Check holding periods: are any positions about to cross the 1-year long-term threshold?
- Review mutual fund capital gains distribution estimates (they create gains even if you do not sell)
- Consider accelerating gains into the current year if you expect to be in a higher bracket next year
- Consider deferring gains if you expect to be in a lower bracket next year
- Confirm you will not violate wash sale rules with January purchases
Track Your Gains, Losses, and Tax Position
Managing capital gains and losses effectively requires real-time visibility into your portfolio's cost basis and unrealized positions across every account. Waiting until tax time to discover you owe $15,000 in capital gains is a planning failure.
Helm Terminal keeps your complete portfolio picture current, showing where gains and losses sit across all your investment accounts so you can make tax-smart decisions throughout the year, not just in December.
Try Helm free to see your complete capital gains picture across all accounts.
The Bottom Line
Capital gains taxes are one of the largest drags on investment returns, and one of the most controllable. By understanding the difference between short-term and long-term rates, systematically harvesting losses, using specific lot identification, and timing realizations thoughtfully, you can keep significantly more of what your portfolio earns. The tax code penalizes the uninformed. Do not be uninformed.
Related Reading
- How to Find Tax-Loss Harvesting Opportunities
- RSU Tax Strategies for Tech Employees
- TLH Calculator: Estimate Your Tax Savings
- The Wash Sale Rule: What It Actually Disallows
- Capital Loss Carryover: How It Works, With the Math
- How to Calculate Cost Basis on Stocks and Funds
- Wash Sale Calculator: Disallowed Loss and New Basis
Frequently asked questions
What are capital gains?
A capital gain is the profit on selling a capital asset for more than its cost basis, which is generally what you paid plus commissions and certain adjustments. The gain is not taxable while you hold the asset. It becomes taxable in the year you sell, which is what people mean when they say gains are taxed on realization rather than on paper.
How does capital gains tax work?
Sale price minus cost basis gives the gain. The holding period then decides the rate. An asset held one year or less produces a short-term gain, taxed at your ordinary income rate. Held more than one year, it produces a long-term gain, taxed in the separate long-term brackets of 0, 15 and 20 percent. Gains and losses are netted before any of that is applied, so the taxable figure is the net, not the sum of the winners.
What is the long-term capital gains tax rate?
Long-term gains fall into 0, 15 or 20 percent bands, and which band applies depends on taxable income and filing status rather than on the size of the gain alone. A separate 3.8 percent net investment income tax can apply above certain income thresholds. Short-term gains do not use these bands at all; they are taxed as ordinary income.
How do capital losses offset capital gains?
Losses net against gains of the same character first, so short-term against short-term and long-term against long-term. Whatever remains crosses over and offsets the other character. If losses still exceed gains after both steps, up to $3,000 of the excess reduces ordinary income for the year under IRC section 1211(b), $1,500 if married filing separately, and anything beyond that carries forward to later years with no expiry.
Is it better to offset a short-term or a long-term gain?
A loss applied against a short-term gain generally saves more tax, because short-term gains are taxed at ordinary income rates while long-term gains use the lower 0, 15 and 20 percent bands. The netting rules do not let you choose freely: same-character netting happens first by law, and only the leftover crosses over.
How do you calculate capital gains tax?
Establish the cost basis for each lot sold, subtract it from the proceeds to get the gain or loss per lot, net the short-term group and the long-term group separately, then cross-net whatever is left. Apply ordinary rates to any net short-term gain and the long-term bands to any net long-term gain. Lot selection matters: selling specific high-basis lots instead of the default first-in-first-out changes the gain reported.
Do you pay capital gains tax in a 401(k) or an IRA?
No. Sales inside a traditional or Roth retirement account are not capital events on your return, so gains inside them are not taxed as gains and losses inside them are not deductible. Distributions from a traditional account are taxed as ordinary income when taken, and qualified Roth distributions are not taxed. This is also why harvesting a loss only works in a taxable brokerage account.
Where does Helm show gains and losses?
Helm reads connected brokerage accounts through Plaid on a read-only basis and works at the lot level, so each position shows its own basis, holding period and unrealized gain or loss. The tax center groups those into short-term and long-term, flags lots currently underwater, and screens the wash-sale window across every connected account. The tax center is part of Helm Pro.
This content is for educational purposes only and does not constitute financial, tax, or investment advice. Consult a licensed professional before making financial decisions. Helm Terminal is not a registered investment advisor.