Feature engineering for financial data
The main families of financial features, from price and volatility to microstructure, and why point-in-time construction makes any of them usable.
A model needs something to look at besides the raw closing price, and the decision about what to compute from a cleaned price series is a decision about which hypothesis about market structure is being tested. A twenty-day momentum feature is a bet that recent direction persists. A rolling volatility feature is a bet that risk regime carries information a return alone does not. Neither bet is validated by the act of computing the feature — the model that consumes it is what tests the hypothesis — but a poorly constructed feature can make a real signal invisible or manufacture a fake one, and it is worth understanding both risks before treating feature construction as a mechanical step.
Price and momentum features
The most direct family: returns over a lookback window, lagged and compounded returns, momentum with a skip period, rate of change, distance from a moving average, and the Donchian channel (the distance of the current price from its own recent high-low range). Momentum-with-skip deserves a moment’s attention because the skip period is a methodological choice, not a tuning knob: momentum research since Jegadeesh and Titman has consistently found that a lookback which includes the most recent one to two weeks captures short-term reversal rather than persistence, contaminating a longer momentum signal with the opposite effect. A common construction skips the most recent week — computing momentum from to , say, rather than to — specifically to exclude that reversal window.
A worked example: with daily closes of over five days, a naive 4-day momentum feature computed at day 4 as blends the whole window’s drift with whatever happened on day 4 itself. A 4-day-momentum-skip-1 feature computed instead as deliberately excludes the most recent point, isolating the earlier trend from the latest move.
Volatility features
Rolling standard deviation, exponentially weighted volatility, average true range (ATR), realised volatility, downside volatility (standard deviation computed only over negative returns), and the ratio of short-window to long-window volatility as a simple regime indicator. The choice between simple rolling and exponentially weighted volatility is a real one: a 20-day rolling window weights all twenty observations equally and drops the oldest observation abruptly when the window slides forward, which can produce a visible step in the volatility estimate the day a single large historical move exits the window. An EWMA estimate with decay ,
weights recent observations more heavily and lets old ones fade out smoothly rather than dropping off a cliff. Quant Compose’s covariance estimators default the EWMA decay to , the RiskMetrics convention, giving an effective half-life of roughly 11 trading days.
Statistical features
Rolling mean, standard deviation and z-score of a return series; skewness and kurtosis, which describe asymmetry and tail thickness relative to a normal distribution; autocorrelation, which measures whether today’s return has any linear relationship with a lagged return; the Hurst exponent, which estimates whether a series exhibits long memory (values above 0.5 suggesting trending behaviour, below 0.5 suggesting mean reversion, though estimating it reliably from a short financial series is difficult); and Shannon entropy, a measure of how unpredictable a discretised return series appears. These are the family most directly connected to the stationarity questions covered in Returns, log returns and stationarity — a rolling skewness or kurtosis estimate is only meaningful if computed over a window short enough that the underlying distribution hasn’t shifted materially within it.
Technical indicators
Moving averages (simple and exponential), Wilder’s RSI, MACD, Bollinger bands, the stochastic oscillator, and ADX. These are among the most familiar features in retail finance, and also among the easiest to overuse: RSI, MACD and Bollinger bands are all, at bottom, transformations of a moving average and a rolling standard deviation computed over slightly different windows, which means feeding a model five technical indicators computed on the same price series often hands it five highly correlated versions of the same two or three underlying statistics rather than five independent sources of information. A model given ten correlated technical indicators does not have ten times the information a model given one has; it has one signal wearing ten costumes, and treating that as ten independent features overstates both the model’s apparent skill and the number of genuine hypotheses actually tested — the same trial-inflation concern examined in Signal versus noise: what a result has to survive.
Cross-sectional features
Rank, percentile, z-score, relative momentum and relative volatility computed within the cross-section — a security’s momentum relative to every other security in the universe on the same date, rather than relative to its own history. A cross-sectional z-score of momentum, computed as
where and are the mean and standard deviation of momentum across all securities in the universe on date , answers a genuinely different question than a time-series feature does: not “is this security’s momentum unusually high for itself” but “is this security’s momentum unusually high relative to its peers, right now.” Cross-sectional features are the natural feature family for a ranking or long-short strategy, where what matters is a security’s position relative to the rest of the universe on a given date, not its absolute level.
Microstructure features
Amihud illiquidity (the average ratio of absolute daily return to dollar volume, a proxy for price impact), Roll’s effective spread (an estimate of the bid-ask spread recovered from the serial covariance of price changes), and Kyle’s lambda (a measure of price impact per unit of order flow). These are built from daily prices and volume rather than order-book data, which is a real constraint: they are proxies for microstructure phenomena that are more directly observable in tick data, and their accuracy at daily frequency should be treated as approximate rather than precise. They are most useful as a coarse liquidity filter — flagging securities where a strategy’s assumed transaction costs are likely to be understated — rather than as a precise cost model.
Point-in-time construction: the constraint that makes any of this usable
Every feature family above shares one non-negotiable requirement: a feature stamped with date must be computable using only information that was actually knowable on or before date . Point-in-timePoint-in-time Stamping every record with the date it was actually knowable, so a later restatement or correction cannot leak into an earlier decision. alignment — stamping every record with the date it was actually knowable, not the date it describes — is what makes that possible for data that is naturally reported with a lag: a fundamental ratio computed from a quarterly filing is not knowable on the filing’s fiscal-period end date, it is knowable on the date the filing was actually released, which can be weeks later. A feature built from fundamentals joined on fiscal-period date rather than release date silently uses information before it existed.
This is worth stating plainly because it is the single most common way a feature pipeline manufactures an optimistic backtest without anyone deciding to cheat: a rolling window that reaches one day past its intended boundary, a join key that uses a reporting date instead of a release date, a cross-sectional universe drawn from today’s constituents instead of the historical ones. Each of these produces a feature that looks identical to a correctly constructed one in every column except performance — and performance is exactly the number nobody double-checks by hand. The full catalogue of ways this happens, across the entire pipeline rather than just feature construction, is the subject of Look-ahead bias and data leakage: the ten ways it happens.