Tax-Loss Harvesting Calculator Formula

Understand the math behind the tax-loss harvesting calculator. Each variable explained with a worked example.

Formulas Used

Total Tax Savings

tax_savings = min(capital_losses, capital_gains) * tax_rate / 100 + income_offset * income_tax_rate / 100

Net Taxable Gain

net_taxable_gain = net_gain

Loss Carryforward

carryforward = max(excess_loss - 3000, 0)

Variables

VariableDescriptionDefault
capital_gainsRealized Capital Gains(USD)10000
capital_lossesAvailable Capital Losses(USD)7000
tax_rateCapital Gains Tax Rate(%)15
income_tax_rateOrdinary Income Tax Rate(%)22
net_gainDerived value= max(capital_gains - capital_losses, 0)calculated
excess_lossDerived value= max(capital_losses - capital_gains, 0)calculated
income_offsetDerived value= min(excess_loss, 3000)calculated

How It Works

Tax-Loss Harvesting

1. Losses offset gains dollar-for-dollar 2. Excess losses offset up to $3,000 of ordinary income 3. Remaining losses carry forward to future years

Tax Savings = Offset Gains x CG Rate + Income Offset x Income Rate

Be aware of the wash sale rule: you cannot repurchase the same or substantially identical security within 30 days.

Worked Example

$10,000 gains, $7,000 losses, 15% CG rate.

capital_gains = 10000capital_losses = 7000tax_rate = 15income_tax_rate = 22
  1. 01$7,000 losses offset $7,000 of gains
  2. 02Net taxable gain = $3,000
  3. 03Tax savings = $7,000 x 15% = $1,050
  4. 04No excess losses for income offset

Ready to run the numbers?

Open Tax-Loss Harvesting Calculator