How to chart a rolling Sharpe ratio over time
Quick answer
To chart a rolling Sharpe ratio, compute excess returns (return minus the risk-free rate), then over a moving window take the mean divided by the standard deviation and annualise by multiplying by the square root of the periods per year - in pandas, a rolling mean over rolling std on daily excess returns, times sqrt(252). Plot it as a line: it shows how a strategy's risk-adjusted return has held up or decayed, which a single headline Sharpe averages away. Use a window long enough to keep the denominator stable, usually 252 trading days.
A single Sharpe ratio compresses a strategy's entire history into one number: return per unit of risk. That is useful for a league table and useless for spotting when a strategy started to break. A rolling Sharpe recomputes the same ratio over a moving window and draws it as a line, so you can watch the risk-adjusted return rise, hold, or decay through time instead of trusting one blended average.
The formula, one window at a time
The Sharpe ratio is the mean excess return divided by its standard deviation, annualised. Excess return is the asset's return minus the risk-free rate over the same period, with the Treasury bill yield the usual proxy. Over a window of N periods: take the mean of the excess returns, divide by their standard deviation, and multiply by the square root of the number of periods in a year to annualise. For daily data that factor is the square root of 252; for monthly, the square root of 12. The annualisation is what makes a daily-data Sharpe comparable to the headline figures people quote.
In pandas the rolling version is two rolling calls over one series of excess returns: a rolling mean divided by a rolling standard deviation, scaled by the square root of 252. Written out: (excess.rolling(252).mean() / excess.rolling(252).std()) * (252 ** 0.5). Each point is a fully annualised Sharpe measured over the trailing year ending on that date.
Why annualising by root-time matters
The square-root scaling trips people up. Mean return grows with the length of the window; standard deviation grows with its square root, because returns are assumed roughly independent from one period to the next. So the ratio of the two scales with the square root of time, and you annualise a daily Sharpe by the square root of 252, not by 252. Get this wrong and the number is off by a factor of about sixteen. This is the most common error in a homemade Sharpe chart, and it is silent: the line looks plausible, just at the wrong altitude.
Choose the window
A rolling Sharpe needs a longer window than most rolling statistics, because the standard deviation in the denominator is unstable over short spans and can briefly collapse toward zero, which sends the ratio to absurd highs. A 252-day window, one trading year, is the common default: long enough to keep the denominator honest, short enough to show a strategy decaying over a few years. Anything under about 90 days tends to produce a jagged, untrustworthy line. As with any rolling metric, state the window on the chart; a rolling Sharpe without a labelled window is not interpretable.
A worked example
Take a broad equity index on daily data with a 252-day window. Through a calm, trending stretch the rolling Sharpe might sit comfortably above 1, occasionally above 2, marking strong risk-adjusted returns. In a drawdown year like 2022, when returns turned negative and volatility rose at the same time, the same line falls through zero and stays negative for the length of the bad patch, then climbs back as the recovery lengthens the trailing window. The headline full-sample Sharpe for the whole period might be a respectable 0.6 and tell you none of that. The rolling line shows exactly when the risk-adjusted return was being earned and when it was being given back. The magnitudes here are illustrative of the pattern; compute the exact values on your own return series and risk-free rate.
[QUADESTO-EMBED: 252-day rolling annualised Sharpe of a broad equity index on daily returns, Treasury-bill risk-free rate, zero line drawn]
Sortino, the downside cousin
If penalising upside volatility bothers you, and it should, since a strategy is not risky for going up, swap the denominator for downside deviation, the standard deviation of only the negative excess returns. That is the Sortino ratio, and a rolling Sortino is built exactly the same way, just with the downside-only deviation in the denominator. It usually sits above the Sharpe line and reacts more sharply to a genuine losing streak.
Building it in Quadesto
Feed in a return series and a risk-free rate and Quadesto plots the rolling annualised Sharpe with the window shown and the root-time scaling handled, alongside the drawdown panel and rolling correlation that round out a performance pack. Switch the window or swap in downside deviation for a Sortino line without touching a formula. The free tier embeds it live with a Made with Quadesto credit; Pro (£149 a month) removes the attribution and adds branded themes for reporting.