Source-linked AI summary

Forecasting directional movements of stock prices for intraday trading using LSTM and random forests

Pushpendu Ghosh, Ariel Neufeld, Jajati Keshari Sahoo

arXiv:2004.10178v2cs.LGq-fin.STstat.ML

TL;DR

The paper examines machine-learning methods for financial time-series prediction, comparing random forests and LSTM networks with a multi-feature setting. The multi-feature setting outperforms single-feature benchmarks for both methods, with higher reported daily returns before transaction costs.

  • Problem

    The paper examines machine-learning methods for financial time-series prediction and their effectiveness for forecasting stock-price movements.

  • Method

    The study introduces a multi-feature setting using closing-price returns, opening-price returns, and intraday returns, alongside random forests and LSTM networks.

  • Results

    0.64% daily return with LSTM and 0.54% with random forests outperform single-feature benchmarks of 0.41% and 0.39%, respectively, before transaction costs.

  • Takeaways & Limitations

    The multi-feature setting outperforms the single-feature settings of Krauss et al. (2017) and Fischer & Krauss (2018) for both random forests and LSTM.

  • Takeaways & Limitations

    The trading evaluation applies a 0.05% slippage cost on each half-turn.

Abstract

from arXiv · show

We employ both random forests and LSTM networks (more precisely CuDNNLSTM) as training methodologies to analyze their effectiveness in forecasting out-of-sample directional movements of constituent stocks of the S&P 500 from January 1993 till December 2018 for intraday trading. We introduce a multi-feature setting consisting not only of the returns with respect to the closing prices, but also with respect to the opening prices and intraday returns. As trading strategy, we use Krauss et al. (2017) and Fischer & Krauss (2018) as benchmark. On each trading day, we buy the 10 stocks with the highest probability and sell short the 10 stocks with the lowest probability to outperform the market in terms of intraday returns -- all with equal monetary weight. Our empirical results show that the multi-feature setting provides a daily return, prior to transaction costs, of 0.64% using LSTM networks, and 0.54% using random forests. Hence we outperform the single-feature setting in Fischer & Krauss (2018) and Krauss et al. (2017) consisting only of the daily returns with respect to the closing prices, having corresponding daily returns of 0.41% and of 0.39% with respect to LSTM and random forests, respectively.

1. Introduction

The paper applies random forests and LSTM networks to forecast stock-price direction for intraday trading, extending prior single-feature benchmark strategies with opening-price and intraday-return features. Its multi-feature setting produces higher reported daily returns than the benchmark settings for both methods.

  • Research focus: The study forecasts each S&P 500 stock’s probability of outperforming the market in intraday returns using random forests and LSTM networks.The prediction is made at the beginning of each day using a multi-feature setting.
  • Contribution: The multi-feature setting adds opening-price returns and intraday returns to closing-price returns.This contrasts with the benchmark single-feature setting based only on daily closing-price returns.
  • Results: 0.64% daily return is obtained with LSTM networks and 0.54% with random forests, prior to transaction costs.These results are reported for the multi-feature setting.
  • Results: The multi-feature results exceed the benchmark daily returns of 0.41% for LSTM and 0.39% for random forests.The cited benchmarks correspond to the single-feature settings in Fischer & Krauss (2018) and Krauss et al. (2017), respectively.

2. Data and technology

The study uses Bloomberg price data for S&P 500 constituent stocks from January 1990 through December 2018, excluding zero-volume stocks from trading. Experiments use Python-based machine-learning implementations alongside MATLAB for visualization and statistical calculations.

  • Data: Stocks with zero volume on a given day are excluded from trading.This condition is applied daily.
  • Technology: The experiments run on an NVIDIA Tesla V100 with 30 GB of memory.The implementation uses Python 3.6.5, TensorFlow 1.14.0, and scikit-learn 0.20.4.
  • Technology: MATLAB R2016b is used to produce visualizations and calculate statistical values.

3. Methodology

The methodology divides the data into training and out-of-sample trading periods, constructs features and targets, trains random forests and CuDNNLSTM networks, and applies a trading strategy.

  • Methodology: The raw data are divided into study periods, each containing an in-sample training part and an out-of-sample trading part.
  • Methodology: The procedure introduces features and targets before defining the machine-learning setup.
  • Methodology: Random forest and CuDNNLSTM are the two training methods used.
  • Methodology: A trading strategy is established for the trading part after model training.

3.1. Dataset creation with non-overlapping testing period

The dataset is organized into rolling four-year study periods with one-year strides, separating approximately three years of training from one year of trading. This produces 26 study periods with non-overlapping trading parts.

  • Dataset creation: The procedure uses a four-year window and one-year stride over data from January 1990 through December 2018.
  • Dataset creation: Each study period contains approximately 756 training days and 252 trading days.These correspond to approximately three years of training and one year of trading.
  • Dataset creation: 26 study periods are obtained with non-overlapping trading parts.

3.2. Features selection

The paper constructs stock-level features from historical opening and closing prices, then adds opening-price and intraday-return features for LSTM sequences. Random forests use 93 features, while LSTMs use 240 timesteps with 3 features and a chronological train-test split.

  • The prediction task uses historical opening prices, prior closing prices, and the prediction day’s opening price while excluding its closing price.
  • The model predicts the k stocks with the highest and lowest intraday returns among n stocks.
  • Random forest: Random-forest features include returns relative to closing prices and opening prices, producing 93 features across selected lags and multi-period horizons.
  • Random forest: The random-forest features are not transformed through scaling or centering.
  • LSTM: LSTM inputs contain 240 timesteps and 3 features, trained to predict the direction of the 241st intraday return.
  • LSTM: LSTM features are standardized with Robust Scaler, which subtracts the median and scales by the inter-quantile range.
  • Train-test split: After removing the first 240 incomplete rows, data are split chronologically into training and testing periods, with approximately 516 and 252 instances per stock.

3.3. Target selection

Stocks are assigned to two equal-sized classes according to whether their intraday returns fall below or above the cross-sectional median at each time.

  • Stocks are divided into two classes of equal size using their intraday returns.
  • Class 0 applies when a stock’s intraday return is smaller than the cross-sectional median intraday return.
  • Class 1 applies when a stock’s intraday return is above the cross-sectional median intraday return.

3.4. Model training specification

The study trains random forests and CuDNNLSTM networks using benchmark-aligned specifications, with GPU acceleration for the LSTM experiments.

  • Random forests are used as a training methodology alongside LSTM networks for the forecasting task.
  • The study follows prior benchmark work for methodological details and comparison.
  • LSTM: CuDNNLSTMs are used because LSTM training is time-consuming and GPU acceleration provides speedups of up to 7.2x.
  • LSTM: The LSTM architecture contains 25 CuDNNLSTM cells, dropout of 0.1, and a dense layer with 2 softmax outputs.
  • LSTM: The LSTM uses categorical cross-entropy, RMSProp with learning rate 0.001, and early stopping after 10 validation-loss epochs without improvement.

3.5. Prediction and trading methodology

The methodology forecasts each stock’s probability of outperforming the median intraday return, then forms equal-weighted long and short portfolios from the highest- and lowest-probability stocks.

  • The model forecasts the probability P(s) for each stock to outperform the median intraday return.
  • The strategy follows prior benchmarks by going long the 10 stocks with the highest forecast probabilities.
  • It applies equal monetary weighting across the long and short positions.
  • Each transaction incurs a 0.05% slippage cost on each half-turn.
  • Forests with maximum depth 10 achieved the highest accuracy in hyperparameter tuning, while tested LSTM cell counts and architectures had only marginal effects.

4. Results and Discussion

The multi-feature IntraDay setting, using closing prices, opening prices, and intraday returns, outperforms the single-feature benchmark across models and analyzed sub-periods. LSTM delivers the strongest reported returns and risk metrics, while the three-feature design improves performance across evaluated measures.

  • The setting combines closing-price returns with opening-price returns and intraday returns, rather than using a single feature.
  • 0.64% daily return before transaction costs is achieved by the multi-feature LSTM setting, versus 0.41% for Fischer & Krauss (2018).
  • 0.54% daily return before transaction costs is achieved by the multi-feature random-forest setting, versus 0.39% for Krauss et al. (2017).
  • The multi-feature setting also yields lower maximum drawdown and daily VaR, while LSTM outperforms random forests.The authors additionally report higher Sharpe ratios and lower standard deviations than the benchmark settings.
  • The multi-feature setting outperforms the benchmark setting in each of the three analyzed time periods.The periods span January 1993 through December 2018 and correspond broadly to strong performance, moderation, and deterioration.
  • The three-feature design produces massive improvement in all reported metrics compared with using intraday returns alone.
Loading 2004.10178v2…