Stock Return Calculator Formula

Understand the math behind the stock return calculator. Each variable explained with a worked example.

Formulas Used

Total Return

total_return_pct = cost_basis > 0 ? (capital_gain + dividends_received) / cost_basis * 100 : 0

Annualized Return

annualized_return = cost_basis > 0 ? (pow((current_value + dividends_received) / cost_basis, 1 / years_held) - 1) * 100 : 0

Total Profit

total_profit = capital_gain + dividends_received

Capital Gain

capital_gain_amount = capital_gain

Variables

VariableDescriptionDefault
purchase_pricePurchase Price per Share(USD)50
current_priceCurrent Price per Share(USD)75
sharesNumber of Shares100
dividends_receivedTotal Dividends Received(USD)500
years_heldYears Held(years)3
cost_basisDerived value= purchase_price * sharescalculated
current_valueDerived value= current_price * sharescalculated
capital_gainDerived value= current_value - cost_basiscalculated

How It Works

Stock Return Calculation

Total Return

Total Return = (Capital Gain + Dividends) / Cost Basis x 100%

Annualized Return (CAGR)

Annualized Return = [(Ending Value + Dividends) / Cost Basis]^(1/Years) - 1

The annualized return normalizes your return to a per-year basis, making it easy to compare investments held for different periods.

Why Include Dividends

Dividends often account for 30-40% of total stock market returns over long periods. Ignoring them understates your actual investment performance.

Worked Example

Bought 100 shares at $50, now worth $75 each, received $500 in dividends over 3 years.

purchase_price = 50current_price = 75shares = 100dividends_received = 500years_held = 3
  1. 01Cost basis = 100 x $50 = $5,000
  2. 02Current value = 100 x $75 = $7,500
  3. 03Capital gain = $7,500 - $5,000 = $2,500
  4. 04Total return = ($2,500 + $500) / $5,000 = 60%
  5. 05Annualized = ($8,000 / $5,000)^(1/3) - 1 = 16.96%

Ready to run the numbers?

Open Stock Return Calculator