Papers
Topics
Authors
Recent
Gemini 2.5 Flash
Gemini 2.5 Flash
129 tokens/sec
GPT-4o
28 tokens/sec
Gemini 2.5 Pro Pro
42 tokens/sec
o3 Pro
4 tokens/sec
GPT-4.1 Pro
38 tokens/sec
DeepSeek R1 via Azure Pro
28 tokens/sec
2000 character limit reached

An Artificial Neural Network-based Stock Trading System Using Technical Analysis and Big Data Framework (1712.09592v1)

Published 27 Dec 2017 in cs.CE, q-fin.TR, and stat.ML

Abstract: In this paper, a neural network-based stock price prediction and trading system using technical analysis indicators is presented. The model developed first converts the financial time series data into a series of buy-sell-hold trigger signals using the most commonly preferred technical analysis indicators. Then, a Multilayer Perceptron (MLP) artificial neural network (ANN) model is trained in the learning stage on the daily stock prices between 1997 and 2007 for all of the Dow30 stocks. Apache Spark big data framework is used in the training stage. The trained model is then tested with data from 2007 to 2017. The results indicate that by choosing the most appropriate technical indicators, the neural network model can achieve comparable results against the Buy and Hold strategy in most of the cases. Furthermore, fine tuning the technical indicators and/or optimization strategy can enhance the overall trading performance.

Citations (63)

Summary

  • The paper introduces a trading system that uses an ANN to predict trading signals rather than future prices.
  • It employs technical indicators like RSI, MACD, and Williams %R with data resampling to address class imbalance.
  • The system’s performance is validated through a realistic trading simulation comparing its results to a Buy and Hold strategy.

This paper presents a stock trading system that uses an Artificial Neural Network (ANN) based on technical analysis indicators and leverages the Apache Spark big data framework. The core idea is to predict stock trading signals (Buy, Sell, Hold) rather than directly predicting future prices, and then execute trades based on these signals.

The system operates in several key phases:

  1. Data Acquisition and Preprocessing:
    • Daily stock price data (Open, Close, High, Low, Adjusted Close, Volume) is obtained for Dow 30 stocks.
    • Adjustments are made to prices based on the Adjusted Close ratio to account for splits, dividends, etc.
  2. Data Labeling:
    • Instead of predicting price, the system aims to predict trading signals.
    • Daily closing prices are labeled automatically as "Buy", "Sell", or "Hold" by identifying peak and valley points within a specified window. Peak points are labeled "Sell", valley points "Buy", and others "Hold".
  3. Feature Engineering:
    • Technical analysis indicators are calculated for each day's data. The paper focuses on three widely used indicators:
      • Relative Strength Index (RSI): A momentum indicator comparing the magnitude of recent gains and losses.
      • Moving Average Convergence and Divergence (MACD): An indicator showing the relationship between two exponential moving averages.
      • Williams %R: A momentum indicator showing overbought or oversold conditions.
    • The TA4J library is used for calculating these indicators.
    • The calculated indicator values, along with the corresponding label and close price, are normalized.
  4. Handling Data Imbalance:
    • Stock data typically has significantly more "Hold" labels than "Buy" or "Sell".
    • To address this class imbalance, the minority classes ("Buy" and "Sell") are oversampled by creating multiple copies of their data points in the training set, aiming for an approximately equal distribution across the three classes.
  5. Model Training:
    • A Multilayer Perceptron (MLP) is used as the prediction model.
    • Apache Spark's MLlib library is utilized for implementing and training the MLP, enabling processing of the potentially large dataset.
    • The MLP architecture consists of four layers: 4 input nodes (for the features), two hidden layers with 5 and 4 nodes respectively, and an output layer with 3 nodes (corresponding to Buy, Sell, Hold classes).
    • The model is trained on historical data (1997-2006 for Dow 30 stocks) for 200 epochs.
  6. Model Testing and Evaluation:
    • The trained model is tested on a separate period of data (2007-2017).
    • Evaluation metrics include prediction accuracy (demonstrated with a confusion matrix and precision/recall/F1 scores for a sample stock like WMT).
    • Crucially, the system's performance is evaluated as a trading strategy. A simulation is run using the predicted signals.
    • The trading strategy: Buy on a "Buy" signal (using all available capital), Sell on a "Sell" signal (move to all cash), and Hold on a "Hold" signal. Repeated signals are ignored until the label changes.
    • A realistic trading environment is simulated, including a commission fee per transaction (\$1) and a stop-loss mechanism (5% loss).</li> <li> The system&#39;s performance is compared against a simple Buy and Hold (BaH) strategy over the same test period, starting with an initial capital (\$10,000). Metrics like total capital, annualized return, annualized number of transactions, success percentage of transactions, average profit/loss per transaction, average transaction length, and maximum profit/loss per transaction are tracked.

Implementation Notes and Practicalities:

  • The use of Apache Spark MLlib is a key practical aspect for handling potentially large volumes of historical data efficiently during the training phase.
  • The reliance on standard, widely accepted technical indicators (RSI, MACD, Williams %R) simplifies feature extraction but might limit performance compared to using optimized or more sophisticated indicators.
  • The automated labeling process based on peak/valley identification is a practical way to generate training labels from price data without manual intervention, though the definition of "peak" and "valley" within a window needs careful consideration (Figure 1).
  • Explicitly addressing the class imbalance problem through resampling is crucial for training a classifier to predict minority classes like "Buy" and "Sell" effectively, as these are the signals that drive trading actions.
  • The trading simulation includes realistic aspects like commission and stop-loss, providing a more grounded evaluation than just prediction accuracy.

Results and Limitations:

The evaluation on Dow 30 stocks showed mixed results compared to Buy and Hold over the 2007-2017 period. The proposed strategy achieved an average annualized return of 10.3%, while Buy and Hold achieved 13.83%. The system outperformed Buy and Hold for 9 out of 29 stocks tested. The average transaction success rate was 67.33%.

The authors acknowledge that using standard, non-optimized technical indicator parameters across all stocks is a limitation. Performance could likely be improved by fine-tuning these parameters or employing optimization techniques specific to each stock or market condition. Future work includes adding optimization stages and exploring deep learning models.