Course contents
Judging it like a professional
A single return figure is not enough to judge a strategy; you compute the measures from the Risk and Psychology course, the total and annualised return, the maximum drawdown, and a risk-adjusted ratio, in code from the backtest. Judge the whole picture, not the headline.
- Compute total return, annualised return (CAGR), and maximum drawdown from a backtest
- Compute a simple risk-adjusted measure
- Connect these metrics to the survival ideas from Risk and Psychology
The last chapter reported one number for the strategy, its total return, and one number is never enough to judge a strategy, as the Risk and Psychology course argued at length. A strategy that makes a good return through a terrifying, unlivable drawdown is worse than a steadier one that makes less, because you would never survive holding it. So professionals judge a strategy by several measures at once, and this chapter computes them in code from the same backtest.
The measures that matter
From the backtest's daily returns you build an equity curve and read the key statistics off it.
# Judge the strategy the way Risk and Psychology taught: not by one number.
import pandas as pd
import numpy as np
df = pd.read_csv("sample_prices.csv", parse_dates=["Date"], index_col="Date")
df["fast"] = df["Close"].rolling(20).mean()
df["slow"] = df["Close"].rolling(50).mean()
df["signal"] = (df["fast"] > df["slow"]).astype(int)
df["position"] = df["signal"].shift(1).fillna(0)
market_return = df["Close"].pct_change().fillna(0)
trade = df["position"].diff().abs().fillna(0)
r = df["position"] * market_return - trade * 0.001 # same after-cost return as the backtest
equity = (1 + r).cumprod()
total = equity.iloc[-1] - 1
years = len(r) / 252
cagr = equity.iloc[-1] ** (1 / years) - 1
drawdown = equity / equity.cummax() - 1
max_dd = drawdown.min()
sharpe = r.mean() / r.std() * np.sqrt(252) # rough, risk-free rate 0
print(f"Total return: {total * 100:.2f}%")
print(f"CAGR (annualised): {cagr * 100:.2f}% (extrapolated from < 1 year, unreliable)")
print(f"Max drawdown: {max_dd * 100:.2f}%")
print(f"Sharpe (rough): {sharpe:.2f}")Total return: -8.11% CAGR (annualised): -11.16% (extrapolated from < 1 year, unreliable) Max drawdown: -14.41% Sharpe (rough): -1.14
Four numbers come out, and they must be read together. The total return of minus 8.11% is the after-cost result from the backtest, restated. The CAGR, the compound annual growth rate, annualises that to about minus 11%, though here it carries a loud caveat printed alongside it: annualising a result from less than a year of data is an unreliable extrapolation, and you should distrust an annualised figure from a short sample. The maximum drawdown of about minus 14% is the worst peak-to-trough fall the strategy suffered along the way, exactly the drawdown from the Risk and Psychology course, now computed from an equity curve. And the Sharpe ratio, roughly minus 1.1, is a risk-adjusted measure: return earned per unit of volatility, where higher is better and negative is bad. On every one of these measures, this strategy fails.
Why the whole picture matters
Notice what the extra measures added. The return alone said the strategy lost a bit. The drawdown says that along the way it fell 14% from its peak, and the negative Sharpe says it delivered losses while taking on real volatility. A strategy is only worth trading if it makes an acceptable return without a drawdown you could not stomach and without risk out of proportion to its reward, and judging that needs all the measures, not the headline return.
The drawdown deserves special weight, because it is the number that ends real traders, as the earlier course insisted. A backtest can show a fine overall return while hiding a period where the strategy lost, say, 40% from its high, a stretch almost no one would actually sit through without abandoning the plan at the worst moment. When you measure a strategy, look hardest at the drawdown, because it tells you not just what the strategy earned but whether you could have survived earning it. Here the answer is plain: a losing return, a double-digit drawdown, and a negative risk-adjusted score describe a strategy to reject, which is exactly what an honest measurement is for.
What to carry forward
A strategy needs several measures at once: total return and CAGR (unreliable on short samples), maximum drawdown, and a risk-adjusted ratio such as Sharpe. Together they judge not just what a strategy earned but whether you could have survived earning it, and the drawdown, the survival number from Risk and Psychology, matters most. Our crossover failed on every measure, which is what an honest measurement is meant to reveal.
The strategy we tested lost, but a determined beginner can still make it look like a winner by tuning it to the past. The next chapter shows how that self-deception works, and the practices that guard against it.