2025xLSTM Directional Trading

S&P 500 Trading (Experiment)

A walk-forward ensemble system that predicts next-day S&P 500 direction (up/down) using an xLSTM architecture with causal wavelet denoising, multimodal feature engineering, and quarterly-retrained walk-forward backtesting from 2021–2024.

*This project was developed solely as a curious exploration; the model's performance is negligible in application (Efficient Market Hypothesis).*

Raw financial time series are contaminated with high-frequency noise that obscures the underlying price signal. This project implements a complete quantitative trading pipeline using causal Daubechies-8 wavelet denoising (db8, level-4, soft thresholding with a 256-day sliding window) to suppress noise without lookahead bias.

The extended LSTM (xLSTM) architecture combines mLSTM blocks with matrix-valued memory for exponential memory capacity and sLSTM blocks with exponential gating for sharp state transitions, using causal convolution, group normalization, and gated MLP residuals. The model processes 50+ strictly stationary features spanning returns, trend, momentum, volatility, volume, macroeconomic indicators (with publication lag adjustments), NYT headline sentiment, and VIX signals, ensuring the model learns market dynamics rather than memorizing price regimes.

01

Causal Wavelet Denoising

Applied causal Daubechies-8 (db8) wavelet denoising with 4th-level decomposition and soft thresholding using a 256-day sliding window. Each timestep is denoised using only past data, guaranteeing no future information leaks. The Universal (VisuShrink) threshold is estimated via Median Absolute Deviation (MAD) of the finest detail coefficients.

02

Stationary Feature Engineering

Built a feature matrix of 50+ strictly stationary variables (ratios, returns, and bounded oscillators) so the model learns dynamics rather than memorizing price levels. Includes multi-horizon returns, trend ratios, momentum oscillators, volatility bands, volume flows, lagged macroeconomic indicators with publication-delay shifts, rolling NYT sentiment z-scores, and VIX signals.

03

xLSTM Model & Walk-Forward Backtesting

Trained an xLSTM ensemble with alternating mLSTM and sLSTM blocks (d_model=48, 2 blocks, 4 heads, expand factor 2) using AdamW optimization, label smoothing, and gradient clipping. Implemented quarterly walk-forward retraining from 2021–2024 with label-known-date constraints, StandardScaler fit on training data only, and 2-year validation windows, evaluating via accuracy, Sharpe ratio, and maximum drawdown against Long/Short, Long/Flat, DCA, and Buy & Hold strategies.

Implemented causal wavelet denoising with Daubechies-8 (db8), 4th-level decomposition, and soft thresholding using a 256-day sliding window, eliminating lookahead bias while preserving trend signal in S&P 500 OHLCV data.

Developed 50+ stationary feature set including multi-horizon returns, EMA/SMA ratios, RSI, stochastic oscillators, volatility measures, volume indicators, lagged macroeconomic data (GDP, inflation, unemployment, interest rates, gold), NYT headline sentiment z-scores, and VIX signals.

Built xLSTM ensemble with alternating mLSTM and sLSTM blocks (d_model=48, 2 blocks, 4 heads), quarterly walk-forward retraining from 2021–2024 with label-known-date constraints, achieving robust directional prediction through walk-forward backtesting.

"This project demonstrates how modern deep learning architectures, specifically xLSTM with matrix-valued memory and exponential gating, can be combined with rigorous signal processing and walk-forward validation to produce a robust, lookahead-free directional trading system."