How every number in the study was produced

Pick a day on the price chart. Each step below then works through that day's calculation, next to the notebook code that does it. Click any line of code to see what it does.

Risk and Return Predictability in Bitcoin: an out-of-sample study of momentum and volatility models. Albert Kho (许智荐), Central University of Finance and Economics.

Bitcoin price in US dollars, log scale

Click or drag on the chart to pick a day

Step 1 of 7, notebook 01_data

Prices and daily returns

Load 3,044 daily Bitcoin prices from Coin Metrics and turn them into daily returns. Every later number starts from this one column.

The return on the selected day

notebooks/01_data.ipynb

Click any line to see what it does. The tabs above hold the other cells of this step.

Output

0.0012212869405938628 0.0341958520865199 -0.3753495151221997 2020-03-12 00:00:00

Cell 3, line 1

btc["ret"] = btc["price"].pct_change()

The daily return: today’s price divided by yesterday’s, minus 1. pct_change does this for every day at once. The very first day has no yesterday, so it is empty.

Step 2 of 7, notebook 02_stats

Risk statistics

Grow 1 USD with the daily returns, measure how far it fell from its peak, and summarise the risk: volatility, drawdown, value at risk and fat tails.

Recomputed in your browser. For 2018 to 2025 these match the notebook output exactly.

Drawdown: how far 1 USD is below its highest value so far

notebooks/02_stats.ipynb

Click any line to see what it does. The tabs above hold the other cells of this step.

Output

annual vol         0.6533
CAGR               0.2582
max drawdown      -0.8138
VaR 95%            0.0522
CVaR 95%           0.0793
skew              -0.2851
excess kurtosis    8.1945
dtype: float64

Cell 2, line 2

dd = wealth / wealth.cummax() - 1  # drawdown: distance below the highest point so far

Drawdown: how far wealth is below its highest point so far. cummax is the running peak; −0.30 means 30% below the peak.

Step 3 of 7, notebook 03_momentum, cells 1–2

Momentum signal, lined up with tomorrow

Today's 30-day momentum and volatility are used to predict tomorrow's return. The shift(-1) is what keeps the test honest: drop it and the regression looks brilliant.

One row of the regression table, for the selected day

Momentum t-statistic (HAC, 30 lags)

Training years 2018–2021, 1,461 days; the scatter shows every third day.

notebooks/03_momentum.ipynb

Click any line to see what it does. The tabs above hold the other cells of this step.

Output

1461

Cell 1, line 9

"y":   r.shift(-1),  # tomorrow's return (the thing we predict)

y is tomorrow’s return, the thing we try to predict. shift(−1) moves every value up one row, so each row holds the next day’s return. This one line prevents look-ahead bias.

Step 4 of 7, notebook 03_momentum, cells 3–5

Out-of-sample test

From 2022 on, refit the model every day using only the past, forecast tomorrow, and compare with a plain benchmark: the average return so far. R² out of sample above 0 means momentum beat the benchmark.

The forecast made on the selected day

R² out of sample, adding one day at a time from 1 Jan 2022

Validation 2022–23

0.009%

Clark–West t = 0.42

Test 2024–25

−0.017%

Clark–West t = 0.19

Both are close to zero and the t-values are far below 1.65, so momentum does not predict Bitcoin's daily return.

notebooks/03_momentum.ipynb

Click any line to see what it does. The tabs above hold the other cells of this step.

Output

1460

Cell 3, line 4

past = data.loc[:t].iloc[:-1]  # rows before today: their "tomorrow" is already known

All rows before today. Their “tomorrow” has already happened, so the model learns only from the past: an expanding window.

Step 5 of 7, notebook 04_volatility

Volatility forecasts

Two ways to forecast tomorrow's risk: the average of the last 30 squared returns, or EWMA, which keeps most of yesterday's estimate and mixes in today's news. QLIKE scores each forecast; lower is better. A GARCH model is added as a check.

Forecast volatility around the FTX collapse, annualised

30-day rollingEWMA, λ = 0.97GARCH(1,1), dashed*

The notebook chose λ = 0.97 on the validation years, then tested it once on 2024–25: Diebold–Mariano t = 2.45, so EWMA is the better forecast.

* Added afterwards as a robustness check (cell 6), with scores taken from the notebook. GARCH is no better than EWMA (Diebold–Mariano t = 0.17). Its fitted α + β ≈ 1 gives it the same structure as EWMA, but around FTX it jumps higher and fades faster, because it weights the newest shock more (α = 0.07 against 0.03).

The EWMA update on the selected day

notebooks/04_volatility.ipynb

Click any line to see what it does. The tabs above hold the other cells of this step.

Cell 2, line 7

v = lam * v + (1 - lam) * x**2  # keep λ of the old belief, mix in (1-λ) of today's news

The EWMA update: keep λ of the old forecast and add (1 − λ) of today’s squared return. With λ = 0.97, each older day counts 3% less, so a shock fades gradually.

Step 6 of 7, notebook 05_strategy, cells 1–6

Strategy backtest

Volatility targeting holds 30% ÷ forecast volatility in Bitcoin, at most 100%, and the rest in T-bills. It is compared with buy-and-hold and with a fixed 39.1% mix, after trading costs.

Volatility targeting on the selected day

Test years 2024–25

Growth of 1 USD, 2024–25, log scale

Buy and hold Fixed mix Volatility target

1 bp is 0.01%: 25 bp means paying 0.25% of whatever is traded.

notebooks/05_strategy.ipynb

Click any line to see what it does. The tabs above hold the other cells of this step.

Cell 3, line 6

gross = w * r[t] + (1 - w) * rf[t]  # BTC part + cash part

Gross return: weight × Bitcoin return + (1 − weight) × T-bill return.

Step 7 of 7, notebook 05_strategy, cells 7–9

Robustness

Is the gap between volatility targeting and the fixed mix real, or luck? Check other settings, each year on its own, and a block bootstrap of the Sharpe difference.

Sharpe ratio by year (25 bp costs)

Block bootstrap: 5,000 reshuffled histories of 2024–25 in 20-day blocks

Your browser's random numbers differ from NumPy's, so the interval can differ from the notebook's [−0.30, 0.10] in the second decimal.

notebooks/05_strategy.ipynb

Click any line to see what it does. The tabs above hold the other cells of this step.

Output

-0.098 [-0.3  0.1]

Cell 9, line 7

for _ in range(5000):  # 5,000 "alternative histories"

Repeats the experiment 5,000 times. Each repeat builds one alternative history of 2024–25 out of reshuffled 20-day blocks of the real days, then measures the Sharpe gap in it.