Guide
How to calculate the Sharpe ratio (with a worked example)
The formula itself is short. Getting a number you can actually trust — and that means the same thing as someone else's Sharpe ratio — takes a bit more care than plugging numbers into it.
Quick answer
Subtract the risk-free rate from the average return, divide by the standard deviation of those returns, then annualize by multiplying by the square root of the number of periods in a year (√252 for daily data). The two places people most often go wrong: using the wrong annualization factor, and quietly comparing an in-sample number to someone else's out-of-sample one.
The formula
Three ingredients: the average return over your chosen period, the risk-free rate over the same period (often simplified to zero for short-term retail backtests), and the standard deviation of those same returns. The square-root term at the end converts whatever period you measured in — daily, weekly, monthly — into a standardized annual figure so ratios computed on different frequencies can be compared.
A worked example, step by step
Say a strategy produced these five daily returns: +0.8%, −0.3%, +0.5%, +0.2%, −0.6%.
- Step 1 — average return: (0.8 − 0.3 + 0.5 + 0.2 − 0.6) / 5 = 0.12% per day.
- Step 2 — subtract the risk-free rate: assuming it's negligible over five days, this stays at 0.12%.
- Step 3 — standard deviation of the returns: works out to roughly 0.53% for this sample.
- Step 4 — daily Sharpe: 0.12 / 0.53 ≈ 0.226.
- Step 5 — annualize: 0.226 × √252 ≈ 3.59.
Five days is far too small a sample to trust in practice — this is purely to show the mechanics. A real calculation needs enough trades or return periods for the standard deviation itself to be a stable estimate, not a number that swings wildly with one extra data point.
The mistakes that quietly distort the number
Using the wrong annualization factor
√252 is standard for daily returns in most equity markets (roughly 252 trading days a year). Using √365 instead — treating every calendar day as a trading day — inflates the annualized Sharpe by about 20%, purely from an arithmetic choice that has nothing to do with strategy quality.
Mixing measurement periods
A Sharpe ratio computed from monthly returns and one computed from daily returns on the same strategy will not match, even before any annualization — different sampling frequencies capture different amounts of the return's volatility. Always state which frequency the underlying returns were measured at.
Ignoring the risk-free rate over long periods
Treating it as zero is a reasonable shortcut for a strategy tested over a few months. Over several years, especially in a higher-interest-rate environment, skipping it can meaningfully overstate the ratio — the "excess" return you're measuring should be excess over what you'd have earned doing nothing at all.
Comparing in-sample to out-of-sample without saying so
The formula doesn't know or care which period the returns came from — an in-sample Sharpe and an out-of-sample Sharpe use the exact same math and can look identical on paper while meaning completely different things.
Or skip the arithmetic and get it done consistently
The Honest Backtest Engine calculates Sharpe the same way, every run — annualized correctly for your data's actual frequency, net of real costs, and always labeled in-sample or out-of-sample so there's never any ambiguity about what the number means.
See how it worksFrequently asked questions
What is the formula for the Sharpe ratio?
Sharpe ratio equals the average return minus the risk-free rate, divided by the standard deviation of those returns, then annualized by multiplying by the square root of the number of periods per year.
Do I need to subtract the risk-free rate to calculate Sharpe ratio?
Technically yes, though many retail backtests simplify by treating the risk-free rate as zero, which is a reasonable approximation for short holding periods but can meaningfully understate risk-adjusted return over long ones.
How do you annualize a Sharpe ratio calculated from daily returns?
Multiply the daily Sharpe ratio by the square root of 252, the typical number of trading days in a year. Using the wrong number of periods, or mixing daily returns with an annual multiplier, is one of the most common calculation mistakes.
Why do two people calculate different Sharpe ratios from the same returns?
Usually because of a different annualization assumption (252 trading days vs 365 calendar days), a different risk-free rate, or sample versus population standard deviation. These are all reasonable choices individually, but they don't produce identical numbers, so a Sharpe ratio should always specify which convention it used.