Sub topic 1
What 'risk' means: uncertainty versus the chance of lasting loss
Prerequisites
This chapter assumes you can compute percentages and averages, read a price chart, and run a short Python 3 script. The code uses only the standard library.
Two meanings of risk
Investors use "risk" for two different things. The first is uncertainty: returns may differ from what you expect. The second is the chance of lasting loss: your money may not come back. Volatility measures the first, and drawdowns measure the second.
Measuring returns
A simple return is the percent change between two prices: new / old - 1.
prices = [100, 102, 99, 103, 101, 105]
returns = [prices[i] / prices[i - 1] - 1 for i in range(1, len(prices))]
print([round(r, 4) for r in returns])Volatility
Volatility is the sample standard deviation of returns. It measures how widely returns scatter around their average. High volatility means a bumpy path, not necessarily a bad outcome.
Annualizing volatility
Multiply daily volatility by the square root of about 252, the number of trading days in a year.
import statistics
prices = [100, 102, 99, 103, 101, 105]
returns = [prices[i] / prices[i - 1] - 1 for i in range(1, len(prices))]
daily_vol = statistics.stdev(returns)
annual_vol = daily_vol * (252 ** 0.5)
print(f"Annualized volatility: {annual_vol:.1%}")The output is about 52%. If returns were roughly normal, about two thirds of yearly returns would fall within 52 points above or below the average.
> The 252 factor assumes daily prices. Five returns are far too few for a reliable estimate.
Drawdowns
A drawdown is the percent fall from the highest earlier price. The maximum drawdown is the worst such fall.
def max_drawdown(prices):
peak = prices[0]
worst = 0.0
for price in prices:
peak = max(peak, price)
worst = min(worst, price / peak - 1)
return worst
print(f"{max_drawdown([100, 120, 90, 110, 80, 130]):.1%}")The output is -33.3%, the fall from 120 to 80.
Exercise
What is the maximum drawdown of the price series [100, 120, 90]?
Show answer
-25%. The highest price is 120, and 90 / 120 - 1 = -0.25.