How to Calculate Your Capital Gains

💡 Your real profit isn’t what your brokerage shows — it’s what’s left after capital gains tax, and a stock tax calculator helps you figure that out before you sell.

The Formula You Actually Need

It sounds complicated. It isn’t.

Here’s the core formula for calculating capital gains on a stock sale:

Capital Gain = Sale Proceeds − Cost Basis

And your cost basis isn’t just what you paid per share. It includes commissions, transaction fees, and any other costs directly tied to the purchase. Same goes for the sale side — you can subtract fees from your proceeds. These small numbers matter more than you’d think across multiple trades.

Let’s say you bought 50 shares at $30 each with a $5 commission. Your cost basis is $1,505, not $1,500. If you later sell those 50 shares at $45 with another $5 commission, your net proceeds are $2,245. Your taxable gain is $2,245 − $1,505 = $740.

💡 Always include transaction fees in your cost basis — it legally reduces your taxable gain and many investors forget to do this.

Multi-Trade Tracking: Where It Gets Messy

One trade is easy. Ten trades across three different stocks, some bought in multiple lots at different prices? That’s where most investors start making errors.

A friend of mine who manages a mid-sized personal portfolio told me he spent an entire weekend last tax season manually reconstructing cost bases because he hadn’t tracked his purchases through the year. He estimated he overpaid by roughly $200 because he couldn’t verify his actual basis on one position and defaulted to the average — which wasn’t optimal for him.

This is exactly the use case a stock tax calculator was built for.

Modern stock tax calculators (many are free, built into platforms like TurboTax, H&R Block, or standalone tools like TaxAct and even some brokerage dashboards) let you input your buy and sell dates, share counts, prices, and fees. They spit out your short-term and long-term gain breakdowns automatically. Some even pull your brokerage data directly.

Tool Type Best For Cost
Brokerage built-in (Fidelity, Schwab, etc.) Trades within that platform Free
Tax software (TurboTax, H&R Block) End-of-year filing with multiple brokerages Paid (varies)
Crypto/stock trackers (Koinly, TaxBit) Complex portfolios, frequent traders Free tier + paid plans
Spreadsheet (manual) Simple portfolios, full control Free

FIFO vs. Specific Identification: It Changes Your Number

Here’s the part most tutorials skip.

When you’ve bought the same stock multiple times at different prices (called “tax lots”), the IRS lets you choose which shares you’re selling. The two main methods:

  • FIFO (First In, First Out) — You sell your oldest shares first. Simple, and the IRS default if you don’t specify.
  • Specific Identification — You choose exactly which lot to sell, which lets you minimize gains (or maximize losses for tax-loss harvesting).

The difference can be hundreds of dollars in a given year. Most stock tax calculators let you toggle between methods and show you the outcome side-by-side. That alone can justify using one.

flowchart TD
    A[Start: You Sell Shares] --> B[Identify Cost Basis Method]
    B --> C{Method Chosen?}
    C -->|FIFO| D[Use Oldest Purchase Price]
    C -->|Specific ID| E[Choose Which Lot to Sell]
    C -->|Average Cost| F[Average All Purchase Prices]
    D --> G[Calculate: Proceeds − Basis]
    E --> G
    F --> G
    G --> H[Apply Tax Rate\nShort-term or Long-term]
    H --> I[= Capital Gains Tax Owed]

Running Three Real Scenarios

Numbers make this concrete. Here are three quick calculations across different situations.

Scenario A — Single lot, long-term hold: You bought 20 shares at $50 ($1,000 total, $5 commission = $1,005 basis). You sell 14 months later at $75 ($1,500 gross, $5 commission = $1,495 proceeds). Gain: $490. At 15% long-term rate: $73.50 tax owed.

Scenario B — Same trade, short-term: Exact same numbers but you sold after 9 months. If you’re in the 22% ordinary income bracket, you owe $107.80 instead. That extra $34.30 is the cost of not waiting.

Scenario C — Multiple lots, mixed holding periods: You bought 10 shares in January and 10 more in August. You sell 10 shares in November. Using FIFO, you’re selling the January shares (long-term). Using LIFO or specific ID, you might be selling the August shares (short-term) — completely different tax result from the exact same sale.

xychart
    title "Tax Owed: Same $490 Gain, Different Rates"
    x-axis ["0% Rate", "15% Rate", "22% Rate", "32% Rate"]
    y-axis "Tax Owed ($)" 0 --> 170
    bar [0, 73.5, 107.8, 156.8]

Am I the only one who didn’t realize how much the holding period and lot selection method could shift the final number? When I first started tracking this stuff, I genuinely thought a gain was a gain was a gain. The reality is more nuanced — and more in your control — than it looks.

Using a stock tax calculator takes the guesswork out and, more importantly, surfaces these choices before you sell. That’s the real power of the tool — not just calculating after the fact, but optimizing before you click the sell button.


Related Articles

Back to Complete Guide: Stock Capital Gains Tax Calculation: 7-Step Beginner’s Guide

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *