Cost Basis Explained: FIFO, Average Cost, and Specific Lot (and Why It Changes Your Tax Bill)
What cost basis is, how FIFO, average cost, and specific lot identification work, worked examples with real math, and how to set a breakeven price alert on any position.
Most investors know what they paid for their first purchase of a stock. Far fewer know what number their broker will report when they sell, and the difference can move a tax bill by hundreds or thousands of dollars.
What Cost Basis Is
Cost basis is what you paid for your shares, including commissions and fees. When you sell, your taxable gain or loss is simply:
Sale proceeds - cost basis = capital gain (or loss)
If you bought 10 shares at $50 and paid a $0 commission, your basis is $500. Sell them at $80 for $800 and your gain is $300. That part is easy. The complexity starts when you bought the same stock more than once.
Why Multiple Purchases Complicate Things
Each purchase creates a tax lot: a batch of shares with its own date and price. Say you built a position in three steps:
| Lot | Date | Shares | Price | Cost |
|---|---|---|---|---|
| A | January | 10 | $50 | $500 |
| B | April | 10 | $70 | $700 |
| C | August | 10 | $90 | $900 |
You now hold 30 shares with a total cost of $2,100. Suppose you sell 10 shares at $100 ($1,000 proceeds). Which 10 shares did you sell? The answer depends on the method used.
The Three Main Methods
1. FIFO (First In, First Out)
FIFO assumes you sell the oldest shares first. It is the default at most US brokers for individual stocks.
- Shares sold: Lot A (basis $500)
- Gain: $1,000 - $500 = $500
In a rising market, FIFO sells your lowest-cost shares first, which produces the largest gain. The upside: oldest lots are more likely to qualify for long-term capital gains rates, which are generally lower than short-term rates.
2. Average Cost
Average cost blends all lots: $2,100 / 30 shares = $70 per share.
- Shares sold: 10 at an assumed $70 basis = $700
- Gain: $1,000 - $700 = $300
Average cost is the standard for mutual funds at many brokers and is simple to track, but it removes your ability to choose lots. Rules differ by account and security type, so confirm how your broker applies it.
3. Specific Lot Identification
You pick the lots. To minimize this year's gain, you sell the highest-cost lot.
- Shares sold: Lot C (basis $900)
- Gain: $1,000 - $900 = $100
| Method | Basis used | Taxable gain on a $1,000 sale |
|---|---|---|
| FIFO | $500 | $500 |
| Average cost | $700 | $300 |
| Specific lot (highest cost) | $900 | $100 |
Same trade, same shares, three different gains. The total gain over time is not erased, because the shares you did not sell keep their own basis, but you control when the tax is paid and whether it is short-term or long-term. See Capital Gains Tax for Investors for how the holding period changes the rate.
Practical note: specific lot selection usually has to be chosen with your broker at or before the time of sale. Check your account's default method and change it if it does not suit you. This is general education, not tax advice; a tax professional can confirm what applies to you.
What Adjusts Your Cost Basis
- Stock splits change your per-share basis but not your total. A 2-for-1 split turns 10 shares at $50 into 20 shares at $25.
- Reinvested dividends are new purchases, and each one adds to your basis. Forgetting this is a common way to overpay tax by counting the same money twice.
- Return-of-capital distributions reduce your basis.
- Wash sales can defer a loss by adding it to the basis of the replacement shares. See the wash sale rule explained.
- Gifted and inherited shares follow different basis rules than shares you bought.
Cost Basis Is Also a Risk Number
Tax aside, your average cost is the most emotionally important price on your chart: it is your breakeven. Investors tend to anchor on it, hold losers hoping to "get back to even," and sell winners too early to lock in a gain.
Turning it into a rule helps:
- Compute your average cost (total dollars paid, including fees, divided by shares).
- Set a breakeven alert at that price so you know when a losing position recovers, without checking every day.
- Set a downside alert at a level where your thesis is broken, for example a set percentage below your average cost. It pairs well with a stop-loss plan; see Stop-Loss Orders Explained.
- Set a profit alert at your target so a rally prompts a decision instead of a surprise.
Setting These Alerts in Stock Alarm
In Stock Alarm you can create a price alert for any symbol in a few taps: pick the ticker, choose "price rises above" or "price falls below," and enter your number. Use your average cost for breakeven, and levels above and below it for target and risk. The step-by-step is in How to Set Stock Price Alerts. You will be notified when the price crosses, so you can review the position (and the lot you would sell) with a clear head.
Common Mistakes
- Not knowing your broker's default method. FIFO is often the default, which may not be what you want.
- Ignoring fees when computing your breakeven.
- Double-counting reinvested dividends.
- Averaging down without tracking the new blended cost. Your breakeven moves every time you buy. See Dollar-Cost Averaging for how repeated buys change your average.
- Changing methods after the sale. Once a trade settles, the lot choice is generally final.
Related Reading
Stock Alarm on your phone
Set price alerts and follow the stocks you track in the Stock Alarm app for iPhone and Android.
Want alerts like these? Get started free.
Join 295,000+ traders using Stock Alarm to stay ahead of the market.
See it work — free
Track markets, screen stocks, and set price alerts with Stock Alarm Pro. Explore the live markets free — no account needed. Trusted by 295,000+ investors.
S&P 500 Screener
Filter by metrics, fundamentals
Price Alerts
Never miss a move
35+ Global Markets
Stocks, crypto, futures
AI Analysis
Ask questions, get answers
Live Terminal Charts, Multiples & Screeners for This Guide
Tickers, Interactive Charts & Fundamental Multiples
Head-to-Head Terminal Comparisons
Related Screeners & Market Trackers
Related Articles

Robo-Advisor vs. Self-Directed Investing: Costs, Control and Which Fits You
Robo-advisor or self-directed brokerage account? Compare fees, control and effort, see how a 1% fee compounds over 30 years, and learn how price alerts keep a DIY portfolio on track.
How to Monitor Your Stock Portfolio With Alerts (Without Watching Screens All Day)
A practical system for monitoring a stock portfolio using alerts instead of screen time: which four alert types to set, how many per position, and a weekly review that catches what alerts can't.
Position Sizing with Stock Alerts: A Risk Management Guide
Most traders focus on what to buy. The traders who survive long-term focus on how much to buy. This guide shows how to use stock alerts to enforce position sizing discipline automatically.