Forecasting & ML#
Training sets and labels from time-series data, online regression and filtering that forecast as they update, and regime and change-point models.
Supervised learning & online forecasting#
Forecasting training sets from causal features and targets, labels such as the triple barrier, and regressions and filters that update and forecast at every step.
Function |
Description |
|---|---|
Online Bayesian linear regression with a forgetting factor: the current slope and intercept, and a one-step-ahead predictive mean and standard deviation. |
|
Exponentially weighted least-squares fit of y on k regressors, with the one-step-ahead prediction made before each row enters, R-squared, and the coefficients. |
|
Least-squares fit of y on k regressors over every row so far, with the one-step-ahead prediction made before each row enters, R-squared, and the coefficients. |
|
Build a forecasting training set where row t holds the features at t and the target over the horizon after t. |
|
Scalar 1-D Kalman filter for a noisy random-walk model. |
|
Rolling least-squares fit of y on k regressors, with the one-step-ahead prediction made before each row enters, R-squared, and the coefficients. |
|
A three-state label over a window: +1 when the price reaches the upper barrier first, -1 when it reaches the lower barrier first, 0 when it reaches neither within horizon steps. |
|
A three-state label over a window of OHLC bars: +1 when the upper barrier is reached first, -1 when the lower barrier is reached first, 0 when neither is reached within horizon bars; barriers are tested on each bar's open, high, and low. |
Regimes & change points#
Detect a change in a series' behaviour: hidden Markov regimes, Bayesian change points, CUSUM events, and tests for persistence, jumps, and randomness.
Function |
Description |
|---|---|
Online Bayesian changepoint detection (Adams-MacKay) on a series with Gaussian segments of unknown mean and variance; the expected run length since the last change and a predictive mean and standard deviation. |
|
Symmetric CUSUM event filter: +1 when the cumulative rise since the last event passes a threshold, -1 for a fall, 0 otherwise. |
|
Two-state hidden Markov model of a series, refit on a trailing window and filtered forward each step; the probability of the high-variance (or more persistent) state and a one-step predictive mean and standard deviation. |
|
Share of the realized variance of a window of returns that comes from jumps: max(0, 1 - BV / RV). |
|
Entropy of the ordinal patterns of a series over a trailing window, from 0 (one pattern repeats) to 1 (every pattern equally often). |
|
Lo-MacKinlay variance ratio of a window of returns, near 1 for a random walk, above 1 when returns trend and below 1 when they revert, or its robust z-statistic. |