Crypto return autocorrelation measures how returns in one time interval relate linearly to returns a specified number of intervals later. Positive values describe persistence around the sample mean; negative values describe reversal. Calculate it on a declared, evenly spaced return series, state the estimator and inspect several justified lags. A near-zero result does not prove independence, and a nonzero result does not establish a profitable trading rule.
Decide what one lag means
With hourly close-to-close returns, lag one compares returns one hour apart and lag six compares returns six hours apart. With daily returns, those same lag numbers mean one and six days. A list of trades sorted by exit time has a different clock: the next row might be seconds or weeks later.
Choose the venue, instrument, quote asset, price source, interval, timestamps and evaluation dates before calculating. A spot close, perpetual mark and last traded price describe different inputs. For a strategy series, declare whether returns include fees, funding and open-position valuation. Check the calendar with the backtest data-quality worksheet.
Autocorrelation compares a series with its own delayed values. Comparing strategy returns with simultaneous benchmark returns asks a different question; the beta and alpha guide covers that relationship. A strategy can track BTC closely while showing little serial dependence in its own returns.
Keep the covariance convention visible
Let r[t] be a return and m the mean of all N supplied returns. First calculate each deviation d[t] = r[t] − m. For lag k, multiply deviations from observations k intervals apart. Sum those products over the N − k available pairs, then divide by the sum of squared deviations across all N observations.
That is the sample autocorrelation convention defined by NIST, whose observation times are assumed equally spaced. In compact notation:
d[t] = r[t] - m
S = sum of all d[t]^2
C = sum of lag pairs
acf[k] = C / S
Here each lag pair contributes d[t] × d[t+k], for t = 1 through N − k. This uses one full-sample mean and one denominator. It is not a separate Pearson correlation that recenters each of the two shortened vectors.
Software settings matter. The statsmodels ACF documentation distinguishes autocovariance denominators of N from the adjusted N − k version. Record that choice when comparing outputs. Lag zero is one for a nonconstant series. If every return is identical, S = 0: report the ACF as undefined, rather than zero or perfect persistence.
Same returns, different order
Consider two hypothetical eight-hour series, expressed in percentage points. They contain exactly the same returns, with mean zero and squared-deviation sum 28. They are teaching inputs, not observed crypto data.
- Sequence A: −3, −2, −1, 0, 0, +1, +2, +3.
- Sequence B: −3, +3, −2, +2, −1, +1, 0, 0.
For A at lag one, the seven products are 6, 2, 0, 0, 0, 2, 6. Their sum is 16. For B, they are −9, −6, −4, −2, −1, 0, 0, summing to −22.
| Quantity under the stated convention | Sequence A | Sequence B |
|---|---|---|
| Observations | 8 | 8 |
| Full-sample mean | 0 | 0 |
| Squared-deviation sum | 28 | 28 |
| Lag-one product sum | 16 | −22 |
| Lag-one ACF | 0.5714 | −0.7857 |
| Lag-two product sum | 6 | 16 |
| Lag-two ACF | 0.2143 | 0.5714 |
The table divides every product sum by 28. Sequence B reverses strongly at the adjacent interval yet has positive lag-two association. A single coefficient misses that distinction.
Both sequences also have the same compounded gross return because multiplication of the same return factors is order-independent. Autocorrelation describes their ordering, not a higher average payoff. Eight deliberately arranged observations cannot establish a population model, statistical significance or an executable edge.
An overlap trap that creates persistence
A realistic failure starts with hourly log returns but calculates a rolling two-hour log return at every hour. Consecutive observations then share one hourly return.
Use an explicit hypothetical model: hourly log returns x[t] are independent, have mean zero and common finite variance v > 0. Define y[t] = x[t] + x[t−1]. Each two-hour return has variance 2v; adjacent two-hour returns have covariance v because they share x[t−1]. Their population lag-one autocorrelation is therefore v / (2v) = 0.5.
The underlying hourly returns remain independent in this model. The persistence comes from reusing an observation. It does not demonstrate that the next hourly price change is forecastable. Nonoverlapping two-hour observations remove that particular shared term under these assumptions, while also changing the observation frequency and count.
Save both the return horizon and sampling step. “Two-hour returns” alone cannot distinguish a fresh observation every hour from one every two hours. Also avoid silently deleting missing hours and treating the survivors as adjacent. Statsmodels explicitly documents that its missing='drop' option treats retained observations as contiguous; that behavior may change the elapsed time represented by a lag.
Quiet return lags can hide dependence
An ACF measures linear association in the chosen variable. A quiet ACF of signed returns does not rule out dependence in their magnitudes, nonlinear relationships or changing conditions. Inspecting the ACF of absolute or squared returns asks whether return size persists; it is a separate diagnostic, not a directional forecast. Squaring also gives unusually large returns more influence.
NIST's autocorrelation-plot guidance explicitly warns that absence of significant autocorrelation does not establish randomness. Its approximate white-noise reference limits use ±1.96 / sqrt(N) for a single 95% comparison. Those limits are conditional on the reference model. They do not give a 95% simultaneous guarantee across every displayed lag, asset and window.
Choose relevant lags before inspecting their values. Searching dozens of intervals and reporting the tallest bar adds selection that a single reference band does not account for. Preserve the failed choices in the backtest trial ledger.
A joint diagnostic such as Ljung–Box combines information through a specified maximum lag. The statsmodels Ljung–Box documentation also requires attention to degrees of freedom consumed by a fitted model; it returns an undefined p-value when the adjusted degrees of freedom are nonpositive. A rejection calls for investigation of that series and model, rather than a buy instruction. Failure to reject does not certify independence.
Turn a diagnostic into a research decision
Use this worksheet alongside the coefficients:
| Finding | Next check | Decision it cannot justify alone |
|---|---|---|
| Positive nearby lags | Shared return windows, stale marks, regime changes | Buying after every positive return |
| Negative lag one | Price-source changes, alternating observations, costs | A profitable reversal strategy |
| Quiet signed-return ACF | Absolute/squared returns and shared market episodes | Independent observations |
| Different recent and full-window ACF | Predeclared windows and input consistency | Selecting the more attractive window |
| Undefined output | Constant input, gaps, insufficient pairs | Replacing the result with zero |
Dependence affects uncertainty, but a lag-one estimate is not a universal discount factor for trade count. The existing effective-sample-size guide explains why the target statistic and dependence model matter. For mean-return uncertainty, the bootstrap guide discusses resampling units and blocks; an ACF can inform that investigation without choosing a valid block length by itself.
Any candidate rule still needs chronological evaluation and an execution model. A reversal rule that repeatedly changes positions may incur substantial portfolio turnover. A statistically visible relationship can be too small, unstable or costly to trade. Retain the input hash, estimator, lags, horizon, sampling step, missing-data policy and follow-up decision with the frozen research result.
Method and limits
This AI-assisted educational article uses linked primary statistical documentation and original hypothetical calculations. The pair sums, ACF values and overlapping-return covariance example were checked algebraically and computationally. No market dataset, empirical predictability, trading profitability or KLINEO autocorrelation feature was tested.
