Sharpe Ratio Calculator Formula

Understand the math behind the sharpe ratio calculator. Each variable explained with a worked example.

Formulas Used

Sharpe Ratio

sharpe = volatility > 0 ? (avg_return - risk_free) / volatility : 0

Excess Return

excess_return = avg_return - risk_free

Reward-to-Variability

risk_premium_per_vol = volatility > 0 ? (avg_return - risk_free) / volatility * 100 : 0

Variables

VariableDescriptionDefault
avg_returnAverage Annual Return(%)10
risk_freeRisk-Free Rate (Treasury)(%)4.5
volatilityAnnual Volatility (Std Dev)(%)12

How It Works

The Sharpe Ratio

Developed by Nobel laureate William Sharpe, this ratio measures the excess return per unit of total risk.

Formula

Sharpe Ratio = (Rp - Rf) / Std Dev

Where:

  • Rp = Portfolio return
  • Rf = Risk-free rate (typically T-bill yield)
  • Std Dev = Standard deviation of portfolio returns
  • Interpreting Results

    The higher the Sharpe ratio, the better the risk-adjusted performance. Use it to compare investments, not in isolation.

    Limitations

  • Assumes returns are normally distributed
  • Does not distinguish between upside and downside volatility
  • Sensitive to the time period chosen
  • Worked Example

    10% average return, 4.5% risk-free rate, 12% volatility.

    avg_return = 10risk_free = 4.5volatility = 12
    1. 01Excess return = 10% - 4.5% = 5.5%
    2. 02Sharpe ratio = 5.5% / 12% = 0.458
    3. 03This is a moderate risk-adjusted return
    4. 04For comparison, the S&P 500 has a long-run Sharpe near 0.4-0.5

    Ready to run the numbers?

    Open Sharpe Ratio Calculator