FIFO & Cost Basis

How to Calculate Cost Basis with Multiple Buys: FIFO Step-by-Step Guide

10 min read ยท Updated 22 February 2026

Why Multiple Purchases Make Cost Basis Complicated

If you buy a stock once and sell it once, calculating capital gains is trivial. Sale price minus purchase price. But most investors do not buy a stock just once. They buy in tranches, adding to positions over months or years as they accumulate conviction or when prices dip.

Each separate purchase creates a distinct lot with its own cost per share and holding period start date. When you sell, FIFO requires you to match the sale against the oldest lot first, then the next oldest, and so on. This lot-matching process is the heart of cost basis computation in India.

The complication arises when a single sale spans multiple lots. You sell 150 shares, but your oldest lot has only 80 shares. The first 80 come from Lot 1 at one price, the next 70 come from Lot 2 at a different price. Each portion may have a different holding period classification (short-term or long-term), resulting in different tax treatments within a single sale.

This article provides a methodical, step-by-step approach to computing cost basis when you have multiple purchase lots. We will work through progressively complex examples, from simple two-lot scenarios to multi-lot partial sales with mixed holding periods.

Step 1: Build Your Lot Register

The first step is to create a chronological list of all purchase lots for the stock. Each lot needs four pieces of information:

  • Purchase date
  • Quantity purchased
  • Price per share
  • Total cost (quantity x price)

Let us build a lot register for a hypothetical Tata Consultancy Services (TCS) position:

  • Lot 1: 15 January 2024, 50 shares at Rs 3,800, total Rs 1,90,000
  • Lot 2: 10 June 2024, 100 shares at Rs 4,000, total Rs 4,00,000
  • Lot 3: 5 January 2025, 75 shares at Rs 3,600, total Rs 2,70,000

Total holding: 225 shares. Average price: Rs 3,822.22.

Notice that Lot 3 was purchased at a lower price than Lots 1 and 2. This often happens when investors buy during a dip. The average price reflects this blend, but FIFO does not use the average.

Important: Always include brokerage, STT, and other transaction charges in the cost per share. These charges are part of the cost of acquisition. For simplicity in our examples, we use round numbers, but in practice you should add all charges to each lot's cost.

Step 2: Match the Sale Against Lots (FIFO)

Now suppose you sell 80 shares of TCS at Rs 4,200 on 20 March 2025.

Apply FIFO:

  1. Start with Lot 1: 50 shares at Rs 3,800. Consume all 50 shares. Remaining to match: 80 - 50 = 30 shares.
  1. Move to Lot 2: 100 shares at Rs 4,000. Consume 30 shares. Remaining to match: 30 - 30 = 0 shares. Lot 2 retains 70 shares.

The 80 shares sold break down as: - 50 shares from Lot 1 at Rs 3,800 - 30 shares from Lot 2 at Rs 4,000

Now compute the gain for each portion:

Lot 1 portion: 50 x (Rs 4,200 - Rs 3,800) = 50 x Rs 400 = Rs 20,000 Holding period: 15 Jan 2024 to 20 Mar 2025 = 14 months (long-term) Classification: LTCG = Rs 20,000

Lot 2 portion: 30 x (Rs 4,200 - Rs 4,000) = 30 x Rs 200 = Rs 6,000 Holding period: 10 Jun 2024 to 20 Mar 2025 = 9 months (short-term) Classification: STCG = Rs 6,000

Total gain from this sale: LTCG Rs 20,000 + STCG Rs 6,000 = Rs 26,000.

Note that a single sale produced both LTCG and STCG, each taxed at different rates.

Step 3: Update the Lot Register After the Sale

After the sale, your lot register must be updated to reflect the consumed shares:

  • Lot 1: 0 shares remaining (fully consumed)
  • Lot 2: 70 shares at Rs 4,000 (partially consumed; 30 of 100 sold)
  • Lot 3: 75 shares at Rs 3,600 (untouched)

Total remaining holding: 145 shares.

This updated register is your starting point for the next sale. The next time you sell TCS shares, FIFO will start from Lot 2 (the oldest remaining lot) and consume from there.

It is critical to update the register after every sale. If you forget to remove consumed lots, future FIFO calculations will be wrong, potentially assigning incorrect cost basis and holding periods.

Also note that the 70 remaining shares in Lot 2 retain their original purchase date of 10 June 2024. Their holding period continues from that original date, not from the date of the partial sale. By 10 June 2025, these 70 shares will transition from short-term to long-term.

If you use TaxHarvestLab, the lot register is updated automatically after each sale. The tool maintains a running FIFO ledger that you can inspect at any time to see your exact lot structure for every stock.

Complex Example: Sale Spanning Three Lots

Let us consider a more complex scenario. You hold Bajaj Finance with these lots:

  • Lot A: 30 shares at Rs 6,000, bought 1 February 2023
  • Lot B: 50 shares at Rs 7,000, bought 15 September 2023
  • Lot C: 40 shares at Rs 6,500, bought 1 April 2024
  • Lot D: 20 shares at Rs 7,500, bought 1 December 2024

Total: 140 shares. You sell 100 shares at Rs 7,200 on 1 March 2025.

FIFO matching: - Lot A: 30 shares consumed. Remaining to match: 70. - Lot B: 50 shares consumed. Remaining to match: 20. - Lot C: 20 of 40 shares consumed. Remaining to match: 0.

Gain computation:

Lot A (30 shares): Gain = 30 x (7,200 - 6,000) = Rs 36,000. Holding: 25 months. LTCG. Lot B (50 shares): Gain = 50 x (7,200 - 7,000) = Rs 10,000. Holding: 17 months. LTCG. Lot C (20 shares): Gain = 20 x (7,200 - 6,500) = Rs 14,000. Holding: 11 months. STCG.

Total: LTCG = Rs 46,000, STCG = Rs 14,000.

Tax (assuming exemption available): LTCG within exemption = Rs 0 tax. STCG at 20% = Rs 2,800.

Remaining lots: Lot C has 20 shares at Rs 6,500, Lot D has 20 shares at Rs 7,500.

Handling Edge Cases: Same-Day Purchases and Zero-Quantity Lots

Real portfolios introduce edge cases that the basic FIFO procedure must handle:

Same-day multiple purchases: If you bought shares of the same stock twice on the same day (perhaps in two market orders), these are typically combined into a single lot with a weighted average price for that day. This is because the holding period start date is identical, so there is no FIFO ordering to resolve within the same day.

Zero-quantity lots after full consumption: Once a lot is fully consumed by a sale, it should be removed from the active lot register. Keeping it as a zero-quantity entry causes no harm computationally but adds clutter. Clean lot registers are easier to audit.

Transfer between demat accounts: If you transfer shares from one demat account to another (say, from Groww to Zerodha), the lots carry over with their original purchase dates and prices. The transfer itself is not a taxable event. Your FIFO lot register should reflect the original purchase information, not the transfer date.

Rebuying after selling: If you sell shares and then buy the same stock again, the new purchase starts a fresh lot. It does not merge with any previous lot. The lot register simply gets a new entry at the bottom.

Dividend Reinvestment Plans (DRIPs): Shares acquired through DRIPs are separate lots with the purchase date being the date of acquisition and the cost being the price at which shares were allotted. These enter the FIFO queue chronologically alongside other purchases.

Using a FIFO Cost Basis Table

LotBuy DateQtyCost/ShareSoldRemainingHolding Period
115 Jan 202450Rs 3,80050014 months (LT)
210 Jun 2024100Rs 4,00030709 months (ST)
305 Jan 202575Rs 3,6000752 months (ST)
Sale: 80 shares at Rs 4,20080145
A visual table like the one above is the clearest way to present your FIFO lot matching. When filing your ITR, Schedule CG requires you to report capital gains separately for short-term and long-term. Having a table for each stock makes it straightforward to fill in the correct figures. For this particular sale: - LTCG = Rs 20,000 (from Lot 1) - STCG = Rs 6,000 (from Lot 2) You would report these in separate sections of Schedule CG. The LTCG gets the benefit of the Rs 1.25 lakh exemption, while the STCG is taxed at 20%. TaxHarvestLab generates these lot-matching tables automatically for every stock in your portfolio. You can export them as part of your tax documentation, making ITR filing significantly simpler.

Key Takeaways: Mastering Multi-Lot Cost Basis

Calculating cost basis with multiple purchases is a systematic process. Here is the workflow in brief:

  • Maintain a chronological lot register for each stock, recording date, quantity, and cost per share.
  • When you sell, apply FIFO by consuming lots from oldest to newest.
  • If a sale spans multiple lots, compute the gain or loss for each lot separately.
  • Classify each lot's gain as STCG or LTCG based on the holding period from the lot's purchase date to the sale date.
  • Update the lot register after every sale by removing fully consumed lots and reducing partially consumed ones.
  • Include transaction charges (brokerage, STT, etc.) in the cost of each lot for accurate gain computation.

The complexity scales with the number of lots and sales, but the method is always the same. Whether you have 2 lots or 20, the FIFO procedure is identical: start from the oldest, consume, move to the next.

For investors with active portfolios spanning dozens of stocks and hundreds of transactions, manual lot tracking is impractical. TaxHarvestLab automates the entire process, from parsing your broker's trade data to generating lot-level FIFO computations for every realized and unrealized position.

See how this applies to your portfolio

Upload your Zerodha or Groww reports and get personalized recommendations in under 2 minutes.

Analyze My Portfolio Free

Frequently Asked Questions

Can a single sale result in both short-term and long-term capital gains?

Yes. When a sale spans multiple lots under FIFO, each lot's holding period is evaluated independently. If the oldest lots are over 12 months old (long-term) and the newer lots are under 12 months (short-term), the single sale produces both LTCG and STCG, each taxed at different rates.

Should I include brokerage charges in the cost basis?

Yes. Brokerage, Securities Transaction Tax (STT), stamp duty, and other transaction charges paid during purchase should be added to the cost of acquisition. Similarly, charges paid during the sale can be deducted from the sale proceeds. This reduces your taxable capital gain.

What happens if I bought the same stock through two different brokers?

FIFO applies across your entire holding of a stock, regardless of which broker or demat account was used. All purchase lots from all brokers should be combined into a single chronological lot register for that stock. The oldest lot across all accounts is sold first.

How do I track lot registers for 30+ stocks in my portfolio?

Manual tracking for large portfolios is impractical and error-prone. TaxHarvestLab automates this by importing your trade history from brokers like Zerodha and building lot registers for every stock. It handles partial sales, lot consumption, and real-time lot status across your entire portfolio.

๐Ÿค

Support Our Mission

TaxHarvestLab is free and always will be. Help us keep it that way for 10,000+ Indian investors.

10K+
Active Users
โ‚น0
Ads โ€ข Ever
Contribute Nowโ†’

One-time or monthly, your choice

Ready to optimize your capital gains tax?

TaxHarvestLab analyzes your actual broker data and shows you exactly what to sell โ€” and what to hold โ€” before March 31.

Analyze My Portfolio Free

Free forever. Works with Zerodha and Groww. Takes under 2 minutes.