Build robust, leakage-free trading systems powered by deep sequence models in Python. This hands-on guide shows how to turn raw market data into deployable signals using Transformers, LSTMs, and Temporal Convolutional Networks, then carry those signals through evaluation, execution, and portfolio construction. Written for quants, researchers, and systematic traders who demand reproducible results and rigorous validation, it focuses on practical techniques that hold up out of sample.
Every chapter includes a full Python code demo that moves from data construction to model training and trading-aligned evaluation. You will learn how to design predictive targets that match holding periods, prevent look-ahead, optimize with cost-aware losses, and monitor models in production. The emphasis is on causality, efficiency, and reliability across regimes and asset classes.
What you will learn:
Engineer event-based datasets with tick, volume, and dollar bars, synchronize cross-asset panels, and clean microstructure noiseCreate triple-barrier labels and meta-labels aligned with tradable horizonsEliminate leakage using purged and embargoed cross-validation and walk-forward splitsBuild rolling and exponentially weighted normalizations, volatility targeting, and fractional differentiation for stationarityConstruct sliding windows and batching strategies for causal training without overlap biasOptimize with trading-aware objectives including differentiable Sharpe, quantile losses, and turnover penaltiesTrain LSTMs and GRUs with truncated BPTT, stateful inference, and robust regularizationImplement TCNs with causal dilated convolutions and receptive fields tuned to holding periodsApply causal Transformers with masked self-attention, time encodings, and efficient long-context variantsPretrain with self-supervised objectives tailored to market sequences and transfer to downstream tasksModel cross-sectional signals with shared encoders, cross-asset attention, and ranking headsAdapt to regime shifts via drift detection, mixture-of-experts, and lightweight adaptersBacktest with realistic costs, slippage, and latency, then map signals to execution and position sizingConstruct portfolios with constraints, risk models, and neutralization, and quantify uncertainty with ensembles and conformal predictionInterpret sequence models and monitor live calibration, drift, and performanceWhy this book:
Code-first and production-minded: every chapter ships with a complete Python demoCausal and trading-aligned design choices from data to decisionsScales from daily bars to tick data and across equities, futures, crypto, and FXIncludes:
Full Python code demos in every chapterReusable pipelines for labeling, windowing, loss functions, and evaluationPractical tips for latency, memory efficiency, and deployment