Short-Term Stock Price Forecasting using Exogenous Variables and Machine Learning Algorithms

Albert Wong, Steven Euijong Whang, Emilio Sagre, Niha Sachin, Gustavo Rachid Dutra, Yew-Wei Lim, Gaétan Hains, Youry Khmelevsky, Frank Chang ZhangarXiv 2023

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).

The research methodology pipeline, from input data sources to performance evaluation.

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).

Performance metrics for Tesla (TSLA) across different models and training windows.

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

Abstract

Creating accurate predictions in the stock market has always been a great challenge in the finance world but is foundational for a good algorithmic trading system. With the rise of machine learning as the next level of development in the forecasting area, this research paper implements and compares four machine learning algorithms and their accuracy in forecasting three well-known stocks traded in the North American stock market in the short term over the period from March 2020 to May 2022. In addition to the time series of historical stock prices, several exogenous financial and economic variables such as stock market indexes, interest rates, and inflation-related variables are included in the modelling process to mimic their anticipated impact on individual stock prices. We deploy, develop, tune, and evaluate several XGBoost, Random Forest, Multi-layer Perceptron, and Support Vector Regression models and report those that produce the highest level of accuracy from our evaluation metrics: Root Mean Square Error, Mean Average Percent Error, and Mean Positive Error. The evaluation also includes an evaluation of the average training time of these algorithms. Using a training data set of 240 trading days, we find that the XGBoost algorithm gives the highest level of accuracy despite taking longer (up to 10 seconds) to run. Results from this study may improve with the further tuning of the individual parameters of the algorithms and the introduction of other exogenous variables such as company demographics or social sentiment on the stock market.
BibTeX
@misc{wong2023short,
  author = {Albert Wong and Steven Euijong Whang and Emilio Sagre and Niha Sachin and Gustavo Rachid Dutra and Yew-Wei Lim and Gaétan Hains and Youry Khmelevsky and Frank Chang Zhang},
  title = {{Short-Term Stock Price Forecasting using Exogenous Variables and Machine Learning Algorithms}},
  year = {2023},
  eprint = {2309.00618},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2309.00618},
}
Figure