A Deep Learning Method for the Detection and Compensation of Outlier Events in Stock Data
Abstract
:1. Introduction
2. Related Works
2.1. Financial Time Series Data
2.2. Use of Artificial Intelligence in Stock Prediction
2.3. Artificial Neural Networks (ANN)
2.4. Higher-Order Neural Networks (HONN)
2.5. Recurrent Neural Networks (RNN)
2.6. Transfer Learning
2.7. Outlier Events in Stock Data
2.8. Auto-Encoders
2.9. Comparison of Similar Works
3. Materials and Methods
3.1. Proposed Method
3.2. System Diagram of Proposed Method
3.3. Transfer Diagram of Proposed Method
3.4. Data for Outlier Detection
3.5. Approach for Outlier Detection
Algorithm 1 An LSTM auto-encoder |
Require: The closing stock price as of 1985
|
Listing 1: LSTM auto-encoder model |
model = Sequential() #Encoder section model.add(LSTM(128, activation=’relu’, input_shape=(X_train.shape[1], X_train.shape[2]))) model.add(Dropout(rate=0.2)) #Encoded representation model.add(RepeatVector(X_train.shape[1])) #Decoder section model.add(LSTM(128, return_sequences=True)) model.add(Dropout(rate=0.2)) #Output layer model.add(TimeDistributed(Dense(X_train.shape[2]))) #Optimizer and loss function optim = tf.keras.optimizers.SGD(learning_rate=25e-4) model.compile(optimizer=optim, loss=’mse’) model.summary() |
3.6. Anomalies
3.7. Approach Taken for Outlier Compensation
Algorithm 2 A higher order neural network |
Require: The closing stock price as of 1985; the probability of an outlier with magnitude and direction
|
Listing 2: HONN model |
model2 = Sequential() # HONN input layer model2.add(Dense(4, input_dim = 2, activation = ’relu’)) #HONN Hidden layers model2.add(Dense(2, activation = ’relu’)) #HONN output layer model2.add(Dense(1, activation = ’relu’)) #Optimizer and loss function optim = tf.keras.optimizers.SGD(learning_rate = 20e-4) model2.compile(optimizer = optim, loss = ’mse’) model2.summary() |
3.8. Environment
4. Results
4.1. LSTM Auto-Encoder Experiments and Results
4.1.1. Training of the LSTM Auto-Encoder
4.1.2. Output from the LSTM Auto-Encoder
4.2. HONN
4.2.1. Training of the HONN
4.2.2. Output from the HONN
4.2.3. Comparison to State-of-the-Art Methods
5. Discussion
5.1. Summary of Findings
5.2. Implication of Findings
6. Conclusions
Delimitation of Methodology
Author Contributions
Funding
Institutional Review Board Statement
Data Availability Statement
Conflicts of Interest
Abbreviations
ADAM | adaptive moment estimation |
AI | Artificial Intelligence |
ANN | Artificial neural network |
API | Application Programming Interface |
ARIMA | Auto-Regressive Integrated Moving Average |
EMH | Efficient Market Hypothesis |
GPU | Graphics Processing Unit |
GRU | Gated recurrent unit |
HONN | Higher order neural network |
LSTM | Long-short term memory |
NN | Neural network |
NYSE | New York Stock Exchange |
ReLU | Rectified Linear Unit |
SGD | Stochastic gradient descent |
Appendix A
Appendix A.1
Input 1 | Input 2 | Biases | |
---|---|---|---|
Neuron 1 | |||
Neuron 2 | |||
Neuron 3 | |||
Neuron 4 |
Appendix A.2
Neuron 1 | Neuron 2 | Neuron 3 | Neuron 4 | Biases | |
---|---|---|---|---|---|
Neuron 5 | |||||
Neuron 6 |
Appendix A.3
Neuron 5 | Neuron 6 | Biases | |
---|---|---|---|
Output 1 |
Appendix A.4
Appendix A.5
References
- Vijh, M. Stock Closing Price Prediction using Machine Learning Techniques. Procedia Comput. Sci 2020, 167, 599–606. [Google Scholar] [CrossRef]
- Krollner, B.; Vanstone, B.; Finnie, G. Financial Time Series Forecasting with Machine Learning Techniques: A Survey. In Proceedings of the 18th European Symposium on Artificial Neural Networks, Bruges, Belgium, 28–30 April 2010; Available online: https://dblp.org/rec/conf/esann/KrollnerVF10.html (accessed on 15 July 2022).
- Devadoss, A. Stock Prediction Using Artificial Neural Networks. IJDMTA 2013, 2, 283–291. [Google Scholar] [CrossRef]
- Zekic, M. Neural Network Applications in Stock Market Predictions—A Methodology Analysis. MS Thesis, University of Josip Juraj Strossmayer in Osijek, Osijek, Croatia, 1998. [Google Scholar]
- Theodossiou, P. Impact of Outliers on Stock Return Models: Implications for Event Studies and the Pricing of Risk. SSRN 2009. [Google Scholar] [CrossRef]
- Theodossiou, P. Consequences of Outlier Returns for Event Studies: A Methodological Investigation and Treatment. Int. J. Account. 2021, 56, 2150013. [Google Scholar] [CrossRef]
- Bojer, C.S. Understanding machine learning-based forecasting methods: A decomposition framework and research opportunities. Int. J. Forecast. 2022, 38, 1555–1561. [Google Scholar] [CrossRef]
- IBM Education. What Is Machine Learning. Available online: https://www.ibm.com/cloud/learn/machine-learning (accessed on 8 June 2022).
- Balaji, J.A. Applicability of Deep Learning Models for Stock Price Forecasting An Empirical Study on BANKEX Data. Procedia Comput. Sci. 2018, 143, 947–953. [Google Scholar] [CrossRef]
- EBGLaw. Duties and Obligations of a Company and Its Officers and Directors upon Going Public. Available online: https://www.ebglaw.com/insights/duties-and-obligations-of-a-company-and-its-officers-and-directors-upon-going-public/ (accessed on 11 July 2022).
- Mew, M. 5 Reasons Why Stock Prediction Projects Fail. Available online: https://towardsdatascience.com/5-reasons-why-stock-prediction-projects-fail-a3dddf30d242 (accessed on 8 March 2021).
- Bank, D. Autoencoders. arXiv Mach. Learn. 2021, arXiv:2003.05991. [Google Scholar] [CrossRef]
- Ray, R.; Khandelwal, P.; Baranidharan, B. A Survey on Stock Market Prediction using Artificial Intelligence Techniques. In Proceedings of the International Conference on Smart Systems and Inventive Technology, Tirunelveli, Tamil Nadu, India, 13–14 December 2018. [Google Scholar] [CrossRef]
- Soni, V.D. Prediction of Stock Market Values using Artificial Intelligence. Int. J. Adv. Res. Electr. Electron. Instrum. Eng. 2018, 7, 1844–1848. [Google Scholar] [CrossRef]
- Grossi, E. Introduction to artificial neural networks. Eur. J. Gastroenterol. Hepatol. 2007, 19, 1046–1054. [Google Scholar] [CrossRef] [PubMed]
- Fulcher, J. Application of Higher-Order Neural Networks to Financial Time-Series Prediction. In Artificial Neural Networks in Finance and Manufacturing; Kamruzzaman, J., Begg, R., Sarker, R., Eds.; IGI Global: Hershey, PA, USA, 2006; pp. 80–108. [Google Scholar] [CrossRef]
- Gupta, M.M. Fundamentals of Higher Order Neural Networks for Modeling and Simulation. In Artificial Higher Order Neural Networks for Modeling and Simulation; IGI Global: Hershey, PA, USA, 2013; pp. 103–133. [Google Scholar] [CrossRef]
- Olah, C. Understanding LSTM Networks. Available online: https://colah.github.io/posts/2015-08-Understanding-LSTMs/ (accessed on 7 July 2022).
- Kwiatkowski, R. Gradient Descent Algorithm—A Deep Dive. Available online: https://towardsdatascience.com/gradient-descent-algorithm-a-deep-dive-cf04e8115f21 (accessed on 8 June 2022).
- Dey, R.; Salem, F.M. Gate-Variants of Gated Recurrent Unit (GRU) Neural Networks. In Proceedings of the 2017 IEEE 60th International Midwest Symposium on Circuits and Systems (MWSCAS), Boston, MA, USA, 6–9 August 2017. [Google Scholar] [CrossRef] [Green Version]
- Shen, G. Deep Learning with Gated Recurrent Unit Networks for Financial Sequence Predictions. Procedia Comput. Sci 2018, 131, 895–903. [Google Scholar] [CrossRef]
- Roondiwala, M. Predicting stock prices using LSTM. Int. J. Sci. Res. 2017, 6, 1754–1756. Available online: https://www.ijsr.net/archive/v6i4/ART20172755.pdf (accessed on 18 March 2022).
- Zhao, L.; Wang, L. Price Trend Prediction of Stock Market Using Outlier Data Mining Algorithm. In Proceedings of the IEEE Fifth International Conference on Big Data and Cloud Computing, Dalian, China, 28 August 2015. [Google Scholar] [CrossRef]
- Mangalampalli, R. Stock Prediction using Hybrid ARIMA and GRU Models. Int. J. Eng. Res. 2020, 9, 737–743. [Google Scholar] [CrossRef]
- Patel, J. Predicting stock and stock price index movement using Trend Deterministic Data Preparation and machine learning techniques. Expert Syst. Appl. 2015, 42, 259–268. [Google Scholar] [CrossRef]
- Sheikhpour, R. A Survey on semi-supervised feature selection methods. Pattern Recognit. 2017, 64, 141–158. [Google Scholar] [CrossRef]
- Brownlee, J. Feature Selection with Real and Categorical Data. Available online: https://machinelearningmastery.com/feature-selection-with-real-and-categorical-data/ (accessed on 1 April 2021).
- Dancho, M. Tidy Time Series Analysis, Part 4: Lags and Autocorrelation. Available online: https://www.business-science.io/timeseries-analysis/2017/08/30/tidy-timeseries-analysis-pt-4.html (accessed on 3 July 2022).
- Brownlee, J. A Gentle Introduction to Imbalanced Classification. Available online: https://machinelearningmastery.com/what-is-imbalanced-classification/ (accessed on 1 April 2022).
- Wu, Y. 7 Techniques to Handle Imbalanced Data. Available online: https://www.kdnuggets.com/7-techniques-to-handle-imbalanced-data.html/ (accessed on 10 July 2022).
- Sadr, V.A. A flexible framework for anomaly Detection via dimensionality reduction. Neural Comput. Appl. 2021. [Google Scholar] [CrossRef]
- Sharma, S. Epoch vs. Batch Size vs. Iterations. Available online: https://towardsdatascience.com/epoch-vs-iterations-vs-batch-size-4dfb9c7ce9c9 (accessed on 1 October 2022).
- Krithikadatta, J. Normal Distribution. J. Conserv. Dent. 2014, 17, 96. [Google Scholar] [CrossRef] [PubMed]
- Kaur, R. Measuring Accuracy of Stock Price Prediction Using Machine Learning Based Classifiers. IOP Conf. Ser. Mater. Sci. Eng. 2021, 1099, 012049. [Google Scholar] [CrossRef]
- Arroyo, J. Introducing interval time series: Accuracy measures. In Proceedings of the Computational Statistics, Rome, Italy, January 2006; pp. 1139–1146. [Google Scholar]
- Singh, S.; Madan, T.K.; Kumar, J.; Singh, A.K. Stock Market Forecasting using Machine Learning: Today and Tomorrow. In Proceedings of the International Conference on Intelligent Computing, Instrumentation and Control Technologies, Kannur, Kerala, India, 5–6 July 2019; pp. 738–745. [Google Scholar] [CrossRef]
Reference | Merits | Demerits |
---|---|---|
[9] | A high-level analysis of deep learning approaches to stock price prediction. | An empirical study of general methods hampers the optimisation of any single approach. |
[2] | A survey of machine learning techniques comparing the type, time frame and input variables. The study shows the advantages of machine learning in forecasting financial time series. | The survey only seeks to provide a correlation between the machine learning techniques used and their success in forecasting financial time series. |
[21] | This paper experiments on different versions of neural networks to create a benchmark of performance. | The approaches made only allow for a comparison between the experiments done in isolation. |
[3] | The methodology of using a simple multilayered dense model to forecast stock prices is established. | The approach made does not use state-of-the-art methods. |
[16] | This is early research into the applications of different architectures of HONNs for financial time series forecasting. | The performance of the HONNs used is not able to match the modern deep networks. |
[24] | This paper shows a modern method to improve the prediction accuracy of stock markets using a hybrid ARIMA and GRU network. The results are a strong indicator of the approach’s success. | The method made does not handle outliers well and is constrained by the complexity of the source data. |
[22] | The LSTM neural network approach made was found to be very accurate, with a testing root-mean-square error of 0.0859. | The model was not able to react in a timely manner to outliers events. |
[25] | A multivariate application of machine learning using up to ten input variables to determine the direction of the movement of a stock. | The feature engineering approach made does not improve the results sufficiently to ignore the sequential nature of the data. |
[14] | A presentation and analysis of the practicality of predicting stock prices using stock prices. | The approach made sacrifices the accuracy of the prediction for generalisation and practicality. |
[1] | The generalised neural network architecture approach taken shows a strong result for the model’s ability to assimilate different stock trends. | By creating a general model, the accuracy of the prediction was sacrificed. |
[23] | A clustering algorithm is used to determine outliers and improve long-term prediction of stock prices. | The innovation of the work is focused on finding outliers and not improving the prediction using the events detected. |
Layer (Type) | Output Shape | Parameters |
---|---|---|
LSTM 1 | (None, 128) | 66,568 |
Dropout 1 | (None, 128) | 0 |
Repeat Vector | (None, 30, 128) | 0 |
LSTM 2 | (None, 30, 128) | 131,584 |
Dropout 2 | (None, 30, 128) | 0 |
Time Distributed Dense | (None, 30, 1) | 129 |
Date | Events |
---|---|
2008 January | Federal Open Market Committee lowered rates in response to falling home sales rate. |
2008 March | The Fed began bailouts. |
2008 April | The Fed lowered the rate. |
2008 May | The Fed auctioned another USD 150 billion through the Term Auction Facility. |
2008 July | Wall Street’s fears make it more difficult for private companies to raise capital. |
2008 September | Fannie and Freddie bailout. |
2008 September | Lehman Brothers bankruptcy. |
2008 October | Congress passed the USD 700 billion bank bailout bill. Central Banks Coordinate Global Action. |
2008 November | The Fed restructured its aid package. GM, Ford and Chrysler Request Bailouts. |
2008 December | The Treasury inserted USD 105 billion in TARP funds into eight banks in return for preferred stock. |
2009 February | The company slashed its yearly dividend from USD 1.24 to USD 0.82 per share. |
2015 March | GE signed an agreement with the Egyptian government to supply the country with turbines and other technology. |
2015 April | GE Capital said it would sell assets valued at USD 200 billion. |
2015 October | GE Transportation signed a USD 2.6 billion deal to supply 1000 locomotives to India. |
2015 November | A USD 9.5 billion purchase of French transportation company Alstom’s power business was made. |
2016 | Allegations GE misled investors about the underlying profitability of its long-term health care and power units were made. |
2016 January | GE agreed to sell its appliance business to Qingdao Haier for USD 5.4 billion. |
2016 August | GE acquires ShipExpress. |
2016 November | GE Digital acquires ServiceMax. |
2017 January | GE announced it would cut 12,000 jobs. |
2017 November | GE unveiled a broad restructuring and halved its quarterly dividend. |
2017 November/December | GE laid off affected employees. |
2018 January | Flannery announced a previously unforeseen USD 6.2 billion insurance charge. |
2018 June | Removed from Dow Jones Industrial Average. |
2018 October/November | H. Lawrence Culp to replace John Flannery as chair and CEO of the company. Culp moves aggressively to reduce GE’s debt and divest unwanted stakes and subsidiaries. |
2020 March | Announcement that the Aviation unit began laying off 10 percent of its U.S. workforce. |
2020 April | The coronavirus pandemic dealt a USD 1 billion blow to cash flow in its industrial business. |
2020 December | GE agreed to pay a USD 200 million penalty to settle charges for disclosure failures in its power and insurance businesses. |
2021 March | GE announced a deal merging its GE Capital Aviation Services (GECAS) aircraft leasing unit with AerCap Holdings. |
2021 November | GE unveiled a plan to split into three independent public companies. |
2022 April | GE warned fiscal 2022 annual earnings were “trending toward the low end”. |
Layer (Type) | Output Shape | Parameters |
---|---|---|
Dense 1 | (None, 4) | 12 |
Dense 2 | (None, 2) | 10 |
Dense 3 | (None, 1) | 3 |
Layer (Type) | Output Shape | Parameters |
---|---|---|
LSTM 1 | (None, 30, 128) | 66,560 |
Dropout 1 | (None, 30, 128) | 0 |
LSTM 2 | (None, 64) | 49,408 |
Dropout 2 | (None, 64) | 0 |
Dense 1 | (None, 16) | 1040 |
Dropout 3 | (None, 16) | 0 |
Dense 2 | (None, 1) | 17 |
Layer (Type) | Output Shape | Parameters |
---|---|---|
GRU 1 | (None, 30, 50) | 7950 |
Dropout 1 | (None, 30, 50) | 0 |
GRU 2 | (None, 30, 50) | 15,300 |
Dropout 2 | (None, 30, 50) | 0 |
GRU 3 | (None, 30, 50) | 15,300 |
Dropout 3 | (None, 30, 50) | 0 |
GRU 4 | (None, 50) | 15,300 |
Dropout 4 | (None, 50) | 0 |
Dense | (None, 1) | 51 |
Predictor | Mean Absolute Error | Mean Square Error | Mean Absolute Percentage Error | Error Standard Deviation |
---|---|---|---|---|
LSTM | 0.712 | 0.770 | 3.993% | 0.148 |
GRU | 0.717 | 0.779 | 4.331% | 0.144 |
The proposed method | 0.034 | 0.002 | 0.030% | 0.030 |
Data Set | Method | Mean Absolute Percentage Error |
---|---|---|
Chinese securities index 10 | Deep Learning | 0.0002% |
S&P Global | FLIT2FNS | 0.3200% |
S&P 500 | LS-Random Forest | 0.5745% |
S&P 500 | LSTM | 0.7240% |
S&P 500 | Particle Swarm Optimization | 0.6558% |
BSE India | SVM-KNN | 0.1123% |
BSE India | FLIT2FNS | 0.6100% |
BSE India | CEFLANN | 1.8000% |
BSE India | SVR-ANN | 2.6600% |
Goldman Sachs | Regression | 1.4726% |
NYSE | CNN | 5.3100% |
NYSE | Proposed method | 0.0300% |
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |
© 2022 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Naidoo, V.; Du, S. A Deep Learning Method for the Detection and Compensation of Outlier Events in Stock Data. Electronics 2022, 11, 3465. https://doi.org/10.3390/electronics11213465
Naidoo V, Du S. A Deep Learning Method for the Detection and Compensation of Outlier Events in Stock Data. Electronics. 2022; 11(21):3465. https://doi.org/10.3390/electronics11213465
Chicago/Turabian StyleNaidoo, Vashalen, and Shengzhi Du. 2022. "A Deep Learning Method for the Detection and Compensation of Outlier Events in Stock Data" Electronics 11, no. 21: 3465. https://doi.org/10.3390/electronics11213465