What this article does and does not do
This is a conceptual description of how a machine learning model is trained and tested on market data. It does not provide a working predictor, a recommended model or any forecast. Whether such a model can predict prices reliably is doubtful, and the article on the limits of machine learning explains why. The aim here is to show the process so that claims about it can be understood and questioned. Nothing here is financial advice.
Step 1: define the question
Everything starts with the target, the quantity the model is asked to estimate. Common choices include:
- the price change over the next hour or day (a number, so a regression problem);
- whether the price goes up or down over that period (a yes or no label, so a classification problem);
- the size of price swings over the next period, which is a risk question.
The choice matters. Predicting the exact price level is usually misleading, because today’s price is already an excellent guess for tomorrow’s level, so a model can look accurate while adding nothing. Predicting the change is a harder and more honest test.
Step 2: gather inputs
The inputs, called features, are numbers computed from data available at each moment. Examples include recent returns, trading volume, measures of volatility, derivative statistics such as funding rate, indicators from technical analysis, and counts from the blockchain. Features must be built only from information that would have been known at that time. If a feature at noon uses a value that was published at midnight, the model is cheating without anyone noticing.
Data quality needs attention. Prices differ between exchanges, volumes may be inflated on some venues, and there can be gaps and errors. The way an aggregator combines venues, described in the discussion of price aggregation, affects what the model actually sees.
Step 3: split the data by time
To find out whether a model learned something real, it must be tested on data it has not seen. In most machine learning tasks the data is shuffled randomly into training and test sets. For prices that is a serious mistake, because neighbouring days resemble one another, and shuffling lets the model learn about a day from its neighbours on both sides.
The usual approach is to split by time:
- a training period, used to fit the model;
- a validation period, used to compare settings and choose between models;
- a test period at the end, used once, to estimate how the final choice might perform.
A stronger version is walk-forward testing. The model is fitted on an initial window, scored on the next block, then the window rolls forward and the process repeats, imitating what would have happened in real time.
Step 4: train
Training means adjusting the model’s internal parameters to reduce a measure of error on the training data. For a simple linear model this is a matter of fitting weights. For a neural network it is done through many small iterative adjustments. The model type is a choice in itself, covered in the article on learning algorithms.
Training is where overfitting arises. A flexible model can reduce training error almost to zero by memorising quirks, including pure noise, and then do poorly on new data. Common countermeasures include limiting model complexity, penalising large weights, stopping training early, and using fewer, more meaningful features.
Step 5: validate honestly
Validation compares the model against reasonable baselines. A simple one is to predict no change. Another is to predict that the next change equals the last one. A model needs to beat these by a meaningful margin on data it never saw, not just by a hair.
Useful practices include:
- Report several measures of error, not just one.
- Look at performance in different market conditions, such as rising, falling and sideways stretches, and not only the average.
- Count the number of things tried. If a hundred model variants were tested on the same data, the best of them is likely flattered by luck.
- Include trading costs, such as fees and the bid-ask spread, if the output would be used for decisions.
Common ways the process goes wrong
- Leakage: future information sneaking into features or into scaling steps, such as normalising the whole dataset at once.
- Look-ahead in labels: using a rule that depends on data after the decision point.
- Reusing the test set: each time you peek and adjust, the test result becomes less trustworthy.
- Ignoring regime change: a model fitted on one kind of market may fail in another, since the structure of crypto markets keeps changing.
- Mistaking a good chart for a good model: a line of predictions closely following the price often just reflects that the model copies the latest value.
What to take from this
Training a model is fairly easy with modern software. Validating it honestly is the hard part, and it is where most claimed results fail. Cryptocurrency prices are volatile, past performance does not predict future results, and people can lose everything they invest. Treat any model, however carefully built, as an experiment in understanding data, not as a source of dependable forecasts.