Capital Gains Tax Basics

How to Calculate Capital Gains on Stocks: Step-by-Step Guide

11 min read read ยท Updated 22 February 2026

The Five Steps to Calculate Capital Gains

Calculating capital gains on Indian stocks involves five sequential steps. Each step feeds into the next, and getting any one wrong can result in incorrect tax calculation. Here is the complete framework before we dive into each step in detail.

Step 1: Identify the holding period for each lot of shares sold. This determines whether the gain is short-term or long-term.

Step 2: Determine the cost basis using the FIFO (First In, First Out) method. The shares purchased earliest are deemed sold first.

Step 3: Calculate the raw gain or loss. Gain = Sale Price minus Cost of Acquisition minus Transfer Expenses.

Step 4: Apply exemptions. For LTCG, apply the Rs 1.25 lakh annual exemption under Section 112A. For STCG, no exemption is available.

Step 5: Apply the applicable tax rate. STCG at 20% under Section 111A or LTCG at 12.5% under Section 112A, plus 4% cess and applicable surcharge.

Let us work through each step with examples. Throughout this guide, we will use a running example of an investor named Amit who has made multiple purchases of Reliance Industries shares and is selling some of them.

Step 1: Identify the Holding Period

The holding period determines whether your gain is classified as STCG or LTCG. For listed equity shares, the threshold is 12 months.

Holding period = Date of sale minus Date of purchase

If the holding period is 12 months or less, the gain is short-term. If it exceeds 12 months, the gain is long-term. Note that it must exceed 12 months, not merely equal 12 months.

For our running example, Amit made these purchases of Reliance shares: - Lot A: 50 shares on 15th January 2025 at Rs 1,200 - Lot B: 100 shares on 20th June 2025 at Rs 1,350 - Lot C: 75 shares on 10th November 2025 at Rs 1,280

Amt sells 120 shares on 20th March 2026 at Rs 1,500 per share.

Holding periods: - Lot A: 15th Jan 2025 to 20th March 2026 = approximately 14 months. This exceeds 12 months so it is LTCG. - Lot B: 20th June 2025 to 20th March 2026 = 9 months. This is 12 months or less, so it is STCG. - Lot C: Not used in this sale (FIFO takes Lot A and Lot B first).

The holding period must be computed separately for each lot because different lots may have different classifications. A single sell order can generate both STCG and LTCG simultaneously.

Step 2: Determine the Cost Basis Using FIFO

India mandates the FIFO (First In, First Out) method for determining which shares are sold when you hold multiple lots of the same stock. Under FIFO, the shares purchased first are considered sold first.

Continuing Amit's example โ€” he is selling 120 shares and holds: - Lot A: 50 shares (purchased 15th January 2025) - Lot B: 100 shares (purchased 20th June 2025) - Lot C: 75 shares (purchased 10th November 2025)

Under FIFO, the 120 shares sold come from: - All 50 shares from Lot A (cost: Rs 1,200 each) - 70 shares from Lot B (cost: Rs 1,350 each)

Lot C is not touched because Lots A and B together provide 120 shares (50 + 70). After the sale, Amit retains: - 30 shares from Lot B (purchased 20th June 2025) - 75 shares from Lot C (purchased 10th November 2025)

The cost basis includes the purchase price plus brokerage and other charges paid at the time of buying. For simplicity, we will assume brokerage is negligible (as with discount brokers charging Rs 20 flat per order).

Important: Many brokers display an average cost price in your holdings. This average price is not the correct cost basis for tax purposes. You must use FIFO. The average price is useful for tracking overall portfolio performance but has no relevance for tax calculations. Using average price instead of FIFO is a common mistake that leads to incorrect tax computation.

Step 3: Calculate the Raw Gain or Loss

With the holding period and cost basis identified, calculating the gain is straightforward.

Capital Gain = Sale Price - Cost of Acquisition - Expenses on Transfer

For Amit's sale of 120 shares at Rs 1,500 each:

From Lot A (50 shares, LTCG): - Sale price: 50 x Rs 1,500 = Rs 75,000 - Cost of acquisition: 50 x Rs 1,200 = Rs 60,000 - Gain: Rs 75,000 - Rs 60,000 = Rs 15,000 (LTCG)

From Lot B (70 shares, STCG): - Sale price: 70 x Rs 1,500 = Rs 1,05,000 - Cost of acquisition: 70 x Rs 1,350 = Rs 94,500 - Gain: Rs 1,05,000 - Rs 94,500 = Rs 10,500 (STCG)

Total sale value: Rs 1,80,000 Total cost: Rs 1,54,500 Total LTCG: Rs 15,000 Total STCG: Rs 10,500

Notice how a single sale transaction generates both LTCG and STCG due to different holding periods of different lots. Your broker's capital gains statement will typically show this breakdown, but it is important to verify the calculations independently. Expenses on transfer (brokerage on sale, exchange charges, GST) should be allocated proportionally to each lot if material.

Step 4: Apply Exemptions and Set-Offs

After computing the raw gains, you apply available exemptions and set-offs to arrive at the taxable amount.

LTCG exemption under Section 112A: The first Rs 1.25 lakh of LTCG in a financial year is exempt from tax. Amit's LTCG of Rs 15,000 is well within this limit, so his taxable LTCG is Rs 0. He has Rs 1,10,000 of exemption remaining for other LTCG during the year.

STCG has no exemption under Section 111A. Amit's full STCG of Rs 10,500 is taxable.

Set-off of losses: If Amit has capital losses from other transactions in the same financial year, he can set them off. The rules are: - Current year STCL can offset STCG first, then remaining STCL can offset LTCG - Current year LTCL can offset only LTCG - Carried-forward STCL (from previous 8 years) can offset STCG and LTCG - Carried-forward LTCL (from previous 8 years) can offset only LTCG

Suppose Amit also sold another stock at a short-term loss of Rs 4,000. He can offset this Rs 4,000 STCL against his Rs 10,500 STCG, reducing taxable STCG to Rs 6,500.

The order of set-off matters: First set off current year losses against current year gains, then apply carried-forward losses. Among carried-forward losses, the oldest are utilized first.

Step 5: Apply the Tax Rate

The final step is applying the applicable tax rate to arrive at your tax liability.

Continuing Amit's example after set-offs: - Taxable LTCG: Rs 0 (within Rs 1.25 lakh exemption) - Taxable STCG: Rs 6,500 (after offsetting Rs 4,000 STCL)

STCG tax = Rs 6,500 x 20% = Rs 1,300 Health and education cess = Rs 1,300 x 4% = Rs 52 Total tax = Rs 1,352

For a more substantial example, consider an investor with: - LTCG: Rs 3,50,000 - STCG: Rs 2,00,000 - No losses to set off

LTCG tax: (Rs 3,50,000 - Rs 1,25,000) x 12.5% = Rs 2,25,000 x 12.5% = Rs 28,125 STCG tax: Rs 2,00,000 x 20% = Rs 40,000 Total base tax: Rs 68,125 Cess at 4%: Rs 2,725 Total tax: Rs 70,850

If this investor had used tax-loss harvesting to offset Rs 1 lakh of their STCG, they would save Rs 20,000 in STCG tax plus Rs 800 in cess, a total saving of Rs 20,800. And if they had used gain harvesting to book their LTCG incrementally within the Rs 1.25 lakh exemption each year, their LTCG tax could have been substantially lower.

Complete Worked Example: Multiple Stocks

Let us work through a comprehensive example with multiple stocks to illustrate the full process.

Meera's transactions in FY 2025-26:

Stock 1 - Infosys: - Bought 200 shares at Rs 1,400 on 1st Feb 2025 - Sold 200 shares at Rs 1,650 on 1st May 2026 - Holding period: 15 months (LTCG) - Gain: 200 x Rs 250 = Rs 50,000 (LTCG)

Stock 2 - HDFC Bank: - Bought 150 shares at Rs 1,600 on 1st Aug 2025 - Sold 150 shares at Rs 1,750 on 15th Jan 2026 - Holding period: 5.5 months (STCG) - Gain: 150 x Rs 150 = Rs 22,500 (STCG)

Stock 3 - Tata Motors: - Bought 100 shares at Rs 900 on 1st June 2025 - Sold 100 shares at Rs 750 on 1st Dec 2025 - Holding period: 6 months (STCL) - Loss: 100 x Rs 150 = Rs 15,000 (STCL)

Net LTCG: Rs 50,000 (within Rs 1.25L exemption, so taxable LTCG = Rs 0) Gross STCG: Rs 22,500 STCL set-off: Rs 15,000 Net taxable STCG: Rs 22,500 - Rs 15,000 = Rs 7,500

STCG tax: Rs 7,500 x 20% = Rs 1,500 Cess: Rs 60 Total tax: Rs 1,560

By strategically selling the loss-making Tata Motors position, Meera reduced her STCG tax from Rs 4,680 to Rs 1,560, saving Rs 3,120.

Tools and Tips for Accurate Calculation

Calculating capital gains manually can be tedious, especially if you have hundreds of transactions. Here are practical approaches to ensure accuracy.

Use your broker's capital gains statement. Zerodha, Groww, Angel One, and most brokers provide a tax P&L report or capital gains statement that lists all your transactions with FIFO-based cost, holding period classification, and gain/loss amounts. Download this from your broker's console at the end of the financial year.

Verify with your AIS (Annual Information Statement). The Income Tax Department now provides an AIS that lists all your reported financial transactions, including share transactions. Cross-reference your broker's statement with your AIS to ensure nothing is missing.

Use TaxHarvestLab for real-time tracking. Upload your holdings to TaxHarvestLab to see your current unrealized gains and losses classified by STCG and LTCG. This helps you make informed decisions about which stocks to sell before the financial year ends.

Maintain your own records. Keep a spreadsheet with purchase date, purchase price, quantity, and broker for each lot. This is essential if you trade across multiple brokers, as each broker only has visibility into transactions on their platform.

Remember that corporate actions like bonus issues, stock splits, and rights issues change your cost basis and lot structure. Track these events carefully as they are a common source of calculation errors.

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

Do I need to calculate capital gains separately for each stock?

Yes. Capital gains must be calculated individually for each stock sold. Each stock may have different purchase dates, different cost bases, and different holding periods. The FIFO rule is applied per stock (per ISIN), not across your entire portfolio. Your final tax is computed on the aggregate of all STCG and LTCG after set-offs.

Can I use average cost instead of FIFO for tax calculation?

No. The Income Tax Act mandates the FIFO (First In, First Out) method for determining cost of acquisition when you hold multiple lots of the same stock. While your broker may display an average cost in your portfolio view, this is for your informational purpose only. Using average cost for tax calculation is incorrect and could lead to discrepancies during assessment.

How do I calculate capital gains if I bought shares before 31st January 2018?

For shares acquired before 1st February 2018, the cost of acquisition for LTCG under Section 112A is the higher of (a) the actual purchase price or (b) the fair market value as on 31st January 2018 (the highest traded price on that date). This grandfathering provision ensures that gains accrued before 1st February 2018 are not taxed under the LTCG regime.

Are brokerage charges deductible when calculating capital gains?

Yes. Brokerage paid on purchase can be added to the cost of acquisition, and brokerage paid on sale can be treated as expenses on transfer. Both reduce your taxable capital gain. However, STT (Securities Transaction Tax) is not deductible from capital gains. With discount brokers charging Rs 20 per order, the impact is small but still worth claiming for accuracy.

๐Ÿค

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.