Tax-Efficient Selling

Capital Gains Tax Lot Optimizer

Compare FIFO, LIFO, HIFO, and tax-loss harvesting strategies to find the optimal lots to sell and minimize your capital gains tax liability.

Your Tax Lots

Loading saved lots...

Sale Scenario

Selling Strategy

Tax Rate Assumptions:

Short-term: 24% (ordinary income)

Long-term: 15% (preferential rate)

Actual rates depend on your income bracket and filing status.

What is a Tax Lot Optimizer?

A tax lot optimizer is a financial planning tool that helps investors minimize their capital gains tax liability by strategically selecting which shares (tax lots) to sell. When you buy shares of a stock at different times and prices, each purchase creates a separate "tax lot" with its own cost basis and holding period. The choice of which lots to sell can significantly impact your tax bill.

This tool allows you to compare different lot selection strategies—FIFO, LIFO, HIFO, and tax-loss harvesting—to find the optimal approach for your specific situation. By understanding the tax implications before you sell, you can make more informed decisions and potentially save thousands of dollars in taxes.

How to Use This Tax Lot Optimizer

  1. Import Your Tax Lots: Upload a CSV or JSON file containing your trade history, or manually enter each purchase. Include the symbol, purchase date, price per share, quantity, and any fees paid.
  2. Set Up Your Sale Scenario: Select the stock symbol you want to sell, enter the expected sale date and price, and specify how many shares you plan to sell.
  3. Compare Strategies: The optimizer automatically calculates the tax implications for each strategy (FIFO, LIFO, HIFO, Tax-Loss Harvesting) and highlights the optimal choice.
  4. Review the Results: Examine the detailed breakdown showing which lots would be sold, the gain/loss on each, and the estimated tax for both short-term and long-term holdings.
  5. Export Your Analysis: Download a JSON report of your analysis for record-keeping or to share with your tax advisor.

Understanding Tax Lot Selection Strategies

FIFO (First In, First Out)

FIFO is the default method used by the IRS if you don't specify otherwise. Under FIFO, the oldest shares you purchased are sold first. This method often results in more long-term capital gains (taxed at lower rates) but may not minimize your overall tax bill if older shares were purchased at lower prices.

LIFO (Last In, First Out)

LIFO sells your most recently purchased shares first. This can be advantageous when recent purchases were made at higher prices, resulting in smaller gains or even losses. However, LIFO often produces more short-term gains, which are taxed at higher ordinary income rates.

HIFO (Highest In, First Out)

HIFO sells shares with the highest cost basis first, minimizing your capital gains regardless of when the shares were purchased. This strategy typically results in the lowest tax liability and is often the optimal choice for tax-conscious investors.

Tax-Loss Harvesting

Tax-loss harvesting prioritizes selling lots that are currently at a loss. These losses can offset capital gains from other investments, reducing your overall tax liability. You can deduct up to $3,000 in net capital losses against ordinary income each year, with excess losses carried forward to future years.

Why Cost Basis Tracking Matters

Accurate cost basis tracking is essential for tax-efficient investing. Your cost basis includes not just the purchase price but also any commissions, fees, or adjustments (such as reinvested dividends or stock splits). Without proper tracking, you may overpay taxes or face compliance issues with the IRS.

This tool stores your tax lot data locally in your browser using IndexedDB, ensuring your financial information never leaves your device. You can import data from your brokerage statements and build a comprehensive record of your holdings over time.

Short-Term vs. Long-Term Capital Gains

The holding period of your investment significantly impacts your tax rate:

  • Short-Term Capital Gains: Assets held for one year or less are taxed as ordinary income, with rates ranging from 10% to 37% depending on your tax bracket.
  • Long-Term Capital Gains: Assets held for more than one year qualify for preferential tax rates of 0%, 15%, or 20%, depending on your income level.

The optimizer automatically categorizes each lot based on the holding period and applies the appropriate tax rate to give you an accurate estimate of your tax liability.

Frequently Asked Questions

What is specific lot identification?

Specific lot identification (also called "specific ID") allows you to choose exactly which shares to sell, rather than following a predetermined method like FIFO. To use this method, you must identify the specific shares at the time of sale and receive written confirmation from your broker. This gives you maximum control over your tax situation.

Can I change my cost basis method?

Yes, but with limitations. You can generally choose your cost basis method for each sale, but once you've sold shares using a particular method, you cannot retroactively change it. For mutual funds and certain other investments, you may need to make an election that applies to all future sales.

How does the wash sale rule affect tax-loss harvesting?

The wash sale rule disallows a loss deduction if you purchase substantially identical securities within 30 days before or after the sale. If you trigger a wash sale, the disallowed loss is added to the cost basis of the replacement shares. This tool helps you identify loss-harvesting opportunities, but you should be aware of wash sale implications when executing trades.

Is my data secure?

Yes. All calculations are performed locally in your browser, and your tax lot data is stored in IndexedDB on your device. No financial data is ever sent to our servers. You can clear your data at any time using the "Clear All" button.

Should I consult a tax professional?

This tool provides estimates based on simplified tax assumptions. For complex situations involving significant gains, multiple investment types, or special circumstances, we recommend consulting a qualified tax professional who can provide personalized advice based on your complete financial picture.

Build Tax-Aware Trading Strategies

Now that you understand how to optimize your tax lots, take your investing to the next level. Use Pineify to build custom Pine Script strategies that factor in holding periods and tax efficiency directly in your TradingView charts.