← All experiments

Experiment 002 · Machine learning

Can XGBoost Predict Tomorrow?

Four possible directions, fourteen signals, ten stocks, and one deliberately skeptical test of whether yesterday contains a useful hint about the next trading day.

Frozen data snapshot through loading…

Held-out results

How much signal did it find?

The model never sees these final dates during training. Higher is better, but modest scores are the honest expectation for noisy daily markets.

Exact four-way categoryDirection onlyFour-way chance: 25%

the short version

Findings and Next Steps

What worked

A faint four-class signal

Exact accuracy reached 29.04%, just above the 28.60% majority-class baseline. Balanced accuracy was 29.22%, so the result was not driven only by the most common label.

What fell short

Direction stayed near chance

Up-or-down accuracy was 50.24%. The model found too little dependable information to support a useful claim about predicting tomorrow, especially before trading costs.

What I learned

More detail is not always more signal

XGBoost can detect small nonlinear patterns, but familiar technical indicators mostly summarize the same noisy price history. A complex model cannot manufacture information that is not there.

What I would try next

  • Repeat the evaluation with rolling walk-forward retraining across several market regimes.
  • Compare against simpler logistic and persistence models.
  • Test whether acting only on high-confidence predictions improves results after costs.

first, define the question

Four ways tomorrow can go

Rather than guess an exact price, the model classifies the next adjusted-close return. There is no universal industry standard for these labels, so this experiment uses a simple symmetric 1% boundary that is easy to interpret and keeps “direction” separate from “magnitude.”

Very negativebelow −1%
Negative−1% to 0%
Positive0% to +1%
Very positive+1% or more

Where it succeeds and slips

Read the mistakes, not just the score

Balanced accuracy gives each class equal weight. The confusion matrix shows which classes the model tends to confuse.

Confusion matrix

Rows are what happened; columns are what the model predicted.

Accuracy by stock

Exact four-way accuracy and simpler up-or-down accuracy.

Fourteen clues

What the model actually reads

A compact set spanning momentum, trend, volatility, volume, and market context. Importance is measured on held-out data by shuffling one signal at a time.

01

Momentum

Returns over 1, 5, 21, and 63 trading days, plus 14-day RSI and relative strength against the S&P 500.

02

Trend

Distance from 20- and 50-day moving averages and the gap between 12- and 26-day exponential averages.

03

Risk + participation

Recent volatility, drawdown, average true range, unusual volume, and the market’s own weekly return.

xgboost in a nutshell

A committee that learns from its misses

XGBoost builds many shallow decision trees in sequence. Each new tree focuses on patterns the earlier trees handled poorly; their weighted votes become probabilities for the four return classes. Here, 260 depth-three trees keep each individual rule modest.

prediction
Fk(x)=m=1260η·fm,k(x) P(y=k|x)=eFk(x)j=14eFj(x)

Each tree adds a small class-specific correction, scaled by learning rate η = 0.04. Softmax turns the four accumulated scores into probabilities.

the honest setup

How the test works

  1. 01

    Pool the ten stocks

    Each stock-day becomes one example. Stock identity is included, while the same signal definitions apply to every company.

  2. 02

    Split forward in time

    The earliest 80% of dates train the model; the newest 20% form one untouched chronological test. Dates are never shuffled.

  3. 03

    Balance the classes

    Training examples are weighted so rare large moves matter. The headline balanced accuracy is the mean recall across all four labels.

  4. 04

    Fit exactly once

    The frozen model is fitted once on training rows and applied once to the held-out period. There is no refit, daily forecast, or automated data refresh.

Notes & sources

The signal families follow commonly used technical-analysis concepts described by Fidelity’s technical-analysis guide ↗. Model implementation uses XGBoost’s scikit-learn classifier ↗. The evaluation follows scikit-learn guidance on preventing data leakage ↗, balanced accuracy ↗, and held-out permutation importance ↗.