Feature Engineering for Quant
The algorithm is interchangeable; the features are the strategy. Three families of raw material, four tests a feature has to pass, five mistakes everyone makes once, and the full rebuild of naive momentum into a cross-sectional z-score.
In quant ML, the algorithm is the easy part. A LightGBM in 2026 is roughly the same object as a LightGBM in 2020. What has changed is the features.
Every ML model pays a “sophistication tax”: the more complex the model, the more ways it can overfit your backtest. Simple models (linear regression, shallow trees) tax you lightly. Complex ones (deep nets, gradient boosting with thousands of trees) tax you heavily. There are two ways to settle that bill — with better features, or with more aggressive regularization and a prayer. Most people choose the second. This article is about the first.
A pattern that recurs: a whole team churns through XGBoost, LightGBM, CatBoost, transformer encoders, and a custom GNN on the same five raw inputs, and the spread between them is a fraction of a Sharpe point. Then somebody adds three well-chosen features, changes no algorithm at all, and doubles it. That is not a joke about deep learning, it is the actual leverage ratio between feature work and hyperparameter work.
Four Layers Between the Tape and the Model
The pipeline from exchange to model has four stages, and confusing them is half the reason feature work goes wrong. Raw market data is tick-level trades and quotes, daily OHLCV bars, fundamental filings, alternative feeds. Derived features are what you compute from that: returns, rolling statistics, ratios, embeddings. Factor scores are features with a directional interpretation — momentum, value, quality. ML inputs are the features as actually fed to the model, after standardization, winsorization, and missing-value handling.
The mistake most beginners make is to start at layer four and try to fix the ML. The leverage is at layers two and three. If your features carry no signal at layer three, no amount of model sophistication extracts any. The model is a sieve; if the water has no gold, the sieve finds no gold.
The next three sections sort features by where the raw material comes from, because that determines cost, update frequency, and crowding — three things worth settling before you write a line of code.
Price and Volume: Oldest, Richest, Most Crowded
Computed from price and volume series alone, no fundamental data feed required. Still one of the richest categories.
The base layer is returns, , computed at multiple horizons: 1-day, 5-day, 20-day, 60-day. There is already an empirical regularity here — the 1-day return is mostly noise, while the 20-day and 60-day returns carry the bulk of the cross-sectional signal. On top of that sit rolling statistics: rolling mean, standard deviation, skew, kurtosis. Volatility at multiple horizons is itself a feature, since high-vol names behave differently from low-vol names.
Momentum is the cumulative return over a lookback window, usually with the most recent month stripped out to avoid the well-documented one-month reversal effect, in which the recent stretch runs contrarian and pollutes the momentum estimate if you include it. Mean reversion z-scores, with mean and standard deviation over a rolling window of length , point the other way: a positive z-score means the price is high relative to recent history, negative means low, and mean reversion strategies buy the low scores and sell the high ones. Two signals with opposite signs out of the same price series, separated mostly by window length — which is why window choice matters about as much as the formula does in this category.
The volume branch covers relative volume (today’s volume over its 20-day average), on-balance volume, and the correlation between returns and volume, often called the volume-price confirmation feature. With tick data you can go further into microstructure: bid-ask spread, order book imbalance, trade sign (Lee-Ready), realized variance over the last ticks.
This category is popular because it is cheap and fast to compute. It is crowded for the same reason. A momentum signal you can build in 50 lines of code is a momentum signal a thousand other people have already built.
Fundamentals: Slow, but Not in the Price
Computed from company financial filings. Quarterly updates with roughly a 45-day reporting lag, so much slower, but carrying information that simply is not in a price series.
Valuation ratios are the classic value branch: price-to-earnings, price-to-book, EV/EBITDA, free cash flow yield. The Fama-French HML factor is, roughly, a long-short portfolio sorted on book-to-price. Growth is year-over-year change in revenue, earnings, and book equity, but growth is a feature and not a strategy: most academic work finds raw growth has weak or negative predictive power for returns, while growth relative to expectations — a growth-surprise feature — carries real signal.
Profitability deserves its own note. Alongside ROE and ROA there is gross profitability (gross profit over assets), and Novy-Marx (2013) presented evidence that gross profitability alone earns roughly the same Sharpe as the value factor while being largely orthogonal to it. Combining them comes close to free, which is rare in the factor world. Leverage (debt-to-equity, debt-to-EBITDA, interest coverage) is directionally more stable but more regime-dependent: highly levered firms underperform low-leverage firms in most regimes, with a conspicuous exception around financial crisis periods when deleveraging capacity itself becomes scarce. Earnings quality looks at accruals, the gap between accounting earnings and cash flow; the Sloan (1996) accruals anomaly — high-accrual firms underperform — is one of the most robust in the literature.
The real trap in this category is not in any formula, it is in the data, and it is called point-in-time integrity. The PE ratio you see today for 2020Q1 is not the PE ratio an investor saw in 2020Q1. The company has since restated, refiled, and restated again. Use the current value as if it were the historical value and you have walked lookahead bias in the front door. What you need is a fundamental database that preserves the as-reported value at each historical date, not a current snapshot.
Alternative: Sounds Proprietary, Usually Isn’t
The catch-all: anything that is not price/volume or fundamental. Most new research lives here.
Sentiment is mined from news headlines, earnings call transcripts, social media, and analyst reports. It is noisy, but uncorrelated with fundamentals, so the combination explains variance neither explains alone. Insider trading comes from SEC Form 4 filings, where cluster buying — several insiders buying inside a short window — is among the most persistent signals in the data. Short interest, the fraction of float sold short, predicts underperformance, but nonlinearly: extreme short interest can predict squeezes and positive returns, so using it linearly is simply wrong. Options flow covers unusual options activity, put-call ratios, and implied volatility skew, and can be computed daily at minute-level granularity.
Further out sits genuinely alternative data. Satellite imagery — car counts in retail parking lots, oil tank shadows, crop health — went from curiosity to a multi-billion-dollar industry. Web traffic and app usage give aggregate user counts, session lengths, and conversion rates at the public-company level, and a set of vendors now sells exactly this. Geopolitical and event features (country risk scores, trade policy changes, election outcomes) are the hardest to quantify and usually update discretely.
Alternative features are seductive because they sound proprietary. Most are not: if you can build a sentiment feature in a week, so can everyone else. The edge here is rarely in the data itself. It is in speed of incorporation (low-latency news feeds) or in the combination with traditional features.
Four Tests a Good Feature Has to Pass
With raw material in hand, the question becomes which features are worth keeping. Not all are equal, and four properties separate the ones that survive from the ones that backtest beautifully and die in production.
Persistent IC. The Information Coefficient is the rank correlation between the feature and forward returns, measuring how well it discriminates stocks that go up from stocks that go down. Persistence means stability across time: a feature with IC of 0.04 in 2015 and 0.04 in 2020 is worth far more than one with IC of 0.10 in 2018 and 0.00 in 2022, even though the second has more than twice the peak. So measure IC over multiple regimes, not just the backtest window. A feature whose IC is positive in every year of the last decade is something. One that is positive in 2019-2023 and negative everywhere else is almost certainly noise.
Low turnover. Strong prediction with high turnover is strong prediction with transaction costs eating it. If your feature is “stocks with the highest 20-day return,” you rebalance constantly: the signal is strong, the implementation is expensive. A usable rule of thumb here is that cross-sectional features (a stock’s position relative to peers) have lower turnover than time-series features (a stock relative to its own history), because cross-sectional rankings shift slowly.
Robustness across regimes. A momentum feature that works in up markets and fails in down markets is one you cannot trade without bolting a market timing model on top. The whole point of features is extracting a portable signal; if the signal works in one regime only, you may as well build a regime detector and a single-factor strategy, and at least then you know what you are betting on. Test across decades. The 2000s and the 2020s were structurally different — value worked in one, growth in the other — and a “value” feature that only works in the 2000s is a regime bet, not a value bet.
No obvious spurious story. The bar here is lower than you might expect. You do not need a causal story, since most ML alphas do not have one. You need to be able to rule out an obvious spurious one. If your feature is “the third digit of the ticker symbol” and it predicts returns, you have a problem: the in-sample correlation is real, it is also almost certainly noise, and you have no way to distinguish the two cases. Features that do have a causal story — momentum from under-reaction, value from over-extrapolation, accruals from earnings management — are easier to defend to a risk committee and easier to reason about when the strategy starts behaving strangely.
A Worked Example: Rebuilding Momentum Four Times
The best way to show those four tests together is to take one feature and fix it repeatedly. The simplest momentum feature is the 12-month return:
This works, and it has been the single most studied feature in asset pricing since Jegadeesh & Titman (1993). It also has well-known failure modes: short-term reversal (the most recent month is a strong contrarian signal, so including it pollutes the estimate), the 2009 momentum crash (a brief period in which the strategy lost 50%+), and persistent crowding.
The first change just drops the trailing month:
The signal is more stable and the 2009 drawdown materially smaller. That step targets the reversal problem specifically.
The second divides by 60-day volatility:
Now the signal measures risk-adjusted momentum rather than raw return. A stock up 20% on 40% annualized vol is not as momentum-y as a stock up 20% on 15% vol, and dividing by volatility captures exactly that difference.
The third moves it into the cross-section:
This is the z-score of risk-adjusted momentum across the universe. The model is now told “this stock is in the 90th percentile of risk-adjusted momentum today,” not “this stock is up 20% over the last year.” The cross-sectional framing strips out market regime effects — which is precisely what the third test asked for, and it works in bull and bear alike — makes the feature directly usable for ranking, and lowers turnover on the way, clearing the second test too.
Each step is a small change. Each is a meaningful improvement. Most quants stop at step one on their first momentum experiment, get a positive but unstable signal, and move on. The progression from step one to step four is where the edge lives.
Five Mistakes Everyone Makes Once
The hope is that you make each of them exactly once.
Lookahead bias is the classic: computing today’s return from today’s close, then training a model on that return as the target. The feature “today’s return” is the label “today’s return,” so the model achieves a perfect in-sample fit and total garbage out of sample. The fix is unexciting — use yesterday’s price for today’s return and tomorrow’s price for tomorrow’s return. Every feature must be available strictly before the label it predicts. Every single one, no exceptions. (López de Prado, Advances in Financial Machine Learning, Ch. 3 on Labeling and Ch. 7 §7.3, Why K-Fold Fails in Finance. ISBN 978-1119482086.)
Survival bias hides in the universe. You have a set of currently traded US equities, you pull the data, compute features, train the model. But today’s universe is not the universe of 2015: stocks that were delisted, acquired, or went bankrupt are absent, their often very negative features (they were distressed at the time) are absent with them, and the model never learns to predict them at all. The fix is a point-in-time universe that includes stocks which existed historically even if they do not now. The historical constituents of the S&P 500 are well documented, and the CRSP database has the full historical tape with delisting returns.
Data snooping is trying 100 feature variations and reporting the one that worked. The literature calls it researcher degrees of freedom, or more bluntly multiple testing bias: the probability that at least one of 100 pure-noise features appears to predict returns at is roughly 99%. The fix is process discipline rather than a statistical trick — pre-register the features you will test before you look at the data, or use deflated Sharpe ratios and out-of-sample validation rigorously.
Wrong scaling is a pure engineering failure: you feed a raw PE ratio (range 0-100) into a model alongside binary indicators (range 0-1), the PE dominates the loss function purely on magnitude, and the binary features contribute nothing. The fix is to z-score each feature, or use a scale-invariant tree model (XGBoost, LightGBM, Random Forest). Tree models handle mixed scales natively; linear models and neural nets do not.
Non-stationary features are the hardest to defend against. A feature that worked in 2010-2019 may not work in 2020-2025, because the macro environment changes — rate regimes, sector leadership, retail versus institutional flows. A feature calibrated on a single decade may be useless in the next. The fix is rolling validation: re-estimate each feature’s IC every year, flag anything that has decayed below its historical 25th percentile, and retire it. Which is really the first test in operational form — IC persistence is not a one-time check, it is a standing job.
Winsorization and Outliers: Hygiene Before the Model
Raw financial data is full of outliers. Daily returns on individual stocks exceed ±50% on earnings days and during corporate actions. Ratios can be negative, infinite, or undefined (the PE of a company with zero earnings). Volume spikes to 100x normal on index rebalance days. Feed those raw and the outliers dominate the loss function, which is the same disease as wrong scaling in the previous section, showing a different symptom.
Winsorization is the standard fix: cap extreme values at percentile thresholds, typically the 1st and 99th (or 0.5th and 99.5th). Note that the values are not removed but pulled to the cap, so the data point still contributes without taking over. That is the right treatment when outliers are real but unrepresentative — a single day’s earnings pop should not drive the model’s loss.
Median absolute deviation (MAD) standardization is more robust than mean/std: subtract the median and divide by the MAD rather than subtracting the mean and dividing by the standard deviation. The standardization itself then stops being skewed by outliers, which matters most when the feature distribution is heavy-tailed. Log transformation suits features with multiplicative dynamics — prices, volumes, market caps — turning multiplicative growth into additive growth, making the distribution more symmetric, and damping extremes.
The rule is to apply winsorization and standardization as part of the feature pipeline rather than as an afterthought. A model trained on raw, unprocessed features will be dominated by outliers and will not generalize.
Feature Importance: Knowing What Your Model Sees
Once the features are built and the model is trained, the natural next question is which features the model is actually using. Note that this is not the question of which features might be useful. They are frequently not the same set.
Three standard methods, each with its own failure mode.
Gain-based importance is the default in XGBoost and LightGBM: for each feature, sum the total reduction in loss across all splits that used it. Features used in many splits, in early splits, or in splits that cut loss sharply score high. It is fast and native to tree models. The catch is that high-cardinality features — continuous variables with many distinct values — are systematically inflated because they offer more candidate split points. A continuous momentum feature will look more important than a binary regime indicator even when the indicator carries more economic signal.
Permutation importance takes the opposite approach: shuffle one column across the dataset, breaking the relationship between that feature and the target, and measure how far model performance drops. Repeat per feature. It is model-agnostic and reflects a feature’s actual marginal contribution. The catch is correlation: permuting one feature lets information leak in through the others, the model partially recovers the signal, and the importance is underestimated. The fix is conditional permutation importance, permuting within groups of similar feature values.
SHAP (SHapley Additive exPlanations) is a game-theoretic decomposition of a prediction into exact per-feature contributions that sum to the prediction. It is theoretically grounded — the unique attribution satisfying a particular set of axioms — and consistent across models. The catch is cost (exponential in feature count in the worst case, though approximations exist) and the fact that global importance summaries can mislead when features are correlated.
Since the three fail in different ways, they check each other: screen quickly with gain, then verify with permutation or SHAP. Agreement means the ranking is real. Disagreement means a feature-interaction or correlation problem that needs more careful analysis.
The most useful question to ask of feature importance, though, is not “which feature is most important” but “is importance spread evenly, or concentrated in one or two?” A model depending on 5 features is more robust than one depending on 1. Concentration is fragile: when that feature decays, the model collapses with it.
Feature Interactions: When They Matter
A linear model assumes each feature contributes independently. A tree model captures interactions natively — a split on A followed by a split on B is an A×B interaction — and a neural net captures them implicitly through hidden layers. So the question “do interactions matter” is largely the question “linear model or tree model.”
Two kinds are genuinely worth caring about. Cross-feature interactions, like momentum × volatility: low-vol momentum behaves differently from high-vol momentum, trees pick it up automatically, and linear models miss it unless you construct the term explicitly. And regime-conditional interactions, like value × interest rate level: the value factor behaves differently in low-rate and high-rate regimes, and expressing that requires either a regime indicator feature or a model that can learn regime-conditional behavior.
Almost everything else is not worth constructing explicitly. A 50-feature set has 1,225 pairwise interactions, and adding all of them to a linear model is nearly all garbage. The interactions that matter are the ones with an economic story.
The test is direct: start with a linear model on the raw features. If its cross-validation performance is close to the tree model’s, interactions do not matter much and the linear model is preferable — simpler, less overfit risk. If the tree model materially outperforms, interactions matter, and you either keep the tree or construct the economically motivated terms explicitly. The comparison hands you one extra piece of information for free: the size of the tree model’s lead is roughly the amount of unexpressed structure sitting in your feature set.
Last Thing
A common way to misallocate time: months spent tuning XGBoost hyperparameters — learning rate, max depth, min child weight, column sampling — for a fraction of a percent over a default-parameter baseline, when the same months spent on feature engineering move the number by an order of magnitude more. The model is rarely the bottleneck.
The feature is the strategy. The model is the implementation. Most quant ML fails because the implementation is being optimized on top of a strategy that does not exist.
References
- López de Prado, M. (2018). Advances in Financial Machine Learning. Wiley. Ch. 3 (Labeling) and Ch. 7 §7.3 (Why K-Fold Fails in Finance). ISBN 978-1119482086.
- Gu, S., Kelly, B., & Xiu, D. (2020). “Empirical Asset Pricing via Machine Learning.” Review of Financial Studies, 33(5), 2223-2273.
- Jegadeesh, N. & Titman, S. (1993). The original momentum paper.
- Novy-Marx, R. (2013). The gross profitability factor.
- Sloan, R. (1996). The accruals anomaly.
- Molnar, C. Interpretable Machine Learning, 2nd ed. The chapters on feature importance, permutation, and SHAP.
- McKinney, W. Python for Data Analysis, 3rd ed. ISBN 978-1098104030. Implementation detail for rolling statistics and grouped operations.