Free lesson · Quant strategy development
02 / The variables that actually enter the decision
Open interactive lessonPractice calculationsExplore labs
Start with the idea
A feature is useful only after its timing, unit and role are defined. Normalising a predictor can make instruments comparable, but it can also erase economically useful level information or amplify tiny denominators.
Symbols, units & horizon
- xᵢ,ₜ: feature of instrument i at time t
- μ̂ᵢ,ₜ and σ̂ᵢ,ₜ: mean and SD estimated from permitted history
- zᵢ,ₜ: dimensionless standardised feature
- rₜ,ⱼ: within-period log return j
- m: count of within-period intervals
- RVₜ: square root of sum of squared returns, a realised-volatility measure for that period
- Hat: estimate
When and why to use this
Use standardised features to compare signal strength and realised volatility to scale exposure. Record whether each variable predicts returns or merely constrains execution and risk.
Useful variables have a defined mechanism, timestamp, unit, and action. More inputs can make a backtest easier to fit while making the economic story harder to test. Distinguish predictors from risk controls, execution controls, and accounting variables; each has a different role.
| Variable family | Examples / units | How it changes a bot |
|---|---|---|
| Return and trend | Lagged returns, moving-average gap, momentum / decimal return | Forecast direction and strength at a specified horizon |
| Relative value | Residual spread, valuation ratio, basis / price or standard deviations | Estimate deviation from a defensible relationship |
| Volatility and tails | Realised volatility, range, jump indicators / return units | Scale exposure, widen uncertainty, constrain losses |
| Liquidity and activity | Spread / bp; volume / shares; depth / units | Decide whether to trade and how much is executable |
| Order flow | Signed volume, imbalance, cancellations / normalised units | Short-horizon forecast and adverse-selection estimate |
| Carry and financing | Rates, dividends, borrow, funding / rate per period | Adjust expected holding return and feasibility |
| Fundamentals and events | Earnings surprise, revisions, issuance / timestamped values | Condition the forecast on newly available information |
| Cross-asset context | Market, sector, curve, credit, currency returns | Separate common exposure from instrument-specific information |
| Portfolio state | Positions, cash, beta, inventory, pending orders | Constrain new orders using total actual and potential exposure |
| Operational state | Quote age, feed gaps, rejects, reconciliation differences | Pause, reconcile, or escalate before further trading |
Standardise a feature and aggregate squared moves
- Solve the scale-location representation for z: subtract μ and divide by positive σ. Invert with .
- For intraperiod log returns, realised variance is the sum of their squares; take its square root for realised volatility. It is a quadratic-variation estimator with sampling and microstructure limitations.
x=12, fitted mean=10, SD=2 gives z=1. Intraperiod returns .01,−.02,.01 give RV=√.0006=.024495, or 2.4495% for that observation interval.
A time-series z-score compares today’s feature with that instrument’s past, using a documented window available at the decision. A cross-sectional rank compares instruments at the same time. Do not confuse the two. Realised volatility above aggregates intraperiod squared log returns; annualisation and overnight moves require an explicit convention.
Python implementation
Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.
from math import sqrt
def z_score(value, training_mean, training_sd):
if training_sd <= 0:
raise ValueError("Positive training SD required")
return (value-training_mean)/training_sd
def realized_volatility(intraperiod_log_returns):
"""No annualisation; microstructure noise and sampling choice matter."""
return sqrt(sum(r*r for r in intraperiod_log_returns))
print(z_score(12,10,2), realized_volatility([.01,-.01]))Continue learning
Quant Strategy Development — all lessons- 01 / Start with a source of return
- 02 / The variables that actually enter the decision
- 03 / Test predictive information before a complex model
- 04 / Momentum and trend: information that persists
- 05 / Mean reversion and relative value
- 06 / Carry, events, and liquidity provision
- 07 / Convert a forecast into a trade decision
- 08 / Build a bot that preserves the experiment
- 09 / Decide whether the edge is real enough to continue
Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations