Stock Lot Cost Basis Calculator

Compute cost basis on a sale using FIFO, LIFO or average-cost methods.

Open tool

Overview

A stock-lot cost basis calculator computes the cost basis of shares sold when an investor holds multiple tax lots of the same security purchased at different prices and times. The IRS requires the seller to choose an identification method at or before sale; the choice changes the realised gain or loss and the holding period (which determines short-term versus long-term tax treatment). The three core methods are FIFO (first-in, first-out), LIFO (last-in, first-out), and average cost.

FIFO is the IRS default for stocks if no method is specified. It tends to maximise realised gain in a rising market because the oldest, cheapest lots are sold first. LIFO sells the most recent lots and is often more tax-efficient in a rising market. Average cost is mostly used for mutual funds and treats every share as having the same per-share basis. Specific lot identification (not modelled here) allows lot-level cherry-picking for maximum tax efficiency. This calculator runs all three so the user can compare them.

How it works

Given an ordered list of purchase lots (date, shares, price) and a sale of S shares: FIFO walks the lot list from oldest, consuming min(remaining_lot, S) from each, recording basis as price × consumed. LIFO walks from newest. Average cost computes a single basis: total_cost / total_shares, then applies it to all S sold shares. Realised gain is proceeds − consumed_basis for each method. Holding period for each consumed lot is determined by the lot's purchase date; long-term treatment requires more than one year.

Examples

  • Lots: 100 sh @ $20 (Jan), 100 sh @ $30 (Jun), 100 sh @ $40 (Nov). Sell 150 sh at $50.
  • FIFO consumes 100 @ $20 then 50 @ $30 → basis $3,500, proceeds $7,500, gain $4,000 (with mixed holding periods).
  • LIFO consumes 100 @ $40 then 50 @ $30 → basis $5,500, gain $2,000.
  • Average cost: total basis $9,000 / 300 shares = $30/share; 150 sold at $50 = basis $4,500, gain $3,000.

FAQ

Which method should I choose?
Depends on your overall tax position. LIFO often defers tax in a rising market; FIFO may be preferable to harvest long-term gains.

Can I switch methods between sales?
For stocks, you can identify specific lots at each sale before settlement. For mutual funds, once you elect average cost you generally cannot change for shares already covered.

Does this work for crypto?
The IRS guidance allows specific identification for crypto if records are adequate; otherwise FIFO is the safe default.

What about wash sales?
Wash-sale rules disallow losses if you repurchase within 30 days. The basis adjustment is layered on top of the lot accounting — this tool ignores wash sales.

Where does the broker get the basis on my 1099?
Brokers report basis for covered shares (those purchased after the broker-reporting effective date for that asset class). Pre-coverage shares require the investor to track basis independently.

Try Stock Lot Cost Basis Calculator

An unhandled error has occurred. Reload ×