Buried in your brokerage settings is a default most investors have never looked at — and it decides, every single time you sell, which of your shares get sold and therefore how big the taxable gain (or harvestable loss) is. Two investors can sell the identical number of shares of the identical stock on the identical day and report wildly different tax outcomes, purely because of the cost-basis method their broker applied. This guide covers all five methods, when each one wins, and the wash-sale traps that can silently undo your tax planning.
The five methods at a glance
| Method | What it sells first | Ideal use case | The catch |
|---|---|---|---|
| FIFO First-In, First-Out | Oldest tax lots | Default / hands-off. Most likely to land long-term rates. | Oldest shares usually have the lowest basis → biggest gain in an appreciated stock. |
| LIFO Last-In, First-Out | Newest tax lots | Rising market — newest shares show the smallest paper gain. | Newest shares are almost always short-term → ordinary rates up to 37%. |
| HIFO Highest-In, First-Out | Most expensive lots | Tax-loss harvesting — maximizes losses / minimizes gains this year. | Ignores the calendar; can grab short-term lots. |
| Low Cost (LOFO) Lowest-In, First-Out | Cheapest lots | Tax-gain harvesting in the 0% LTCG bracket; charitable planning; burning off loss carryovers. | Realizes the biggest gain — only smart in specific situations. |
| Tax Lot Optimizer | Most tax-favorable lots, 4-bucket priority | The lowest current-year tax bill on most sales. | Optimizes this year — can defer bigger gains into future years. |
The Tax Lot Optimizer's priority order (popularized by Schwab) is worth memorizing: (1) short-term losses, largest first — they offset ordinary income; (2) long-term losses, largest first; (3) long-term gains, smallest first — taxed at the preferential 0/15/20% rate; (4) short-term gains, smallest first — taxed at your full ordinary rate, so they go last.
What your broker actually lets you pick
| Broker | Default | Can you change it? |
|---|---|---|
| Robinhood | FIFO | No. FIFO only — no account default change, no per-trade lot picking. |
| Schwab | FIFO | Yes — account-level default (incl. Tax Lot Optimizer) + per-trade specific-lot selection. |
| Fidelity | FIFO | Yes — account default + per-trade lot picking, incl. a "Tax-Sensitive" smart mode. |
| Vanguard | FIFO (avg cost on mutual funds) | Yes — SpecID unlocks per-lot control on ETFs and stocks. |
| E*TRADE | FIFO | Yes — account default + per-trade selection. |
The Robinhood row is the punchline: Robinhood always sells your oldest shares first and gives you no say in it. DiviDrip's Multi-Share Sell widget shows you what all five methods would do before you sell — so even Robinhood users can see the FIFO tax consequence in advance, and multi-broker users can pick the lot strategy their real broker supports.
Worked example — same sale, five different tax bills
Say you own 40 shares of a stock across four tax lots, and you sell 10 shares today:
- Lot A: 10 shares, bought 2 years ago at $40 (long-term)
- Lot B: 10 shares, bought 2 months ago at $60 (short-term)
- Lot C: 10 shares, bought 3 years ago at $120 (long-term)
- Lot D: 10 shares, bought 5 months ago at $150 (short-term)
Scenario 1 — stock at $100 (mixed gains and losses)
| Method | Lot sold | Result | Tax character |
|---|---|---|---|
| FIFO | Lot C (oldest) | −$200 loss | Long-term loss |
| LIFO | Lot B (newest) | +$400 gain | Short-term gain (ordinary rate) |
| HIFO | Lot D ($150 basis) | −$500 loss | Short-term loss (max deduction power) |
| Low Cost | Lot A ($40 basis) | +$600 gain | Long-term gain |
| Optimizer | Lot D (ST loss bucket) | −$500 loss | Short-term loss |
Scenario 2 — stock skyrockets to $200 (every lot profitable)
| Method | Lot sold | Gain | Approx. tax (15% LT / 24% ST) |
|---|---|---|---|
| Optimizer | Lot C (smallest LT gain) | +$800 | $120 |
| FIFO | Lot C (oldest) | +$800 | $120 |
| HIFO | Lot D | +$500 | $120 (smaller gain, but short-term rate) |
| LIFO | Lot B | +$1,400 | $336 — the worst pick by far |
Note the HIFO subtlety: the smallest dollar gain ($500) does not produce the smallest tax bill, because it's a short-term gain taxed at ordinary rates. Holding-period character matters as much as the dollar amount — this is exactly the trade-off the Optimizer's bucket order encodes.
Scenario 3 — stock crashes to $30 (harvesting the loss)
| Method | Lot sold | Loss harvested | Deduction power |
|---|---|---|---|
| HIFO / Optimizer | Lot D | −$1,200 short-term | Max — ST losses offset ordinary income first |
| FIFO | Lot C | −$900 long-term | Moderate |
| LIFO | Lot B | −$300 short-term | Minimal |
Harvested losses offset capital gains dollar-for-dollar, and up to $3,000 per year of leftover loss deducts against ordinary income (the rest carries forward indefinitely). See the full tax-loss harvesting playbook.
The wash-sale rule — three traps that undo your harvest
Selling at a loss only produces a deduction if you avoid a wash sale: buying the same (or a substantially identical) security within the 61-day danger window — 30 days before the sale, the sale day itself, and 30 days after. Trip the rule and the loss is disallowed and rolled into the new shares' basis (deferred) — or permanently destroyed if the repurchase happened inside an IRA.
- Trap 1 — the quick re-entry. You harvest a loss, the stock dips further three days later, and you "buy the dip." Wash sale. The deduction is gone for this year.
- Trap 2 — DRIP. Your dividend reinvestment plan buys a fractional share inside the window. That counts as a purchase and triggers a partial wash sale. Turn DRIP off on the ticker before harvesting.
- Trap 3 — the other account. The rule applies across all your accounts — a different broker, your IRA, even your spouse's account. Selling in taxable and re-buying in the Roth is the worst version: the loss is disallowed and can never be recovered through basis adjustment.
"Substantially identical" — the ETF substitution guide
| Swap | Wash-sale risk | Why |
|---|---|---|
| Same ticker, any account | Definite | Identical security. |
| GOOGL ↔ GOOG, BRK.A ↔ BRK.B | Definite | Different share class, same company. |
| Stock ↔ options on that stock | Definite | Options count as acquiring the position. |
| VOO ↔ SPY ↔ IVV | High | Same S&P 500 index — most pros treat these as substantially identical. |
| VOO → VTI | Generally safe | S&P 500 vs total-market — different index, ~13% different holdings weight. |
| VOO → QQQ or DIA | Safe | Different index entirely. |
| F → GM | Safe | Direct competitor, different issuer. |
The 31-day safe-swap-back timeline
- Day 0: sell the losing lot. Make sure no purchase of the same ticker happened in the prior 30 days (DRIP included).
- Days 1–30: the danger window. Hold cash or a non-identical substitute. Keep DRIP off.
- Day 31: safe to repurchase the original ticker. Calendar days, not business days — if Day 31 is a weekend or holiday, wait for the next market open.
Using the Multi-Share Sell widget in DiviDrip
DiviDrip tracks every buy as its own tax lot — which means a position built through years of DRIPs and partial buys can hold dozens of lots with different bases and holding periods. The Multi-Share Sell widget turns "sell 15 shares across 9 lots" from a manual fraction-counting exercise into one click:
- On your Portfolio page, expand any ticker row (or open the Stock Modal → My Portfolio tab) and click Sell Multiple Shares at the top of the lot list.
- Enter the share count and pick a method — is pre-checked because it's the IRS default and Robinhood's only behavior. Click any method name for its definition.
- Review the live preview: every lot that will be consumed, in order, with the estimated gain/loss split between short-term and long-term — plus a warning whenever the sale realizes a loss. Then click Execute sell.
DiviDrip is a tracker, not a broker — the widget updates your DiviDrip records and cash balance, and you place the matching trade with your real brokerage.
FAQ
- Which cost-basis method does the IRS use if I never pick one?
- FIFO — First-In, First-Out. If you (or your broker) don't specify a method before the trade settles, the IRS assumes your oldest shares were sold first. Robinhood goes a step further and only supports FIFO, with no override. Schwab, Fidelity, Vanguard, and E*TRADE all let you set a different default or pick lots per-trade.
- Can I change the cost-basis method after the sale settles?
- No. Lot identification must happen at or before settlement (typically T+1). Once the trade settles under one method, that's your tax reality for the year — the 1099-B your broker files with the IRS reflects it. This is exactly why previewing the tax consequence before you click sell matters so much.
- Does a DRIP reinvestment really trigger a wash sale?
- Yes. A dividend reinvestment is a purchase in the eyes of the IRS. If your DRIP buys even a fraction of a share within 30 days before or after you sell that ticker at a loss, the loss attributable to those replacement shares is disallowed (a partial wash sale). When harvesting a loss, turn DRIP off for the ticker and wait until Day 31 to re-enable it.
- Is selling VOO and immediately buying SPY a wash sale?
- Officially unsettled — the IRS has never published a bright-line rule for ETFs — but VOO, SPY, and IVV all track the identical S&P 500 index, so most tax professionals treat that swap as high-risk for the "substantially identical" test. The safe playbook: swap into a fund tracking a different index (VOO → VTI tracks total-market, VOO → QQQ tracks Nasdaq-100) or a direct competitor stock (F → GM), then swap back after Day 31 if you want the original exposure.
- Which method should a dividend investor actually use?
- For most sales, the Tax Lot Optimizer produces the lowest current-year tax bill: it consumes short-term losses first (they offset ordinary income), then long-term losses, then long-term gains (preferential 0/15/20% rate), and saves short-term gains for last. Use HIFO when you specifically want the maximum harvestable loss today, and Low Cost (LOFO) when you're intentionally realizing gains in the 0% long-term bracket. If your real broker is Robinhood, pick FIFO — that's what Robinhood will execute regardless of your preference.
Disclaimer: This is not tax advice. Cost-basis elections, wash-sale determinations, and the "substantially identical" test depend on your full personal situation, and broker execution can differ from the typical cases described here. Confirm specific moves with a CPA or Enrolled Agent before selling positions large enough to matter.
