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)
| Income Level | Rate | |---|---| | Up to ~$47,025 (single) | 0% | | $47,026-$518,900 | 15% | | Over $518,900 | 20% |
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
Ready to run the numbers?
Open Capital Gains Tax Calculator