Trading Dev AcademyFree quant education

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 familyExamples / unitsHow it changes a bot
Return and trendLagged returns, moving-average gap, momentum / decimal returnForecast direction and strength at a specified horizon
Relative valueResidual spread, valuation ratio, basis / price or standard deviationsEstimate deviation from a defensible relationship
Volatility and tailsRealised volatility, range, jump indicators / return unitsScale exposure, widen uncertainty, constrain losses
Liquidity and activitySpread / bp; volume / shares; depth / unitsDecide whether to trade and how much is executable
Order flowSigned volume, imbalance, cancellations / normalised unitsShort-horizon forecast and adverse-selection estimate
Carry and financingRates, dividends, borrow, funding / rate per periodAdjust expected holding return and feasibility
Fundamentals and eventsEarnings surprise, revisions, issuance / timestamped valuesCondition the forecast on newly available information
Cross-asset contextMarket, sector, curve, credit, currency returnsSeparate common exposure from instrument-specific information
Portfolio statePositions, cash, beta, inventory, pending ordersConstrain new orders using total actual and potential exposure
Operational stateQuote age, feed gaps, rejects, reconciliation differencesPause, reconcile, or escalate before further trading
zi,t=xi,t−μ^i,tσ^i,t,RVt=∑j=1mrt,j2
Algebra and arithmetic

Standardise a feature and aggregate squared moves

  1. Solve the scale-location representation x=μ+σz for z: subtract μ and divide by positive σ. Invert with x=μ+σz.
  2. 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.
Work it by hand

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
  1. 01 / Start with a source of return
  2. 02 / The variables that actually enter the decision
  3. 03 / Test predictive information before a complex model
  4. 04 / Momentum and trend: information that persists
  5. 05 / Mean reversion and relative value
  6. 06 / Carry, events, and liquidity provision
  7. 07 / Convert a forecast into a trade decision
  8. 08 / Build a bot that preserves the experiment
  9. 09 / Decide whether the edge is real enough to continue

Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations