Abstract
Creating accurate predictions in the stock market has always been a significant challenge in finance. With the rise of machine learning as the next level in the forecasting area, this research paper compares four machine learning models and their accuracy in forecasting three well-known stocks traded in the NYSE in the short term from March 2020 to May 2022. We deploy, develop, and tune XGBoost, Random Forest, Multi-layer Perceptron, and Support Vector Regression models. We report the models that produce the highest accuracies from our evaluation metrics: RMSE, MAPE, MTT, and MPE. Using a training data set of 240 trading days, we find that XGBoost gives the highest accuracy despite running longer (up to 10 seconds). Results from this study may improve by further tuning the individual parameters or introducing more exogenous variables.
Introduction
Predicting stock market movements is a "holy grail" challenge in finance, often complicated by the Efficient Market Hypothesis, which suggests that stock prices already reflect all available information. Traditional forecasting often relies heavily on historical price data (technical analysis) or company-specific financials (fundamental analysis).
This research addresses the gap in short-term forecasting by exploring whether exogenous variables—external economic indicators like interest rates and inflation proxies—can improve the predictive power of machine learning algorithms. By evaluating four machine learning models—XGBoost, Random Forest, Multi-layer Perceptron (MLP), and Support Vector Regression (SVR)—the study seeks to identify the most effective architecture for predicting short-term stock prices for high-growth tech companies during the volatile period between March 2020 and May 2022.
Methodology
The researchers developed a comprehensive pipeline to process market data and generate forecasts. The core of the approach involves comparing ensemble learning methods (XGBoost and Random Forest) against neural networks (MLP) and regression-based models (SVR).
Key technical strategies included:
- Feature Engineering: Categorical features were created to capture seasonality (month, day of week) and intraday patterns (15-minute segments).
- Rolling Window Training: Models were trained using "rolling" datasets of 60 and 240 trading days to simulate real-world adaptation to recent market trends.
- Normalization: Min-Max normalization was applied to ensure diverse variables like gold prices and bond yields were scaled appropriately for the algorithms.
Data Description
The study utilized 15-minute interval data for three major NYSE-traded stocks: Tesla (TSLA), Apple (AAPL), and Nvidia (NVDA). The input features were designed to provide a "macro" view of the economy:
- Market Indices: Dow Jones, S&P 500, and NASDAQ.
- Interest Rates: 2-year, 5-year, and 10-year Treasury bond yields.
- Inflation Proxies: Prices of Gold and Crude Oil.
- Temporal Data: Time-stamps shifted by one period to ensure the model predicts future values based on past exogenous data.
Results and Discussion
The evaluation focused on several metrics: Root Mean Squared Error (RMSE), Mean Absolute Percentage Error (MAPE), Mean Percentage Error (MPE), and Mean Training Time (MTT).
Key Findings:
- XGBoost Superiority: Across almost all tests, XGBoost produced the lowest error rates. For Tesla's 1-day ahead forecast using a 240-day training set, XGBoost achieved a MAPE of approximately 2.39%.
- Training Efficiency: While accurate, Random Forest proved to be the slowest model to train, taking up to 12 seconds. In contrast, XGBoost maintained high accuracy with a training time of approximately 10 seconds for the larger window.
- Volatility and Horizon: Model performance was inversely related to market volatility and the forecasting horizon. Errors spiked during chaotic market periods and increased as the prediction window expanded from 1 to 5 days.
- Feature Importance: The inclusion of bond yields and commodities provided critical context. Interestingly, increasing model complexity (e.g., more trees in XGBoost) yielded diminishing returns, suggesting that feature quality is the primary driver of performance.
Conclusion
This research demonstrates that incorporating exogenous variables into machine learning models significantly enhances short-term stock price forecasting. XGBoost emerged as the most robust model for this task. Future work will look to integrate sentiment analysis from social media and news, expand the stock universe, and include broader economic indicators like unemployment rates to further refine predictive accuracy.
Summary updated