Cost Basis Accounting Methods: minimize taxes When You Sell Your Stocks
Most investors focus on picking the right stocks. Far fewer pay attention to which shares they sell—and that oversight can cost real money. The IRS allows you to choose how your gains are calculated when you sell. If you don’t make a choice, the default method is applied automatically, and it’s rarely the one that saves you the most in taxes.
This article explains the main cost basis accounting methods, shows you how the numbers work with concrete examples, and walks through the steps you should take before your next sale.
What Is Cost Basis and Why It Matters for Your Taxes
Cost basis is the original purchase price of your shares, adjusted over time for events like stock splits and reinvested dividends. When you sell, the IRS uses this figure to determine your taxable gain or loss:
Gain or Loss = Sale Price − Cost Basis
This calculation only applies to taxable brokerage accounts. Shares held inside a 401(k), traditional IRA, or Roth IRA are not subject to capital gains tax at the time of sale, so cost basis method selection doesn’t apply there.
In a taxable account, the method you choose determines which shares are treated as sold first. Because you may have bought shares at different times and prices, this choice directly controls how large your taxable gain appears—and how much you owe. Choosing strategically can reduce your tax bill by hundreds or thousands of dollars on a single transaction.
The IRS formally recognizes three approaches: FIFO, Average Cost, and Specific Identification. HIFO and LIFO are variations that fall under the Specific Identification umbrella.
The 5 Main Cost Basis Methods Explained
1. FIFO (First In, First Out)
Your oldest shares are treated as sold first. It’s the simplest method to apply and the IRS default if you don’t specify otherwise. The downside: stocks held the longest tend to have the lowest cost basis, meaning the largest taxable gain. FIFO is rarely the most tax-efficient option for long-term investors with appreciated holdings.
2. LIFO (Last In, First Out)
Your most recently purchased shares are sold first. LIFO is widely used in business inventory accounting but is rarely optimal for stock sales. If your most recent purchases were made at higher prices and the stock has since dropped, LIFO might reduce gains—but in most appreciating markets, this method doesn’t offer a consistent advantage over other approaches.
3. HIFO (Highest Cost, First Out)
The shares with the highest purchase price are sold first, minimizing the current gain. This is a sound strategy when your primary goal is deferring taxes as long as possible. One caveat from Vanguard’s documentation: HIFO doesn’t account for holding period, which means it could trigger short-term capital gains rates (up to 37%) even when long-term shares are available.
4. Average Cost
All your purchase prices are blended into a single average cost per share. This simplifies record-keeping but gives you less control over your tax outcome. It’s the default method for mutual funds at most brokerages. Important IRS rule: once you switch to average cost for a particular fund, you generally cannot switch to another method for shares already covered under that election.
5. Specific Lot Identification (SLID)
You hand-pick exactly which shares to sell. This gives the most tax flexibility—you can target long-term shares, short-term loss lots, or any combination that fits your strategy. The trade-off is more administrative work. You must identify the lots at the time of sale and your brokerage must confirm the selection.
FIFO vs. Specific Identification: Real Numbers Show the Difference
Here’s a straightforward example that shows why method selection matters:
- You own 100 shares purchased two years ago at $50 each (long-term lot)
- You own 100 shares purchased 14 months ago at $80 each (also long-term)
- Current share price: $100
- You want to sell 100 shares
- Your long-term capital gains rate: 15%
Under FIFO (IRS Default)
The oldest shares—purchased at $50—are sold first.
- Gain per share: $100 − $50 = $50
- Total gain: $50 × 100 = $5,000
- Tax owed: $5,000 × 15% = $750
Under Specific Identification (targeting the $80 lot)
You select the higher-cost shares purchased at $80.
- Gain per share: $100 − $80 = $20
- Total gain: $20 × 100 = $2,000
- Tax owed: $2,000 × 15% = $300
Tax saved: $450 on a single 100-share sale.
If you don’t specify a method, your brokerage applies FIFO by default and the $450 difference is gone. This example uses a relatively small holding—the savings scale up significantly with larger positions or more complex portfolios.
➤ Free Guide: 5 Ways To Automate Your Retirement
How Holding Period Changes Your Tax Rate and Strategy
The method you choose interacts directly with how long you’ve held each share. The IRS taxes capital gains at different rates based on holding period:
- Long-term gains (held more than 1 year): 0%, 15%, or 20% depending on taxable income
- Short-term gains (held 1 year or less): Taxed as ordinary income, with a top federal rate of 37%
The holding period can matter more than the gain amount. A $3,000 short-term gain taxed at 32% costs $960. The same $3,000 gain at the 15% long-term rate costs $450. That’s more than a 2x difference in tax from the same dollar gain.
Specific Identification lets you deliberately manage this. For example:
- Sell short-term loss lots to offset short-term gains (which carry the highest tax rate)
- Hold long-term winners and let them continue to compound at favorable rates
- Avoid inadvertently selling a short-term lot when a long-term lot with a similar cost basis is available
HIFO, by contrast, ignores holding period entirely—a limitation worth understanding before relying on it.
Reinvested Dividends and Stock Splits: They Change Your Cost Basis
Two common events affect your cost basis in ways that investors often overlook.
Reinvested Dividends
When dividends are automatically reinvested, the reinvestment amount is added to your cost basis. This is actually a tax benefit: since you already paid income tax on those dividends when they were distributed, increasing the cost basis prevents you from being taxed on them again when you sell.
Example: You invest $5,000 in a stock and reinvest $500 in dividends over several years. Your adjusted cost basis becomes $5,500. If you later sell for $7,000, your taxable gain is $1,500—not $2,000.
Each reinvestment event creates a separate tax lot with its own purchase date and price per share. This matters for Specific Identification because you can target or avoid those lots strategically.
Stock Splits
A stock split increases the number of shares you hold but doesn’t change the total value of your investment—or your total cost basis. The per-share cost basis is simply recalculated.
Example: You own 100 shares with a $40 cost basis per share (total basis: $4,000). A 2-for-1 split doubles your shares to 200. Your new cost basis per share becomes $20. Total basis remains $4,000.
Brokerages adjust for splits automatically, but it’s worth verifying the accuracy of your cost basis records before a large sale—especially for older holdings or shares transferred from another institution.
Automated vs. Manual Methods: Tax Lot Optimizer and MinTax
If manually tracking every tax lot sounds burdensome, some brokerages offer automated tools that do the selection for you.
Tax Lot Optimizer (Charles Schwab)
Schwab’s Tax Lot Optimizer automatically selects shares to minimize your current tax liability. According to Schwab’s own guidance, this method can offer a high level of tax efficiency without requiring you to specify individual lots on each trade. It’s a strong option for investors who want tax-conscious selling without the administrative overhead of full Specific ID.
MinTax (Vanguard)
Vanguard’s MinTax method automatically selects lots based on the tax rate type—prioritizing long-term gains over short-term. However, Vanguard notes that MinTax prioritizes the type of gain, not the size of the gain. That means it could select a long-term lot with a large gain over a short-term lot with a tiny gain, which isn’t always optimal. MinTax also doesn’t factor in gifting strategies or long-term goals beyond the current transaction.
Full Specific Identification
Manual lot selection offers the most control but requires the most work. It’s best suited for investors with high-value holdings, complex portfolios, or specific tax strategies—particularly when working with a CPA who can identify the optimal combination of lots before each sale.
Practical recommendation: Use Tax Lot Optimizer or your brokerage’s equivalent automated tool for routine selling. If you have unrealized gains exceeding $10,000 in a single position, consult a CPA before selling—the advisory cost typically pays for itself in tax savings.
Common Cost Basis Mistakes and How to Avoid Them
Mistake 1: Defaulting to FIFO Without Thinking About It
FIFO is the IRS default. If you don’t choose a method, you get FIFO—and for most long-term investors with appreciated holdings, that means paying taxes on the largest possible gains. Take 10 minutes to confirm your account’s default method before your next sale.
Mistake 2: Losing Dividend Reinvestment Records
If you can’t document the cost of reinvested dividends, you can’t claim them as part of your basis. That means overpaying taxes on gains that were already taxed when the dividends were paid. Keep all brokerage statements and trade confirmations for at least seven years.
Mistake 3: Switching Away from Average Cost Mid-Stream
The IRS restricts method changes for shares already under an average cost election. Once you’ve used average cost for a particular mutual fund, you generally cannot apply a different method retroactively to those covered shares. Understand the method you’re using before committing to it.
Mistake 4: Triggering the Wash Sale Rule
If you sell shares at a loss and repurchase the same or substantially identical security within 30 days before or after the sale, the IRS disallows the loss deduction under the wash sale rule. This is a common error during tax-loss harvesting. If you want to lock in a loss, wait 31 days before rebuying, or buy a different but similar ETF in the interim.
Mistake 5: Reactive Selling Instead of Proactive Planning
Making a sell decision in December under time pressure leads to suboptimal lot selection. The best cost basis strategies are built throughout the year—reviewing unrealized gains and losses quarterly and planning sales around your tax situation, not the calendar.
What to Do Next: Select Your Cost Basis Method Before You Sell
Here are five concrete steps to take before your next sale in a taxable account:
- Check what methods your brokerage supports. Log in to Schwab, Vanguard, Fidelity, or wherever you hold your accounts and locate the cost basis settings. Not every brokerage offers every method. Confirm what’s available and what the current default is.
- Choose a default method for your account—or elect Specific ID for large sales. If you hold a diversified portfolio with many small lots, an automated method like Tax Lot Optimizer is practical. If you’re selling a large block of a single stock, Specific Identification is worth the extra effort. Document your election in writing.
- Verify the method used in every trade confirmation. After each sale, check the confirmation your brokerage sends to confirm it used the method you intended. Discrepancies are easier to correct immediately than after tax season.
- Retain all purchase records for at least seven years. This includes original purchase confirmations, dividend reinvestment statements, and any records of share transfers or corporate actions. These documents are your audit support.
- Consult a CPA before selling positions with gains over $10,000. A qualified tax advisor can identify which lots to sell, factor in your marginal rate, evaluate whether losses elsewhere can offset gains, and flag wash sale risks. The consultation fee is typically small relative to the tax savings on larger positions.
Bottom Line
Cost basis method selection is one of the few tax levers that investors fully control. The IRS won’t pick the method that saves you the most—it will apply FIFO by default, which is often the least favorable option for long-term investors.
Understanding the difference between FIFO, Average Cost, HIFO, and Specific Identification, and applying the right one before you sell, can reduce your capital gains tax on a single transaction by hundreds of dollars. Over a lifetime of investing, the cumulative savings are significant.
The mechanics aren’t complicated. The key is to act before the sale—not after.
This article is for informational purposes only and does not constitute personalized tax or investment advice. Consult a qualified tax professional for guidance specific to your situation.
