liveBook · Manning

Chapter 10: Building the quantitative engine: Market direction prediction with machine learning

What you will learn in chapter 10 of Financial AI in Practice

The introduction shifts the book’s focus from protecting capital against credit and fraud losses to pursuing market-beating investment returns.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction shifts the book’s focus from protecting capital against credit and fraud losses to pursuing market-beating investment returns.

Key terms: alpha, market-beating returns, protect capital

10.1 Architecting our AI-powered investment strategy

The section places an AI-powered investment strategy in the evolution of quantitative finance and maps a seven-step investment workflow onto four architectural layers.

Key terms: Quant 1.0, Quant 2.0, Quant 3.0, Quant 4.0, Modern Portfolio Theory, factor models, seven-step process, data asset layer, modeling layer, strategy and monitoring layer

10.1.1 Architecting our strategy: Aligning the playbook with the four-layer framework

This section maps a seven-step investment workflow onto the book’s four-layer framework to give each part of the application a clear architectural role.

Key terms: seven-step process, four-layer framework, data asset layer, modeling layer, strategy and monitoring layer, application layer

10.1.2 Defining our scope: A practical path to powerful results

This section sets a practical scope for the quantitative engine: daily and weekly predictions using widely available information rather than speed or exclusive data.

Key terms: High-Frequency Trading (HFT), proprietary alternative datasets, daily and weekly prediction horizons, widely available data sources

10.2 The data foundation: The lifeblood of a quant strategy

Defines a quantitative investment strategy and explains why the quality of its data matters more than model complexity.

Key terms: quantitative strategy, quants, data quality, sourcing, cleaning, and engineering data

10.2.1 The universe of financial data: A practitioner’s reality check

This section explains the strengths and pitfalls of market, fundamental, and alternative data, then gives five criteria for choosing data sources for a quantitative strategy.

Key terms: market data, adjusted prices, corporate actions, survivorship bias, delisted securities, candlestick charts, line graphs, time bars, tick bars, volume bars

10.2.2 Our strategic choice: Why ETFs as economic proxies?

The section explains why ETFs are useful signals for predicting market direction and warns that relationships between them can change under stress.

Key terms: ETFs, economic proxies, directional signals, SPY, GLD, regime-dependent, correlation, safe-haven role, extreme liquidity events

10.2.3 Building the ETF toolkit: Selecting economic barometers

The section explains why a deliberately selected set of ETFs can serve as economic and market barometers for a quantitative strategy.

Key terms: economic barometers, proxy, commodity diversification, factor-driven ETFs, risk premiums, credit-focused ETFs, HYG, LQD, spread differential, credit risk barometer

10.3 Acquiring and preparing the ETF data

The section explains how to choose a useful historical window for ETF data, acquire it for prototyping, and check its quality before modeling.

Key terms: ETF universe, historical price and volume data, public market data, data ingestion pipeline, lookback window, market regimes, rolling 10-year window, stress-testing events, fair-weather strategies, data quality checks

10.3.1 Beyond simple APIs: Industrial-strength data architecture

The section explains why an institutional quantitative data pipeline must make data trustworthy, timely, and reusable, not merely handle more instruments than a yfinance prototype.

Key terms: production quant system, trust, validated, reproduce, data source diversification, automated quality gates, enrichment before modeling, controlled data transformations, workflow orchestration, parallel processing

10.4 Feature engineering: Crafting predictive signals

This section frames feature engineering for predicting tomorrow’s SPY direction and explains why economically meaningful inputs matter more than model complexity.

Key terms: feature engineering, target variable, predictors, SPY, ETFs, noise-fitting, logistic regression, rolling 30-day volatility spread

10.4.1 Step 1: Defining the target variable (Y-label)

The section defines a next-day, three-class market-direction target using a conservative return threshold and explains the resulting label imbalance.

Key terms: target variable, Y-label, next day’s return direction, look-ahead bias, R t +1, bullish move, bearish move, neutral move, ±1% cutoff, target distribution

10.4.2 Step 2: Engineering quant-grade predictive features

The section builds predictive features for 20 ETFs by combining asset-level technical indicators with cross-asset relationships, while distinguishing the educational pipeline from institutional-scale feature engineering.

Key terms: technical indicators, ETF universe, momentum, volatility, volume, cross-asset relationships, rolling correlations, cross-asset spreads, alpha, dimensionality reduction

10.4.3 Feature engineering realities

The section explains practical checks that make engineered market signals more robust when relationships, conviction, and trading conditions change.

Key terms: correlation breakdown, SPY-TLT, flight to quality, liquidity stress, volume ratio, high-conviction moves, false breakouts, three-class classification, neutrality, forced binary predictions

10.4.4 From features to alpha: Next steps

This section connects engineered ETF features to the aim of finding durable trading signals and stresses consistent feature management for modeling.

Key terms: market relationships, regime changes, sustainable alpha, engineered features, versioned, model training, live inference

10.5 Predictive modeling: Selecting and validating robust ML methods

The section introduces the challenge of choosing a financial prediction model and calls for a skeptical approach to model selection.

10.5.1 The accuracy myth: Why high predictions demand scrutiny

This section explains why reported market-direction accuracy needs scrutiny and why a small, reliable edge can matter more than a spectacular backtest result.

Key terms: survivorship bias, look-ahead bias, regime filtering, overfitting, operating environment, class imbalance, SPY prediction task, naive model, baseline, directional accuracy

10.5.2 Our model choice: Why random forest excels for financial signals

This section explains why random forest suits financial prediction and how it fits within broader institutional modeling strategies.

Key terms: non-linearity, interactions, regime-dependent interactions, feature space, bagging, bootstrap aggregating, low SNR, variance-reduction, decorrelated decision trees, feature importances

10.5.3 Time-series cross-validation: The foundation of intellectual honesty

This section explains why market-direction models need time-respecting validation and why class imbalance makes accuracy misleading.

Key terms: k-fold cross-validation, arrow of time, time-aware validation splits, class imbalance, bullish (1), bearish (–1), neutral (0), imbalance-aware evaluation metrics

10.5.4 Building a robust validation scheme

This section builds a time-ordered validation scheme for market predictions and adds leakage-aware separation between training and test data.

Key terms: TimeSeriesSplit, expanding window, validation set, information leakage, 20-day momentum, performance metrics, embargo, purging, create_embargoed_splits, temporal separation

10.5.5 Training the final model with optimized parameters

This section trains a conservatively configured random forest and interprets its out-of-sample predictions as a modest, conditional trading signal rather than a proven profitable strategy.

Key terms: random forest, overfitting, tree depth, samples per leaf, feature sampling, minimum samples for splits, Directional Accuracy, neutral market days, volatility thresholds, trade filtering

10.6 From signal to strategy: Next steps

The section interprets the ETF model as a diagnosed but limited signal and explains why profitable investing requires more than predictive accuracy or a single model.

Key terms: predictive accuracy, profitability, payoff ratio, transaction costs, statistical edge, economic one, time-series validation, embargo, evaluation metrics, diagnosed signal

10.7 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 9: Unveiling hidden connections: Graph-based analytics for advanced fraud detection Chapter 11: Building the qualitative engine with news analysis and LLMs →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.