A Stock Market Forecasting Model in Peru Using Artificial
Intelligence and Computational Optimization Tools
Miguel Angel Cano Lengua 1(0000-0002-1809-5082)and Mirko Jerber Rodríguez Mallma2(0000-0002-5344-7952) Erik
Alex Papa Quiroz2(0000-0002-8678-6918)
1 Universidad Norbert Wiener and Universidad Nacional Mayor San Marcos,
2Universidad Nacional de Ingeniería, Lima Perú, [email protected]
3Universidad Privada del Norte,Lima, Perú, [email protected]
Abstract. It is proposed the development of a forecast model capable of predicting the behavior of the price indices and quotes of the shares traded on the Lima Stock Exchange, based on the use of artificial intelligence techniques such as Artificial Neural Networks and Diffuse Logic based on computational optimization methods. The proposed model considers the forecast, in addition to the historical quantitative data of the share price, the inclusion of qualitative macroeconomic factors that significantly influence the behavior of the time series of the stock markets. It is about harnessing the ability of Artificial Neural Networks to work with non-linear quantitative data and their capacity for self-learning; and also, take advantage of the Fuzzy Logic technique to simulate the way of reasoning of human beings by defining judgment rules or knowledge base and their evaluation through inference mechanisms.
The main contribution is to demonstrate that the proposed model is capable of obtaining more optimal approximations in the forecast of the financial time series.
Keywords: Artificial Intelligence, Artificial Neural Networks, Difficult Logic, Computational Optimization.
1. Introduction
The study of the stock market is important to make an adequate forecast of the behavior of stock prices and other quantitative characteristics. In Peru, this activity began in 1860 with the creation of the Lima Mercantile Exchange. Currently, because the market does not behave in a linear manner, and in the prediction, it is necessary to include variables from both the Fundamental Analysis and the Technical Analysis, a series of investigations on the application of alternative and multidisciplinary methods have recently been developed in the analysis of financial markets, such as: Chaos Theory, Fractals, Wavelets, Support Vector Machines, Hidden Markov Models, Artificial Intelligence and combinations of these methods, SMITH & GUPTA [9].
Recent research regarding the prediction of the stock market in Peru is as follows: Cáceres [2] using Support Vector Regression, Mejía [4] using Time series, Vegas [10] using Data Mining for High Markets Frequency. However, using the methodology of neural networks and fuzzy logic there are still no referenced works.
qualitative data using the methodology presented; For this reason we believe that it is an important contribution to the advance of the forecast of the stock exchange in Peru.
The content of this article is as follows. In Section 2, we present the proposed model, in Section 3 it deals with the methodology of the selection of micro-economic variables and the indices and indicators of the stock market, in Section 4 the numerical experiments and the main contributions are shown from this study. Finally, in Section 5 we give our conclusions.
2 Proposed Model
In this work, a model based on the sequential hybrid system is used and will be carried out in two parts: The first one corresponds to the definition and development of the Diffuse Logic System for the processing of qualitative values and the second one corresponds to the development and definition of the Artificial Neural Networks Model that will be in charge of the processing of the set of quantitative variables and the result variable that the Diffuse Logic System has previously processed in the first part.
The Diffuse Logic System will carry out a treatment of qualitative variables, through a process of defining business rules, to determine in a more optimal way the influence and implication of qualitative variables in the forecast of time series in a market of values, whose output will be used as one more input in the proposed Neural Networks model.
Figure 2.1 shows the architecture for the implementation of the hybrid model proposed in this research, which is composed of a model of Artificial Neural Networks and a Diffuse Logic System.
Fig. 2.1 Proposed hybrid model.
Source: Own elaboration
2.1 Description of the Proposed Model
The CRISP-DM methodology was used, which is one of the most standardized and accepted when facing Data Mining projects. The design phases are:
• Phase 1: Understanding the business or problem
• Phase 3: Data preparation
• Phase 4: Modeling
• Phase 5: Evaluation
• Phase 6: Implementation.
2.2 Definition of the Proposed Model
In Figure 2.2 we show the unified data of both the qualitative and quantitative variables from
the model.
Fig. 2.2 The input variables of the model (qualitative and quantitative).
Source: Own elaboration.
2.3 Architecture of the Artificial Neural Networks Model
Fig. 2.3 The architecture of an MFNN type network.
Source: [SMITH & GUPTA, 2002]
Each neuron calculates its output based on the number of inputs that it receives. The entries are calculated with a summation function of the value of the elements with their respective assigned weight, while the output is calculated using the sigmoidal function and it depends on the magnitude of the inputs.
2.4 Construction of the Artificial Neural Networks Model.
For the construction of the Artificial Neural Networks model proposed in this research, the methodology proposed by Kaastra and Boyd [3] will be followed for the design of neural network models applied to financial and economic time series predictions, which is composed of eight steps shown in Figure 2.4 and described below.
Fig. 2.4 Methodology for the construction of an RNA model.
3 Variable Selection
3.1 Microeconomic Variables
Various studies have been carried out to determine the influence of macro-economic factors on the behavior of stock prices in the stock market. For our study, 4 macroeconomic input variables have been considered, namely:
• Inflation
• Sector GDP - Mining
• Interest rate
• Exchange rate
3.2 Stock Market Indicators and Indicators
In addition to the macroeconomic variables that significantly influence in the behavior of stock prices in the stock market, it is important to take into account various indices or indicators that allow measuring the behavior and health of the stock market over time, PASTOR, [6 ].
For our study, two of the most important indicators used in the Peruvian stock market were used, namely:
• General Index of the Lima Stock Exchange - IGBVL.
• Selective Index of the Lima Stock Exchange - ISBVL
• Sector Index - IS (Mining and Services)
• National Capitalization Index – INCA
4. Numerical Experiments
In the study period (from January 2001 to December 2010), 2411 historical data have been identified for each of the variables used in the study.
Table 2 Test models and topologies.
Source: Own elaboration.
Test Model
Topology
(p-q-1)
MSE
Iterations
Model 1
7-3-1
0.0740
49
Model 2
7-4-1
0.0441
22
Model 3
7-5-1
0.0544
113
Model4
7-6-1
0.0934
77
Model 5
7-7-1
0.0428
179
Model 6
7-8-1
0.0987
43
Model 7
7-9-1
0.0778
118
Model 8
7-10-1
0.1020
161
Model 9
7-11-1
0.1090
123
Model 10
7-12-1
0.1220
69
Model 11
7-13-1
0.0856
117
Model 12
7-14-1
0.0936
89
Model13
7-15-1
0.1530
61
Model 14
7-18-1
0.2340
56
Model 15
7-20-1
0.7040
95
Data used for the tests
For this study, one of the largest companies in the mining sector in Peru has been chosen: Volcan. Historical information on the price of its shares traded on the Lima Stock Exchange in the period between January 2001 and December 2010 has been considered.
Table 3 Basic Volcano Information
Source: Lima Stock Exchange
BASIC TITLE DATA
Mnemonic VOLCAN
RUC 20383045267
Code VOLCABC1
No. of outstanding shares 1,249,669,371
No. of shareholders 8,841
Nominal value S/. 1.00
Date of Listing in the BVL 31/03/1998
4.1 Results
From the execution of the experiments, it was observed that the best results were obtained with models in which the number of neurons in the hidden layer were less than or equal to the number of neurons in the input layer (7, as observed in the models 2, 3 and 5). The best results were obtained with model 5, followed by models 2 and 3 respectively, which are the models that have the lowest mean square errors MSEs. In general, models with a number of neurons in the hidden layer greater than the number of neurons in the input layer do not show convergence to an optimal solution and, on the contrary, their performance decreases. Similarly, models with a number of neurons in the hidden layer less than or equal to the number of neurons in the input layer do not show a significant difference in the value of the mean square errors, which leads us to state that in general models based on Artificial Neural Networks with a number of neurons in the hidden layer less than or equal to the number of neurons in the input layer achieve a good level of approximation in the calculation of financial series time series forecasts and therefore it helps us to make a forecast of the price of shares in the Stock Market of Peru.
5. Conclusions
This research paper presents a hybrid forecast model applied to the stock market of Peru; using artificial intelligence tools and computational optimization, analyzing the qualitative and quantitative variables. Unlike previous works carried out by Rodríguez & Papa [8] where they present a general model and the thesis of Rodríguez & Valdivia [7] that work with artificial neural networks which only analyzes the quantitative variables. The relevant thing about this work is that there are numerical results that strengthen the exposed model. In this way, an attempt is made to obtain a better performance model that reflects the behavior and fluctuations in the prices of the shares traded in the Peruvian stock market.
References
1. Burton, G. M. (2018). To Random Walk Down Wall Street. (8th ed.), New York, USA: W.W. Norton & Company.
2. Caceres V. (2018) Stock Exchange Price Prediction using Support Vector Regression.
(Pre-degree thesis) University of Lima, Li-ma, Pe-ing.http: //repositorio.ulima.edu.pe/bitstream/handle/ulima/6973/C%C3%A1ceres_Chian_V%C3%A Dctor_Andr%C3% A9s_Edgard.pdf? Sequence = 1 & isAllowed = y
3. Kaastra, I. and Boyd, M. (1996). Designing a neural network for forecasting financial and
economic time series. Neurocomputing Elsevier Science, 10, 215-236.
5. Panchal, G., Ganatra, A. and Kosta, Y. P. (2011). Behavior Analysis of Multilayer Perceptrons with Multiple Hidden Neurons and Hidden Layers. International Journal of Computer Theory and Engineering. 3 (2), 332-337.
6. Pastor, J. (2011). Stock Exchange - Operation and Stock Market Valuation. Lima, Peru:
Corporación Grafimar SAC.
7. Rodriguez M. and Valdivia H. (2012). Stock Price Forecasting Model in the Lima Stock Exchange Based on Artificial Neural Networks. (Pre-degree thesis) National University of Engineering, Lima, Peru.
http://cybertesis.uni.edu.pe/handle/uni/3459
8. Rodriguez M. and Papa E. (2011) Forecast Model of Financial Indicators for the Stock Market,
based on Artificial Neural Networks and Different Logic. III Peruvian Congress of Operations
and Systems Research, COPIOS 2011. Pontifical Catholic University of Peru.
http://congreso.pucp.edu.pe/copios/esp/publicacion.html
9. Smith, K. and Gupta, J. (2014) Neural Networks in Business: Techniques and Appli-cations
Pennsylvania, USA: Idea Group Publishing.
10. Vegas I. (2016) Stock Market Prediction Through Data Mining For High Frequency Market.
(Final Degree Project) Polytechnic University of Madrid, Madrid, Spain.