Mastering Stock Taxes: RSUs, ESPP, Wash Sales & Loss Harvesting
A rigorous, practitioner guide for software engineers, tech professionals, and active investors. Decode RSU supplemental withholding traps, navigate qualifying vs. disqualifying ESPP dispositions, avoid the 1099-B double tax pitfall, master IRC ยง1091 wash sale rules, and execute systematic tax-loss harvesting.
1. Restricted Stock Units (RSU) Taxation
Vesting triggers, ordinary income recognition, withholding deficits, and the 1099-B double taxation trap.
The 3 Lifecycle Milestones of an RSU
Company promises to award shares in the future subject to a vesting schedule (e.g., 4-year vest with 1-year cliff).
Shares become unconditionally yours. Fair Market Value (FMV) ร shares is immediately taxed as ordinary W-2 income.
When you sell the shares. Gain or loss is calculated as Sale Price โ Vesting FMV (Cost Basis).
Under IRS federal rules, your employer is only required to withhold a flat 22% for federal income tax on supplemental compensation up to $1,000,000 (37% above $1M). However, many software engineers and professionals have a marginal tax bracket of 32%, 35%, or 37%!
How to fix: Ask payroll/brokerage to increase your supplemental withholding rate to your true marginal bracket (32%, 35%, or 37%), or submit quarterly estimated tax payments via IRS Form 1040-ES.
Brokers (Morgan Stanley, E*TRADE, Charles Schwab, Fidelity) are prohibited by IRS regulations from reporting compensation income on Form 1099-B Box 1e (Cost Basis) for non-covered shares or certain RSUs. As a result, your 1099-B often shows $0.00 or an unadjusted cost basis!
If you naively import your 1099-B into TurboTax or tax software without adjusting it, you will pay taxes twice on the exact same money: once as W-2 salary at vest, and again as a 100% capital gain upon sale!
How RSUs Are Handled at Vest
The 4 primary company execution methods:
1. Sell-to-Cover (Most Popular)
The broker automatically sells just enough shares on the open market at vest to pay mandatory withholding taxes, depositing the remaining net shares into your brokerage account.
2. Net Share Settlement
The company surrenders shares back to corporate treasury to pay taxes instead of selling into the open market, depositing only net shares.
3. Same-Day Sale (Auto-Sell All)
All shares are immediately liquidated at vest. Taxes are withheld, and cash is deposited. Zero capital gain/loss is realized.
4. Cash Transfer
You wire out-of-pocket cash to cover tax withholdings to keep 100% of your vested shares intact.
"If your company handed you a cash bonus of $50,000 today after taxes, would you log into your brokerage and buy $50,000 of your employer's stock?"
If the answer is no, holding vested RSUs exposes you to excessive concentration risk (your paycheck and your portfolio depend on one firm). Selling immediately upon vest creates zero capital gain and allows instant diversification into index funds (e.g. VTI, VOO).
2. Employee Stock Purchase Plan (ESPP) Taxation
IRC ยง423 rules, 15% lookback discounts, qualifying vs. disqualifying dispositions, and Form 3922 tracking.
Built-in Arbitrage
Many plans offer up to a 15% discount applied to the lesser of the stock price on the Offering Date or the Purchase Date.
$25,000 / Calendar Year
IRC ยง423 caps your total purchases at $25,000 worth of stock per year, calculated using the undiscounted fair market value at the grant date.
IRS Form 3922
Your employer must issue Form 3922 for every purchase period, detailing Grant Date FMV, Purchase Date FMV, and actual purchase price.
Qualifying vs. Disqualifying Disposition Comparison
The tax treatment of your ESPP proceeds depends entirely on whether your sale meets the strict statutory two-prong holding period test.
| Feature | Qualifying Disposition (Held Long Enough) | Disqualifying Disposition (Sold Early) |
|---|---|---|
| Holding Period Required |
> 2 years from Offering Date (Grant) AND > 1 year from Purchase Date (Exercise) |
Sold before meeting BOTH 2-year and 1-year holding criteria. |
| Ordinary Income Recognized |
Lesser of: 1. Actual gain (Sale Price โ Purchase Price), OR 2. 15% discount applied to Grant Date FMV. If sold at a loss, Ordinary Income is $0! |
Exact discount at purchase: (Purchase Date FMV โ Purchase Price Paid) ร shares. Taxed as ordinary income even if the stock plummeted! |
| Capital Gain / Loss | Always Long-Term Capital Gain (LTCG) for all remaining profits above the ordinary income cap. | Can be Short-Term (if held ≤ 1 year from purchase) or Long-Term. Calculated as Sale Price โ Purchase Date FMV. |
| W-2 Inclusion | Employer may not include in W-2 Box 1; you must self-report on Schedule 1. | Usually automatically reported by employer in W-2 Box 1 as compensation. |
| Risk Profile | Higher market risk (forced to hold company stock for 12โ24 months). | Immediate risk-free discount lock-in if sold on day 1! |
- โข Grant FMV: $100 | Purchase FMV: $120
- โข 15% Lookback Price: $85 | Sold at: $150 (>2 yrs from grant)
- โข Total Profit: $150 โ $85 = $65
- โข Ordinary Income: Lesser of ($65 gain vs $15 discount) = $15
- โข Long-Term Capital Gain: $65 โ $15 = $50
- โข Grant FMV: $100 | Purchase FMV: $120
- โข 15% Lookback Price: $85 | Sold on Day 1 at: $120
- โข Total Profit: $120 โ $85 = $35
- โข Ordinary Income (W-2): $120 โ $85 = $35
- โข Capital Gain/Loss: $120 โ $120 = $0.00
- Result: Locked in 41.1% gain with zero downside market exposure!
3. Short-Term vs. Long-Term Capital Gains & Surtaxes
The 365-day holding clock, preferential federal tax rates, Net Investment Income Tax (NIIT 3.8%), and state disparities.
Tax Rate Differences
Taxed identically to regular salary and ordinary income. Subject to your highest marginal income tax bracket plus state income taxes.
Preferential federal rates. Single filers pay 0% up to ~$47,000, 15% up to ~$518,900, and 20% above that threshold.
Enacted under IRC ยง1411. An extra 3.8% tax on net investment income (dividends, interest, capital gains) if Modified Adjusted Gross Income (MAGI) exceeds $200,000 (single) or $250,000 (married filing jointly).
IRS Schedule D Capital Gain Netting Order
When you file taxes, the IRS mandates a strict 3-step sequential algorithm to net your gains and losses:
4. The Wash Sale Rule (IRC ยง1091)
The 61-day window, basis adjustments, RSU/ESPP auto-triggers, and the permanent IRA loss forfeiture trap.
What Triggers a Wash Sale?
Under IRS Section 1091, a wash sale occurs if you sell a security at a loss, and within a 61-day window (30 days before the sale, the day of the sale, and 30 days after the sale), you:
Buy the same company stock or substantially identical securities.
Acquire a call option, in-the-money put, or contract to buy.
An automatic RSU vest or ESPP buy occurs within 30 days of selling at a loss.
Note: A wash sale only applies to losses! If you sell at a profit and immediately buy back 5 seconds later, the IRS happily taxes your gain; there is no wash rule for winners.
What Happens to the Disallowed Loss in a Regular Taxable Account?
The loss is not permanently forfeited. Instead, two mechanics happen:
- Basis Adjustment: The disallowed dollar loss is added directly to the cost basis of the newly repurchased shares.
- Holding Period Tacking: The holding period of the original sold shares is added to the holding period of the replacement shares.
This is the single most expensive mistake investors make when attempting tax-loss harvesting:
If you sell shares at a loss in your regular taxable brokerage account, and purchase replacement shares inside your Traditional IRA or Roth IRA within the 61-day window:
1. The tax loss is disallowed on your tax return.
2. THE LOSS CANNOT BE ADDED TO YOUR IRA BASIS!
The tax deduction is permanently, completely vaporized into thin air. You can never reclaim it.
To harvest a loss without triggering a wash sale while staying 100% invested in the market:
5. Tax-Loss Harvesting & Loss Reclaim Concepts
Offsetting capital gains, the $3,000 W-2 income loss deduction, indefinite carryforward banks, and HIFO share selection.
1. Unlimited Capital Gain Shield
Realized capital losses offset realized capital gains dollar-for-dollar without any ceiling. If you made $80,000 in short-term crypto/stock gains and harvested $80,000 in losses, your net taxable capital gain is $0.
2. Ordinary Income Loss Reclaim
If your total realized capital losses exceed all your capital gains, you can deduct up to $3,000 per year ($1,500 if married filing separately) directly against your ordinary W-2 salary, reducing your highest-bracket tax burden.
3. Indefinite Loss Carryforward
Unused net losses roll forward to future tax years indefinitely until exhausted. A $50,000 loss can shield $10k gains today, offset $3k W-2 wages this year, and bank the remaining $37k to offset gains in 2027, 2028, and beyond.
โ๏ธ Broker Cost Basis Method: Avoid the "FIFO Default" Trap
HIFO > Specific ID > FIFOBy default, virtually all brokerage firms (Fidelity, Schwab, E*TRADE, Vanguard, Robinhood) set your default cost basis disposal method to FIFO (First-In, First-Out). When you sell shares, FIFO sells the oldest shares first, which typically have the lowest cost basis, generating the largest possible taxable gain!
Sells oldest shares first. Maximizes realized gains, increases tax liability. Worst for harvesting.
Sells newest shares first. Useful during sharp market drawdowns if recently purchased.
Recommended: Highest-In, First-Out automatically liquidates the highest cost basis lots first, minimizing gains or maximizing harvestable losses!
6. Startup Equity & Advanced Tax Strategies
Section 83(b) elections, ISO Alternative Minimum Tax (AMT), QSBS 100% exclusions, and safe harbor rules.
Section 83(b) Election
For pre-IPO startup equity or restricted stock. Must be filed with IRS within strictly 30 days of grant. Pay tax on negligible initial value now; all future appreciation converts to Long-Term Capital Gains.
ISO & Alternative Minimum Tax
Incentive Stock Options (ISOs) are non-taxable under regular income tax at exercise, but the spread is an AMT preference item. If stock crashes before sale, you may owe massive AMT on phantom gains!
QSBS (Section 1202)
Qualified Small Business Stock permits up to 100% federal capital gains exclusion (up to $10M or 10x basis) if acquired directly from a qualifying C-Corp and held for at least 5 years.
Safe Harbor Estimated Taxes
Avoid IRS underpayment penalties (Form 2210) on large equity sales by withholding 110% of prior-year total tax (for AGI > $150k) or 90% of current-year total tax liability across all quarters.
7. Interactive Equity & Stock Tax Calculators
Real-time simulation models for RSU vesting net proceeds, wash sale detection, and tax-loss harvesting.
๐ RSU Vesting Calculator
Net Proceeds๐ซ Wash Sale Simulator
IRC ยง1091The $30/share loss is added to the $75 replacement share, creating a new $105 tax cost basis.
๐พ Loss Reclaim Simulator
Schedule D8. Frequently Asked Questions
Clear answers to nuanced equity compensation, wash sale, and tax filing queries.
How do I know if my 1099-B reported my RSU cost basis as $0? โผ
Inspect your Form 1099-B or Consolidated 1099 Tax Statement from your brokerage (E*TRADE, Morgan Stanley, Schwab, Fidelity). Check Box 1e (Cost or other basis) for your RSU sales. You will also receive an accompanying document titled "1099-B Supplemental Information".
If Box 1e says $0.00, or is listed under "Non-covered securities," you must report the sale on IRS Form 8949 (Part II for long-term or Part I for short-term). Enter the broker's reported Box 1e in Column (e), enter code B in Column (f), and in Column (g) enter the negative adjustment representing your vesting FMV so the net gain in Column (h) accurately reflects only the post-vest appreciation.
Does automatic dividend reinvestment (DRIP) trigger a wash sale? โผ
Yes! An automatic dividend reinvestment is considered an intentional acquisition of replacement shares under IRC ยง1091. If you sell 1,000 shares of a stock at a loss on December 15, and on December 28 a quarterly dividend automatically buys 4.2 shares of that same stock, those 4.2 shares trigger a wash sale on 4.2 of your 1,000 loss shares!
To prevent this headache during active tax-loss harvesting, turn off dividend reinvestment (DRIP) on stocks or ETFs you intend to harvest, routing dividends to cash.
Why do most financial advisors recommend a "Disqualifying Disposition" for ESPP? โผ
While a Qualifying Disposition offers a modest tax advantage (capping ordinary income and converting the rest to LTCG), it forces you to hold a single company's stock for up to 2 years from grant and 1 year from purchase. Single-stock volatility frequently wipes out 20% to 50% of the stock's value during bear markets.
Selling immediately on purchase day (Disqualifying Disposition) guarantees an instant 17.6% pre-tax gain on a 15% discount without bearing market risk. You pay ordinary income tax on the discount, but you instantly lock in real cash and can diversify immediately.
Does the Wash Sale Rule apply to Cryptocurrency and Bitcoin? โผ
Under current IRS statutory definitions (IRC ยง1091), the wash sale rule applies to "stock or securities." Because the IRS classifies cryptocurrency as property rather than a stock or security (Notice 2014-21), crypto trades are not technically subject to statutory wash sales under federal law as of today.
However, the IRS economic substance doctrine (ยง7701(o)) still requires trades to have meaningful economic purpose besides tax evasion, and Congress has repeatedly proposed legislation to close this loophole.
What happens if I sell RSUs immediately at vesting? Are there any taxes? โผ
If you sell RSUs on the day they vest, you still owe full ordinary income tax on the entire vesting value (reported on your W-2). However, because your Sale Price equals your Vesting FMV (your Cost Basis), your capital gain or loss is virtually $0.00 (minus minor broker settlement transaction fees of a few pennies).
Related Educational Guides & Tools on aiagent.org
Income Tax Masterclass
Federal tax brackets, 401k/HSA pre-tax AGI reductions, and FIRE tax strategies.
Stock Valuation Masterclass
P/E ratios, PEG ratio velocity, profit margins, balance sheet debt, and equity metrics.
FIRE Retirement Calculator
Calculate safe withdrawal rates, portfolio longevity, and target retirement age.