Cost Basis Calculator

Free cost basis calculator - compute gain or loss per lot using FIFO, LIFO, or average cost methods for stocks, ETFs, and mutual funds.

Purchase Lots

$
$
$
$

Method Comparison

MethodCost BasisGain / Loss
FIFO (First In, First Out) $2,550.00+$2,250.00
LIFO (Last In, First Out) โ˜…$3,450.00+$1,350.00
Average Cost $3,030.00+$1,770.00
โ˜… = Lowest taxable gain (most tax-efficient for gains)
Total Shares Owned
100
Sum of all values
Total Cost
$5,050.00
All-in cost including fees
Avg Cost/Share
$50.50
Sale Proceeds
$4,800.00
60 shares ร— $80.00
Planning notes, formulas, and examples

About the Cost Basis Calculator

When you sell shares purchased at different times and prices, the lot-identification approach you use directly affects your taxable gain or loss. FIFO (first in, first out) sells the oldest shares first, reverse-order matching sells the newest shares first, and average cost spreads total basis evenly across all shares. Each approach can produce a different tax result.

Our Cost Basis Calculator lets you enter multiple purchase lots and a sale quantity, then compares the gain or loss under FIFO, a newest-lot comparison, and average cost. Use it to see how lot selection changes taxable results before you place a sell order. Tax-lot selection affects not just the current tax bill but also which low-basis or high-basis shares remain in the account after the trade.

When This Page Helps

Choosing the right basis method can materially change the taxable gain on a sale. Selling high-basis lots first reduces the current gain, while selling low-basis lots leaves more high-basis shares for later. This calculator makes those tradeoffs visible before you execute the order with your broker.

How to Use the Inputs

  1. Enter each purchase lot: date (for reference), number of shares, and price per share.
  2. Enter the number of shares you plan to sell.
  3. Enter the sale price per share.
  4. Review the gain or loss under FIFO, newest-lot comparison, and average cost methods.
  5. Choose the method that best fits your tax situation.
  6. Inform your broker of your lot selection method before or at the time of sale.
Formula used
FIFO: sell oldest lots first. Newest-lot comparison: sell newest lots first. Average Cost: basis per share = total cost of all shares / total shares owned. Gain = (Sale Price - Cost Basis) x Shares Sold.

Example Calculation

Result: FIFO gain: $2,250 / Newest-lot gain: $1,350 / Avg gain: $1,770

You own 100 shares in three lots. Selling 60 shares at $80: FIFO sells the 50 shares at $40 and 10 at $55 for a $2,250 gain. The newest-lot comparison sells 20 at $70, 30 at $55, and 10 at $40 for a $1,350 gain. Average cost basis is $50.50 per share, so the gain on 60 shares is $1,770. In this setup, selling the newest shares first produces the smallest gain.

Tips & Best Practices

  • FIFO is often the default when shares are not specifically identified; it often produces the largest gain in rising markets.
  • Specific identification through your broker offers the most flexibility; the newest-lot comparison here is a planning proxy rather than a filing election by itself.
  • Average cost is generally available for mutual-fund and DRIP shares, not every individual stock position.
  • Once you elect average cost for an eligible mutual fund, IRS rules can limit later changes.
  • Pair this calculator with a capital-gains tax tool if you want to compare the after-tax effect of each basis choice.
  • Keep detailed records of all purchase dates, quantities, and prices for accurate basis tracking.

Why Cost Basis Methods Matter

The way shares are identified for sale directly affects reported gain or loss. In a portfolio built through multiple purchases, the difference between FIFO and a higher-basis share selection can materially change the tax outcome.

FIFO vs. Newest-Lot Comparison vs. Average Cost

FIFO sells the oldest shares first. In steadily rising markets, those are often the cheapest shares and can create the largest gain. A newest-lot comparison does the opposite and shows what happens when the most recently purchased shares are used first. Average cost divides the entire portfolio cost by total shares and is mainly relevant for eligible fund holdings.

Practical Recommendations

For individual stocks and ETFs, specific identification with your broker gives the most control over which lots leave the account. For mutual funds in taxable accounts, average cost is commonly available and simplifies record-keeping. In tax-advantaged accounts, basis method is usually less important because the account structure drives the tax treatment.

Sources & Methodology

Last updated:

Methodology

This calculator totals the entered purchase lots, then compares three basis scenarios for the entered sale quantity: oldest lots first (FIFO), newest lots first, and average cost. It multiplies the shares sold by the entered sale price to compute proceeds, then subtracts the selected basis to show gain or loss under each scenario.

The newest-lot comparison is a planning aid, not a substitute for broker-level specific identification. For individual stocks, actual tax reporting depends on the lot-identification method your broker records for the sale. Average-cost rules are also narrower for individual securities than for mutual-fund or DRIP shares.

Sources

Frequently Asked Questions

  • Cost basis is the original purchase price of an investment plus adjustments such as commissions or reinvested amounts where applicable. It is subtracted from sale proceeds to determine capital gain or loss for tax purposes.