Statistics#
Measures of a window: central tendency, dispersion, quantiles, moments, z-scores, running totals, and cross-series relationships.
Statistics#
Windowed summary statistics: central tendency, dispersion, quantiles, moments, and extremes.
Function |
Description |
|---|---|
Rolling mean of |return| / notional (Amihud 2002 illiquidity ratio). |
|
EW excess kurtosis. |
|
Exponentially-weighted moving average (pandas adjust=True). |
|
EW root-mean-square. |
|
EW skewness. |
|
EW standard deviation. |
|
EW variance (pandas adjust=True bias-corrected). |
|
Running bias-corrected excess kurtosis (Fisher) over the whole history. |
|
Running mean over the whole history since the last reset. |
|
Running bias-corrected sample skewness (G1) over the whole history. |
|
Running sample standard deviation (ddof=1) over the whole history. |
|
Running sample variance (ddof=1) over the whole history. |
|
Window-offset of the trailing-window maximum (TA-Lib MAXINDEX). |
|
Window-offset of the trailing-window minimum (TA-Lib MININDEX). |
|
Q3 minus Q1 over the trailing window. |
|
Trailing-window excess kurtosis. |
|
Trailing-window mean absolute deviation from the rolling mean. |
|
Trailing-window maximum (monotonic deque). |
|
Trailing-window arithmetic mean (simple moving average). |
|
Trailing-window median. |
|
Rolling median absolute deviation, median(|x - median|), a robust scale estimate. |
|
Trailing-window minimum (monotonic deque). |
|
Trailing-window (min, max) returned as a 2-tuple per step. |
|
Percentile (rank/window) of the current value in the trailing window. |
|
Trailing-window quantile (e.g. 0.25 = lower quartile). |
|
Trailing-window max minus min. |
|
Rank of the current value within the trailing window (1-based, average tie rule). |
|
Trailing-window root-mean-square. |
|
Trailing-window skewness. |
|
Trailing-window sample standard deviation (ddof=1). |
|
Trailing-window sum. |
|
Trailing-window sample variance (ddof=1). |
Volatility#
The size of fluctuations and risk: standard deviation and variance, RMS, range-based OHLC estimators, and ATR.
Function |
Description |
|---|---|
Wilder-smoothed average of TrueRange. |
|
Mean +/- num_std rolling standard deviations. |
|
Var form of the Garman-Klass range-based volatility estimator (OHLC). |
|
Vol form of the Garman-Klass range-based volatility estimator (OHLC). |
|
Var form of the Parkinson range-based volatility estimator (uses high & low). |
|
Vol form of the Parkinson range-based volatility estimator (uses high & low). |
|
EW root-mean-square. |
|
Var form of the Rogers-Satchell drift-robust range-based estimator. |
|
Vol form of the Rogers-Satchell drift-robust range-based estimator. |
|
EW standard deviation. |
|
EW variance (pandas adjust=True bias-corrected). |
|
Running sample standard deviation (ddof=1) over the whole history. |
|
Running sample variance (ddof=1) over the whole history. |
|
Volatility-adapted envelope: EMA midline plus/minus a multiple of ATR. |
|
ATR scaled to a percentage of the current close. |
|
Trailing-window downside semideviation: the RMS of returns falling below a minimum acceptable return. |
|
Var form of the Garman-Klass range-based volatility estimator (OHLC). |
|
Vol form of the Garman-Klass range-based volatility estimator (OHLC). |
|
Var form of the Parkinson range-based volatility estimator (uses high & low). |
|
Vol form of the Parkinson range-based volatility estimator (uses high & low). |
|
Trailing-window max minus min. |
|
Trailing-window root-mean-square. |
|
Var form of the Rogers-Satchell drift-robust range-based estimator. |
|
Vol form of the Rogers-Satchell drift-robust range-based estimator. |
|
Trailing-window sample standard deviation (ddof=1). |
|
Trailing-window sample variance (ddof=1). |
|
Var form of the Yang-Zhang estimator (drift + gap robust). |
|
Vol form of the Yang-Zhang estimator (drift + gap robust). |
|
Per-bar true range accounting for overnight gaps (Wilder, 1978). |
Standardization & normalization#
Put values on a comparable scale: z-scores, affine rescaling, and detrending.
Function |
Description |
|---|---|
x[t] minus its rolling mean. |
|
Latest sample standardised by EW mean and std. |
|
Affine transform: scale * x + shift. |
|
Latest sample standardised by trailing-window mean and std. |
Cumulative#
Running aggregates from the start of the series.
Function |
Description |
|---|---|
Chaikin Accumulation/Distribution Line. |
|
Running maximum from t=0. |
|
Running minimum from t=0. |
|
Running product from t=0. |
|
Running sum from t=0. |
|
Running drawdown from the cumulative peak. |
|
Running maximum from t=0. |
|
Running minimum from t=0. |
|
Running product from t=0. |
|
Running sum from t=0. |
|
Latch the first finite value seen since reset. |
|
Return the most recent finite value seen since reset. |
|
Worst drawdown experienced so far (since reset). |
|
On-Balance Volume: signed cumulative volume by close-direction (Granville, 1963). |
Correlation & regression#
Relationships between series: correlation, covariance, regression, hedging, pairs, and mean-reversion.
Function |
Description |
|---|---|
Causal one-step-ahead predictive mean and std plus current slope and intercept via Normal-Inverse-Gamma posterior. |
|
EW CAPM beta: cov(target, regressor) / var(regressor). |
|
EW Pearson correlation of two parallel streams. |
|
EW covariance of two parallel streams. |
|
Exponentially-weighted price-impact slope of return on signed order flow. |
|
Rolling OLS intercept of target on regressor (companion to RollingBeta). |
|
cov(x, y) / var(y) - regression slope of x on y. |
|
Rolling Pearson correlation of two parallel streams. |
|
Rolling sample covariance of two parallel streams. |
|
Rolling-window Hurst exponent via Anis-Lloyd corrected rescaled-range analysis. |
|
Rolling-window price-impact slope of return on signed order flow (Kyle 1985). |
|
Full OLS fit returning (slope, intercept, r_squared, stderr). |
|
Rolling MLE fit of a mean-reverting Ornstein-Uhlenbeck process. |
|
OLS fit y = a + b*t over a trailing window. derivative_order selects value/slope/zero. |
|
Standard deviation of the rolling-hedge-adjusted residual y - beta*x. |
|
x - beta(x,y) * y - hedge-adjusted residual. |
|
Linear regression of y on time, projected one step ahead. TA-Lib's TSF. |