1. How Stock Sale Taxes Actually Work
When you sell stock for more than you paid, the profit is a capital gain. When you sell for less, it's a capital loss. The IRS taxes gains and allows you to deduct losses — but the rules around timing, classification, and limitations determine how much you actually owe.
The formula is simple:
Capital Gain = Sale Price − Cost Basis − Transaction Costs
Your cost basis is what you originally paid for the shares, including commissions. If you received shares through an employer (RSUs, ESPP), the basis is the fair market value on the vesting date (already taxed as ordinary income).
The holding period determines your tax rate. Stocks held more than one year qualify for long-term capital gains rates. Stocks held one year or less are taxed at your ordinary income rate — which for high earners can approach 37% federal plus state taxes.
2. 2026 Capital Gains Tax Rates
For tax year 2026, the long-term capital gains brackets are:
| 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 |
| Head of Household | Up to $64,750 | $64,751 – $566,700 | Over $566,700 |
Short-term gains are taxed at ordinary income rates (10%, 12%, 22%, 24%, 32%, 35%, or 37%). For a high-earning executive in the 37% bracket with the 3.8% NIIT, short-term gains face a combined federal rate of 40.8%. In California, add 13.3% state tax for a total marginal rate exceeding 54%.
3. Cost Basis Methods
When you own multiple lots of the same stock (bought at different times and prices), the cost basis method you choose determines which shares you're "selling" and therefore your gain or loss.
FIFO (First In, First Out)
Default method. The oldest shares are sold first. In a rising market, FIFO typically produces the largest gain (because the oldest shares have the lowest basis). Bad for taxes, but the easiest to track.
Specific Identification
You designate exactly which lot to sell. This gives you maximum control — sell the highest-basis lot first to minimize gains, or sell a losing lot to generate a deductible loss. You must identify the lot before the trade settles.
Average Cost
Available only for mutual fund shares (not individual stocks). All shares are averaged to a single basis. Simple but inflexible.
4. The Wash Sale Rule Explained
The wash sale rule exists to prevent investors from claiming a tax loss while maintaining economic exposure to the same position. Under IRC §1091, if you sell a security at a loss and repurchase a "substantially identical" security within 30 days before or after the sale, the loss is disallowed.
The 61-day window:
What counts as "substantially identical":
- Same stock (obvious)
- Options on the same stock (calls or puts)
- Contracts to acquire the same stock
- Buying in an IRA within the window (yes, this triggers it too)
What does not trigger a wash sale:
- Selling AAPL and buying MSFT (different company)
- Selling a single stock and buying a broad ETF (even if it holds that stock)
- Selling an S&P 500 ETF from one provider and buying one from another (debatable — IRS hasn't ruled definitively, but most advisors consider this risky)
5. Tax-Loss Harvesting Mechanics
Tax-loss harvesting (TLH) is the practice of deliberately selling investments at a loss to offset gains elsewhere in your portfolio. Done correctly, it can save thousands annually without materially changing your investment exposure.
The math:
| Scenario | Without TLH | With TLH | Savings |
|---|---|---|---|
| $80K long-term gain, no harvesting | $19,040 tax | — | — |
| Harvest $30K in losses elsewhere | — | $11,900 tax | $7,140 |
| No gains, harvest $30K losses | $0 | -$3,000 deduction* | $1,110/yr |
*Capital losses exceeding gains can offset up to $3,000 of ordinary income per year. Excess losses carry forward indefinitely.
The Replacement Strategy
To maintain market exposure while harvesting:
- Sell the losing position
- Immediately buy a similar (but not "substantially identical") investment
- Wait 31 days
- Optionally switch back to the original position
Common swaps that avoid wash sale issues:
- VOO (Vanguard S&P 500) → IVV (iShares S&P 500) — different provider, same index
- VTI (total market) → ITOT (iShares total market)
- Individual stock → sector ETF containing that stock
6. Net Investment Income Tax (3.8%)
The Net Investment Income Tax (NIIT) under IRC §1411 adds 3.8% to capital gains for individuals with modified AGI above:
- $250,000 — Married Filing Jointly
- $200,000 — Single
- $125,000 — Married Filing Separately
The 3.8% applies to the lesser of net investment income or the excess of MAGI over the threshold. This means a married couple with $300K MAGI and $80K in capital gains pays NIIT on $50K (the excess over $250K), not the full $80K.
7. Seven Legal Strategies to Minimize Capital Gains Tax
Strategy 1: Hold for One Year + One Day
The simplest and most impactful. Moving from short-term (37% max) to long-term (20% max) cuts your federal rate nearly in half. For a $200K gain, that's $34,000 saved.
Strategy 2: Harvest Losses Year-Round
Don't wait until December. Market corrections happen throughout the year. Set alerts for positions down 10%+ and evaluate whether harvesting makes sense. The best opportunities often come in mid-year corrections when everyone else is panicking.
Strategy 3: Donate Appreciated Stock to Charity
Donating stock held more than one year lets you deduct the full market value while completely avoiding capital gains tax. A $100K stock with $30K basis: selling and donating cash nets you a $70K deduction minus $23.8K tax ($46.2K value). Donating the stock directly gives you a $100K deduction with $0 tax. That's $53.8K in total benefit — $7,600 more.
Strategy 4: Use Specific Lot Identification
Always sell your highest-cost-basis lots first. If you own 500 shares of NVDA bought in 5 lots between $50 and $400, selling the $400 lot when the price is $450 generates a $50/share gain. Selling the $50 lot generates a $400/share gain. Same economics, very different tax bills.
Strategy 5: Opportunity Zone Investment (IRC §1400Z)
Reinvesting capital gains into a Qualified Opportunity Zone Fund defers the gain until 2026 (deadline passed for partial exclusions) and eliminates tax on future appreciation if held 10+ years. The 2026 deadline for the original deferral is approaching — consult your CPA immediately if this applies.
Strategy 6: Installment Sales for Concentrated Positions
If selling a large private-company stake or a concentrated public position via a structured sale (exchange fund or installment note), you can spread the gain across multiple tax years, potentially keeping each year's income in a lower bracket.
Strategy 7: State Tax Arbitrage
If you're relocating, timing stock sales for after establishing residency in a no-income-tax state (TX, FL, NV, WA, TN, WY, SD) eliminates state capital gains tax entirely. This must be a genuine relocation — the former state will audit if you maintain ties.
8. Common Mistakes That Trigger Audits
- Ignoring wash sales in separate accounts: The rule applies across ALL your accounts, including spouse's accounts and IRAs
- Wrong basis on inherited stock: Inherited shares get a stepped-up basis to date-of-death value, not the original purchase price
- Forgetting RSU basis: The fair market value at vesting is your basis (you already paid ordinary income tax on it)
- Missing cryptocurrency reporting: Every crypto-to-crypto trade is a taxable event as of 2024
- Not reporting cost basis on transferred shares: When shares move between brokers, basis data often doesn't transfer. You're responsible for providing it.
Tax planning isn't optional for serious investors. It's the one area where the math is clear: every dollar saved in taxes compounds in your portfolio forever. A $10,000 tax savings invested at 10% annual returns becomes $67,000 in 20 years.
Key Takeaways
- Long-term vs. short-term is the biggest lever: One extra day of holding can cut your federal rate from 37% to 20%
- Use Specific Identification: Always sell highest-basis lots first to minimize gains
- Harvest losses systematically: Set up alerts and harvest year-round, not just in December
- Mind the 61-day wash sale window: It applies across all accounts including IRAs
- Plan around NIIT thresholds: 3.8% is avoidable with income timing
- Donate appreciated stock, don't sell and donate cash: You avoid gains tax AND get the full deduction
At Proflex Finance, our managed portfolio clients receive year-round tax-loss harvesting as part of their advisory relationship. We estimate our systematic harvesting approach generates 0.5% – 1.5% in annual after-tax alpha — compounding quietly in the background while you focus on earning.