Capital Gains Tax Calculator Formula
Understand the math behind the capital gains tax calculator. Each variable explained with a worked example.
Formulas Used
Capital Gain
capital_gain = gainTax on Gain
tax_owed = gain * holding_period / 100After-Tax Profit
net_profit = gain * (1 - holding_period / 100)Total Return
total_return = purchase_price > 0 ? gain / purchase_price * 100 : 0Variables
| Variable | Description | Default |
|---|---|---|
purchase_price | Purchase Price(USD) | 10000 |
sale_price | Sale Price(USD) | 15000 |
holding_period | Holding Period | 15 |
gain | Derived value= max(sale_price - purchase_price, 0) | calculated |
How It Works
Capital Gains Tax Rates (2024)
Long-Term (held >1 year)
Short-Term (<1 year)
Taxed as ordinary income at your marginal tax rate (up to 37%).
Worked Example
Bought at $10,000, sold at $15,000, held over 1 year.
purchase_price = 10000sale_price = 15000holding_period = 15
- 01Capital gain = $15,000 - $10,000 = $5,000
- 02Tax at 15% = $5,000 x 0.15 = $750
- 03Net profit = $5,000 - $750 = $4,250
Frequently Asked Questions
What is the difference between short-term and long-term gains?
Short-term gains (held under 1 year) are taxed as ordinary income. Long-term gains (held over 1 year) get preferential rates of 0%, 15%, or 20%.
Can capital losses offset gains?
Yes. Capital losses offset capital gains dollar-for-dollar. If losses exceed gains, you can deduct up to $3,000 against ordinary income per year.
Do I owe tax on unrealized gains?
No. Capital gains tax is only owed when you sell an asset. Unrealized gains (paper profits) are not taxed until the sale occurs.
Ready to run the numbers?
Open Capital Gains Tax Calculator