← Back to projects

Automated Market Forecasting — Notes

Comparing LightGBM and XGBoost for short-horizon return prediction using engineered OHLCV signals and risk-aware evaluation.

Time Series LightGBM XGBoost OHLCV Feature Engineering Risk Metrics

Problem

Short-horizon financial forecasting is noisy and non-stationary. Raw predictive accuracy is often modest, so the real question is whether a model produces stable, risk-adjusted performance under a time-aware evaluation scheme.

What We Built

  • Cleans and standardizes daily OHLCV data
  • Engineers time-series features (trend, momentum, volatility, volume, technical signals)
  • Predicts 5-day forward returns using only past information (no leakage)
  • Evaluates models with walk-forward (time-aware) validation
  • Reports risk-adjusted financial metrics alongside forecasting quality

Models Compared

  • LightGBM — fast, highly responsive gradient boosting; strong short-term reactivity but more sensitive to noise.
  • XGBoost — more conservative tree growth with regularization; smoother and more stable out-of-sample behavior.

Data

  • Source: Kaggle “World Stock Prices” (daily OHLCV)
  • Time range: ~2000 → 2025 (multi-year horizon)
  • Modeling subset: 10 liquid large-cap equities (diverse sectors)
  • Target: 5-day forward return (returns rather than prices)

Features

  • Lagged returns + rolling statistics
  • Volatility + range measures
  • Volume/participation signals
  • Technical indicators (RSI, MACD-style)

Applied a simple feature selection step (remove near-zero correlation features) to keep the set compact and reduce noise/overfit.

Results

Highlights
  • XGBoost is smoother and more stable; LightGBM is more reactive.
  • Walk-forward validation keeps evaluation time-aware and leakage-free.
  • Risk-aware metrics translate signal quality into real trading behavior.
Sharpe Max drawdown Win rate
Data & Feature Engineering
Coverage, cleaned trajectories, and engineered signals.
Dataset coverage from 2000 to 2025
Dataset coverage (2000–2025). High-density daily OHLCV across market regimes.
Cleaned stock price trajectories
Cleaned price trajectories (sample of tickers). Regime shifts and volatility clustering.
Feature breakdown by category
Feature breakdown by category across technical, volume, lag, and volatility signals.
Model Behavior — NVDA
Actual vs prediction, 2024–2025.
NVDA actual vs LightGBM prediction
LightGBM tracks the medium-term trend while reacting more aggressively to short-horizon fluctuations.
NVDA actual vs XGBoost prediction
XGBoost produces smoother forecasts with improved stability under volatile segments.
Model Behavior — AAPL
Actual vs prediction, 2024–2025.
AAPL actual vs LightGBM prediction
LightGBM adapts quickly to local trend changes, sometimes overshooting during sharp moves.
AAPL actual vs XGBoost prediction
XGBoost maintains stronger stability and captures overall direction with fewer abrupt swings.

Takeaway: Both models learn non-random structure; XGBoost is more stable, while LightGBM is more responsive (with higher drawdown risk).

Strategy Comparison

Risk-Averse Execution

Higher trade threshold, smaller sizing, tighter drawdown controls.

Risk-Tolerant Execution

Lower threshold, larger exposure, accepts higher volatility for returns.

Validation + Evaluation

Validation uses a walk-forward / time-aware split (train strictly on earlier time, test on later time) with early stopping to reduce overfit.

Forecast quality: MAE / RMSE, cross-validated R², stability across folds

Trading behavior: Sharpe, max drawdown, volatility, hit rate

Key Results

  • Both models showed predictive structure, but XGBoost was more stable.
  • LightGBM: ~12.2% annualized return, Sharpe ~1.36, max drawdown ~25.9%, win rate ~54.5%.
  • XGBoost: ~14.4% annualized return, Sharpe ~1.61, max drawdown ~4.3%, win rate ~54.8%.
  • Practical takeaway: model choice changes behavior (stability vs responsiveness), not just accuracy.

Why It Matters

This project demonstrates time-series ML done the real way: feature engineering without leakage, time-aware validation, and evaluation through risk-adjusted performance rather than a single error number.