# Feature Engineering

> Features are the inputs that give trading models a chance. Learn the main feature families, how to make them stationary and comparable, and how to avoid leakage.

Source: https://learn.tradelabsai.com/machine-learning/feature-engineering/  
Track: Machine Learning · Level: Advanced · Updated: 2026-10-03  
Publisher: TradeLabs AI (https://tradelabsai.com). Education, not financial advice.  
Cite as: TradeLabs Learn, "Feature Engineering", https://learn.tradelabsai.com/machine-learning/feature-engineering/

In trading machine learning, the choice of inputs usually matters more than the choice of model. Feature engineering means turning raw data, such as prices, volumes, financial statements or news, into variables that capture something meaningful and that a model can learn from. Good features are grounded in a reason the market might behave a certain way, are calculated using only past information and are scaled so they mean the same thing across time and across assets. A simple model with thoughtful features almost always beats a complex model fed raw prices.

## Main feature families

| Family | Examples | Lesson |
|---|---|---|
| Momentum and trend | Past returns over 1, 3 and 12 months; distance from moving averages | [Momentum Factor](https://learn.tradelabsai.com/research/momentum-factor/) |
| Mean reversion | Short term return, z score versus a rolling mean, RSI | [Mean Reversion](https://learn.tradelabsai.com/strategies/mean-reversion/) |
| Volatility | Realised volatility, ATR, implied volatility, volatility ratios | [Historical and Realized Volatility](https://learn.tradelabsai.com/volatility/historical-volatility/) |
| Volume and liquidity | Relative volume, turnover, spread, order imbalance | [Relative Volume](https://learn.tradelabsai.com/volume/relative-volume/) |
| Fundamentals | Valuation ratios, profitability, growth, revisions | [Value Factor](https://learn.tradelabsai.com/research/value-factor/) |
| Calendar | Day of week, month, time to earnings or expiry | [Seasonality in Commodities](https://learn.tradelabsai.com/commodities/seasonality-in-commodities/) |
| Cross asset | Rates, dollar, commodities, sector returns | [Currency Correlations](https://learn.tradelabsai.com/forex/currency-correlations/) |
| Sentiment and alternative | News tone, social activity, web traffic | [Sentiment Data](https://learn.tradelabsai.com/alternative-data/sentiment-data/) |

## Make features stationary

Raw prices trend and change scale over time: a stock at $20 in 2015 and $200 today. A model that learns from price levels learns nothing transferable. Convert to forms with stable statistical properties:

- **Returns** instead of prices.
- **Ratios** such as price divided by its 50 day average.
- **Changes** in rates or spreads.
- **Volatility scaled values,** such as a return divided by recent volatility.

See [Stationarity, Differencing and Unit Roots](https://learn.tradelabsai.com/math/stationarity/).

## Make features comparable

| Technique | Purpose |
|---|---|
| Rolling z score | Express a value relative to its own recent history. See [Percentiles, Quantiles and Z-Scores](https://learn.tradelabsai.com/math/z-scores/) |
| Cross sectional rank | Rank each asset against others on the same date, from 0 to 1 |
| Volatility scaling | Put calm and volatile assets on one scale |
| Winsorising | Cap extreme values to limit outlier influence. See [Outliers and Robust Statistics](https://learn.tradelabsai.com/math/outliers-and-robust-statistics/) |

Use only past data for any scaling. A z score computed with a full sample mean leaks the future. See [Rolling and Expanding Windows](https://learn.tradelabsai.com/math/rolling-and-expanding-windows/).

**Example: A volatility scaled momentum feature**
Stock A rose 10% over the last 3 months with annualised volatility of 40%; stock B rose 6% with volatility of 12%. Raw momentum ranks A higher. Dividing each return by its volatility gives 10 divided by 40, or 0.25, for A, and 6 divided by 12, or 0.50, for B. On a risk adjusted basis, B's move is twice as strong, and research on momentum suggests risk adjusted measures are often more reliable. Using the scaled version stops the model from simply learning to favour the most volatile stocks. See [Volatility and ATR-Based Sizing](https://learn.tradelabsai.com/risk/volatility-and-atr-based-sizing/).

## Avoiding leakage

| Leak | Example | Fix |
|---|---|---|
| Same bar data | Using today's close to predict today's return | Shift features by one period |
| Full sample statistics | Normalising with mean and standard deviation of all data | Use rolling or expanding windows |
| Restated fundamentals | Using revised earnings | Point in time data. See [Point-in-Time and Survivorship-Free Data](https://learn.tradelabsai.com/programming/point-in-time-data/) |
| Survivorship | Features only for stocks that still exist | Survivorship free universe |
| Target in disguise | A feature computed over the target period | Check every feature's time window |

See [Data Leakage](https://learn.tradelabsai.com/research/data-leakage/) and [Look-Ahead Bias](https://learn.tradelabsai.com/research/look-ahead-bias/).

## How many features?

More features are not always better. Each extra feature adds a chance of fitting noise, and many features are highly correlated. Start with a few well motivated ones, check their individual predictive power out of sample, and add more only if they improve validation results. Techniques such as principal component analysis or clustering can group correlated features. See [Overfitting and Curve Fitting](https://learn.tradelabsai.com/research/overfitting-and-curve-fitting/).

## Testing a single feature

Before modelling, test each feature alone: sort assets or periods into groups by the feature and compare later returns, or compute the information coefficient, the rank correlation between the feature and future returns. A feature that shows no relationship alone rarely becomes useful inside a model. See [Signal Discovery](https://learn.tradelabsai.com/research/signal-discovery/).

## Frequently asked questions

### What is feature engineering in trading?

Creating model inputs from raw data, such as returns, volatility, valuation ratios or sentiment scores, in forms a model can learn from.

### Why should features be stationary?

Non stationary inputs such as raw prices change scale over time, so patterns learned in one period do not apply in another.

### How do I avoid look ahead bias in features?

Use only data available before each prediction, shift features appropriately, use rolling statistics and use point in time fundamental data.

Next, learn how to validate models properly in [Model Evaluation and Cross-Validation](https://learn.tradelabsai.com/machine-learning/cross-validation/).

## Continue learning

- Next lesson: [Model Evaluation and Cross-Validation](https://learn.tradelabsai.com/machine-learning/cross-validation/)
- Previous lesson: [Neural Networks and Deep Learning](https://learn.tradelabsai.com/machine-learning/neural-networks/)
- Related: [Neural Networks and Deep Learning](https://learn.tradelabsai.com/machine-learning/neural-networks/): Neural networks power deep learning, from LSTMs to transformers. Learn how they work, where they help in trading, especially with text and images, and their risks.
- Related: [Supervised vs Unsupervised Learning](https://learn.tradelabsai.com/machine-learning/supervised-learning/): Supervised learning trains models on examples with known answers. Learn regression versus classification, how to define trading targets and labels, and key pitfalls.
- Related: [Data Leakage](https://learn.tradelabsai.com/research/data-leakage/): Data leakage lets information from test data or the future slip into model training. Learn common leaks in trading and machine learning and how to prevent them.
- Related: [Stationarity, Differencing and Unit Roots](https://learn.tradelabsai.com/math/stationarity/): A stationary series has stable statistical properties over time. Learn why prices are non stationary, how to test with ADF and KPSS and how to make data stationary.
- Related: [Percentiles, Quantiles and Z-Scores](https://learn.tradelabsai.com/math/z-scores/): A z score shows how many standard deviations a value is from its mean. Learn the formula, its uses in mean reversion and pairs trading, and the pitfalls.
- Related: [Combining Signals](https://learn.tradelabsai.com/research/combining-signals/): Combining several weak signals often beats relying on one strong one. Learn standardisation, weighting methods, correlation between signals and pitfalls to avoid.
