What is time-series cross-validation? Why shouldn’t you shuffle the training and test sets when predicting cryptocurrency prices?

In quantitative cryptocurrency trading, machine learning models often need to be trained on historical data before predicting future price movements. But if you randomly shuffle all the data and then split it into training and test sets, as you might for a typical classification task, you could disrupt the time order and make the model’s evaluation results overly optimistic.

First, what is time-series cross-validation?

It is a method of organizing training and validation in chronological order. The model trains on past data and predicts data from a later period. The time window is then moved forward, and training and validation are repeated to observe how the model performs across different market conditions.

Second, why shouldn’t you shuffle the data?

Financial data is time-dependent. Adjacent samples may share the same market context, technical indicator windows, or even overlapping prediction labels. A random split may put information from after the test period into the training set, making the evaluation inconsistent with the chronological order of real-world trading.

Third, how should you split the data?

For example, you could train on data from January through June, validate on July’s data, and then use August’s data for the final test. The actual window lengths should depend on the size of the dataset and the prediction horizon. The final test set should remain independent; don’t keep adjusting the model every time the results are disappointing.

Fourth, what else should you keep in mind?

Steps such as normalization, handling missing values, and feature selection should be fitted using only the data in the current training window. If labels overlap over time, you should also consider using an appropriate gap between the periods. Evaluate performance across different market conditions as well, so the model doesn’t become suited only to bull markets or sideways markets.

Time-series cross-validation cannot guarantee that a model will be profitable in the future, but it can make evaluation more representative of the actual deployment process.

Training must respect chronological order. A truly valuable model doesn’t memorize historical answers; it uses past information to make sound judgments about market conditions that have yet to occur.

Next article: What is feature engineering? How can you extract more valuable trading signals from price, trading volume, and volatility?