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 : 0Annualized Return
annualized_return = cost_basis > 0 ? (pow((current_value + dividends_received) / cost_basis, 1 / years_held) - 1) * 100 : 0Total Profit
total_profit = capital_gain + dividends_receivedCapital Gain
capital_gain_amount = capital_gainVariables
| Variable | Description | Default |
|---|---|---|
purchase_price | Purchase Price per Share(USD) | 50 |
current_price | Current Price per Share(USD) | 75 |
shares | Number of Shares | 100 |
dividends_received | Total Dividends Received(USD) | 500 |
years_held | Years Held(years) | 3 |
cost_basis | Derived value= purchase_price * shares | calculated |
current_value | Derived value= current_price * shares | calculated |
capital_gain | Derived value= current_value - cost_basis | calculated |
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
- 01Cost basis = 100 x $50 = $5,000
- 02Current value = 100 x $75 = $7,500
- 03Capital gain = $7,500 - $5,000 = $2,500
- 04Total return = ($2,500 + $500) / $5,000 = 60%
- 05Annualized = ($8,000 / $5,000)^(1/3) - 1 = 16.96%
Ready to run the numbers?
Open Stock Return Calculator