Stock Price Prediction: Evaluation Pitfalls and Honest Experimental Design
Low price errors and high R² scores can make stock prediction models look more useful than they are. This article examines an experiment in which four deep learning models failed to beat a no-change baseline, explains why price-level metrics can mislead, and outlines a more credible evaluation process using directional accuracy, significance testing, rolling validation, and trading costs.
1. The Main Takeaways
If you take away only three points, make them these:
- MAPE and R² calculated on price levels reveal very little on their own. Stock prices often behave approximately like random walks, with substantial variation driven by trends. An R² close to 1 can reflect the structure of the series rather than predictive skill.
- Every stock prediction model must compete against “tomorrow’s price equals today’s price.” A model that cannot beat this naive baseline has not demonstrated useful improvements. In the experiment discussed here, all four deep learning models lost to it.
- Directional accuracy deserves attention, but it requires significance testing. The best model achieved 52.8% on 396 observations—only about 1.1 standard deviations above 50%. That result is not statistically significant and does not establish predictive ability.
The following sections explain the experiment, the evaluation traps, and the reasoning behind these conclusions.
2. An Experimental Design That Looks Sound
The experiment used the following setup:
- Asset: A Hong Kong-listed smart hardware company, referred to here as Asset A, which went public in July 2018. The dataset covered its available trading history.
- Dataset size: Approximately 2,029 trading days.
- Split: 1,420 training days, 203 validation days, and 406 test days, in strictly chronological order, with no shuffling.
- Prediction task: Use the previous 60 trading days, each with 10 technical features, to predict daily log returns for the next 10 trading days.
- Features: All were ratios or standardized quantities, including daily returns; price deviations from 5-, 10-, and 20-day moving averages; normalized momentum indicators; indicator histogram values divided by price; position within a range, scaled from 0 to 1; 10-day rolling volatility; and cumulative returns over 5 and 20 days.
- Model families:
- A three-layer one-dimensional convolutional network with global average pooling.
- A two-layer recurrent network with a hidden dimension of 64.
- A convolutional feature extractor followed by a recurrent network.
- A Transformer variant that divides the sequence into patches and uses self-attention to model long-range dependencies.
Why the Split Must Be Stated Up Front
The split is the foundation of the experiment’s credibility. Shuffling time-series observations can allow future information to enter the training process, producing implausibly good test results.
Many tutorials claiming “99% accuracy” in stock prediction suffer from this problem. Another common source of leakage is computing normalization statistics across the full dataset before splitting it.
One detail also matters for interpreting the results: prices in the test period ranged from 21 to 60, compared with 8.35 to 35.30 in training. The test period therefore showed a substantial distribution shift and included prices beyond the training range.
3. Why a 2% MAPE Can Be Misleading
Let the actual price be (P_t), and let the naive prediction be:
[
\hat{P}t = P{t-1}
]
Its relative error is:
[
\frac{|\hat{P}_t-P_t|}{P_t}
=
\frac{|r_t|}{1+r_t}
\approx |r_t|
]
where (r_t) is the daily simple return.
The naive baseline’s MAPE is therefore approximately the mean absolute daily return. Asset A’s daily volatility was on the order of 2%–3%. A model reporting a MAPE of 2.1% may simply be reproducing the scale of day-to-day price noise rather than reducing forecast error.
The R² Illusion
By definition:
[
R^2
=
1-
\frac{\sum_t(P_t-\hat{P}_t)^2}
{\sum_t(P_t-\bar{P})^2}
]
For the no-change forecast, the numerator captures one-step price changes. The denominator measures price deviations from the sample mean and can be dominated by the much larger movement of the price level over time.
In a random-walk-like series, the denominator can grow much faster than the accumulated one-step forecast errors. The ratio becomes small, pushing R² toward 1.
A strongly trending series can therefore give “tomorrow equals today” an R² of 0.99 without any sophisticated model. A high score is not, by itself, evidence of forecasting skill.
The four models in this experiment predicted daily log returns for a 10-day horizon. Reconstructing price paths from those predictions made the price-level metrics look even more favorable: the broad movement of prices could overshadow forecast errors without adding evidence of predictive value.
4. Why the Naive Baseline Is Hard to Beat
Under a random-walk assumption, the optimal one-step price forecast is the current price. To outperform it, a model must extract genuinely useful information rather than merely reproduce the current level.
Several practical obstacles make this difficult:
- The predictable component of closing-price data has a very low signal-to-noise ratio. Return autocorrelation is close to zero.
- Technical features are highly collinear. Ten features may contain only two or three largely independent sources of information.
- Deep learning capacity can greatly exceed signal strength. Models can easily learn noise in the training period as though it were a stable pattern.
- Distribution shift weakens generalization. The test-period price range extended well beyond the training range, making extrapolation a concern.
The experiment reflected these difficulties: the naive baseline outperformed all four models on MAE, RMSE, and R².
5. What Honest Evaluation Looks Like
5.1 Make Directional Accuracy a Primary Metric
Instead of relying on price-level fit, evaluate whether predicted returns have the correct sign:
import numpy as npdef direction_accuracy(y_true, y_pred):# y contains returns; compare only their signsreturn float(np.mean(np.sign(y_true) == np.sign(y_pred)))
This measures whether the model gets the direction right, rather than whether its reconstructed price path stays near a trending series.
5.2 Test Whether Directional Accuracy Is Significant
Use a chance-level null hypothesis:
[
p_0 = 0.5
]
A normal-approximation test can be implemented as follows:
from math import sqrt, erfdef z_test(p_hat, n, p0=0.5):se = sqrt(p0 * (1 - p0) / n)z = (p_hat - p0) / se# Two-sided p-value using the error-function form of the normal CDFp_value = 2 * (1 - 0.5 * (1 + erf(abs(z) / sqrt(2))))return z, p_valueprint(z_test(0.528, 396)) # z ≈ 1.11, well below 1.96
An accuracy of 52.8% over 396 observations is only about 1.1 standard deviations above 50%. It is not statistically significant.
Establishing that a 52.8% accuracy rate differs from chance at the 5% significance level requires substantially more observations—not simply adding three more layers to the model.
5.3 Correct for Multiple Comparisons
Four model families combined with several hyperparameter configurations can amount to dozens of tests.
Without Bonferroni correction or a similar error-rate control, an apparently significant result from the “best” configuration may be a product of data mining.
Report the distribution of results across all configurations, not just the winner.
5.4 Replace a Single Split with Rolling, Purged Validation
A single 70/10/20 split can produce conclusions that depend heavily on the chosen period.
A more robust approach uses rolling time-series evaluation. Remove training observations near the boundary whose future labels overlap the validation period—a process known as purging—to reduce label leakage.
The following split generator leaves a gap before each evaluation block:
def rolling_splits(n, n_splits=5, test_size=200, embargo=10):for k in range(n_splits):end = n - (n_splits - 1 - k) * test_sizetrain_end = end - test_size - embargoyield (0, train_end), (train_end + embargo, end)
The essential requirement is to keep overlapping future labels from connecting the training and evaluation periods.
5.5 Translate Predictions into Trading Performance
Convert directional predictions into strategy returns, then deduct:
- Transaction costs on both entry and exit.
- Slippage.
- Market impact costs.
Only then evaluate the Sharpe ratio and maximum drawdown.
If a strategy is unprofitable after costs, high directional accuracy remains a paper result rather than evidence of a useful trading system.
Use a block bootstrap to estimate confidence intervals for the return series. Daily returns are not necessarily independent, and an ordinary bootstrap that ignores temporal dependence can underestimate uncertainty.
6. A Complete Evaluation Checklist
- Define the target clearly. Are you predicting price levels, returns, direction, or volatility? Price-level regression is particularly prone to misleading fit metrics.
- Split before preprocessing. Divide the data chronologically, then fit all normalization statistics using only the training period.
- Require simple baselines. Include a no-change forecast, a historical-mean baseline, and a simple linear-trend baseline.
- Use a combination of metrics. Treat MAE and RMSE as supporting measures. Prioritize after-cost returns and directional accuracy.
- Test significance. Use a binomial test or permutation test, with correction for multiple comparisons.
- Check robustness. Use rolling validation with an embargo, and report all configurations rather than only the best one.
- Inspect distribution drift. Explicitly compare training and test feature distributions, as well as their price ranges.
- Make the experiment reproducible. Fix random seeds and record data versions, feature versions, and split definitions.
7. Engineering the Evaluation Workflow
These practices can be implemented with general-purpose cloud infrastructure:
- Object storage for versioned market-data snapshots and feature tables.
- Message queues to decouple data ingestion from feature computation.
- Container platforms for training and backtesting jobs with consistent environments.
- Logging, monitoring, and alerts to track missing data, shifts across evaluation periods, and metric degradation.
The critical principle is to treat data version, split definition, and metric specification as first-class records.
Without them, a team may be unable to explain six months later how a reported score was produced.
8. Conclusion
The most valuable output of this experiment was not a neural network. It was the one-line baseline.
That baseline exposed a hidden assumption: on strongly trending, low-signal series, goodness-of-fit metrics can reward a forecast that does little more than carry today’s price forward.
The hardest part of stock price modeling is therefore not choosing a network architecture. It is designing an evaluation that honestly distinguishes predictive information from the structure of the data.
Build a credible baseline before building a larger model. Test statistical significance before making claims about predictive skill. And evaluate performance after trading costs before treating that skill as an economic advantage.
