Soft Computing Analysis for Stock Price Dynamism Using Gaussian Membership Function: A Case Study of Nigerian Stock Exchange

Abstract

Stock Prices are dynamic and vulnerable to quick changes because of the fundamental nature of the financial field and in part because of the mix of known parameters (Previous Days Closing Price, High Price, etc.) and unknown factors (like Election Results, Rumors, etc.). Its prediction is generally regarded to be a very arduous task as the process is time-varying, thus, creating uncertainty as its characteristic nature. Uncertainty results from the limited capability to resolve details and encompass the notions of partial, vague, noisy and incomplete information about the real world. Soft Computing techniques operate in an environment that is subject to uncertainty and imprecision with the aid of Fuzzy logic that aims at formalization of approximate reasoning. Gaussian fuzzy membership function was employed to capture the stock dynamism by the function’s smoothness at its edges. The system was simulated using MATLAB. 256 production rules of the technical indicators and 16 of the external factors were generated. The simulated system gave a good insight into stock market for investors to know at what point in time is best to buy and sell stocks as well as make a good profit or loss.

Share and Cite:

Mbeledogu, N. , Ugoh, D. , Paul, R. and Mbeledogu, K. (2024) Soft Computing Analysis for Stock Price Dynamism Using Gaussian Membership Function: A Case Study of Nigerian Stock Exchange. Open Access Library Journal, 11, 1-18. doi: 10.4236/oalib.1111519.

1. Introduction

Indicators are statistics used to measure current conditions as well as forecast financial or economic trends. The need of stock price indicators cannot be overemphasized as they ease the investors’ problem in seeking for profitable stocks to invest in. Closing Price is an indicator in stock that gives the latest up-to-date valuation of a security before the next trading day. It is of great importance to investors, financial institutions, regulators and other stakeholders because it shows how well or poorly a stock performed over a period of time. In fact, investors and other stakeholders base their decisions on closing stock prices [1] .

Whatever stock price one considers to predict, they are very dynamic and vulnerable to quick changes because of the fundamental nature of the financial field and in part because of the mix of known parameters (Previous Days Closing Price, High Price, etc.) and unknown factors (like Election Results, Rumors, etc.). Its prediction is generally regarded to be very arduous as the process is time-varying, thus, creating uncertainty as its characteristic nature.

Our minimal ability to use Hard Computing (HC) technique that is based on deterministic (well-defined mathematical solutions) and precise computations will be inefficient in handling the unimaginable characteristics of the real-world conception of partial, vague, noisy and incomplete information combined with the problems under study as the nature of the system is not fully known.

The aim of Soft Computing (SC) is to develop intelligent machines that solve nonlinear and mathematically un-modeled system problems [2] . This nature of computing is notably acceptable to imprecision and uncertainty, thus, presenting the approach as an efficient technique to those delving into “noisy” terrain. Its method of reasoning is approximate rather than exact in order to model and analyze very complex problems, and so termed “inexact” computing techniques [3] . It is employed to actualize tractability, robustness, and tolerance of imprecision, uncertainty, partial truth, and approximation.

The ability of SC to cope with uncertainty and imprecision involves words and perceptions as one of its principle components, and it is motivated by the human capability to perform a wide variety of physical and mental tasks without any physical measurements and manipulation. This principle component formed the fundamental basis for a computational theory of perceptions. The major distinction between perceptions used by SC and measurements applied with HC is that crisp values are used for measurements whereas acceptable values for perceptions are fuzzy in nature.

Among the soft computing techniques, FL was the first to establish the basic ideas of soft computing. It is used in two different ways. First, it as a logical system that aims at a formalization of approximate reasoning. Lastly, it can be thought of as the application side of fuzzy set theory dealing with well-thought-out real-world expert values for a complex problem [4] .

Fuzzy logic encompasses the concepts of a linguistic variable, canonical form, fuzzy if―then rule, fuzzy quantifiers and such modes of reasoning as interpolative reasoning, syllogistic reasoning and dispositional reasoning. Unlike classical logic, it gives a route to get to the results based on bounds that rely upon the vague, ambiguous, noisy or incomplete information, thus, solely concerned with uncertainty.

2. Literature Review

Some studies have been done with fuzzy logic in order to manage uncertainty. They are:

[5] worked on usage of the fuzzy adomain decomposition method for solving some fuzzy fractional partial differential equations. The authors proposed and utilized the technique of fuzzy adomain decomposition as an alternative method for obtaining approximate fuzzy solutions to various types of fractional differential equations.

[6] applied Fuzzy Case-Based Reasoning (F-CBR) and Fuzzy Analytic Hierarchy Process (F-AHP) to machine cutter planning and control. The researchers proposed a decision support system that integrated F-CBR and F-AHP for metal-cutting process.

[7] worked on a new fuzzy joint choquet integral method that considers multi-attributes under interval-valued function. This technique reflected the interaction between multiple attributes in a complex and uncertain environment while retaining the initial preference of the decision maker. The corresponding sensitivity analysis was operated that clarified the reliability and flexibility of the proposed technique.

2.1. Membership Functions

Lotfi Zadeh developed a set theory that captures these imprecise boundaries in order to resolve the issue of uncertainty. In the light of this development, the theory of a Membership Function was conceived. In a real-world scenario, every element in the fuzzy set that describes the vagueness is believed to have a degree of membership in that set. The degree of membership is the extent of measurability at which an element belongs in a particular set. The process of deriving the measurability values for the element is known as fuzzification.

An element can be both in and out of the set with a degree of membership. For fuzzy logic, to show the degree of truth, a set of membership values is inclusively between 0 and 1 while for crisp sets, elements are allowed a membership degree of 100% or 0% with nothing in between.

The different types of membership functions are:

2.1.1. Triangular Membership Function

The triangular membership function is a piecewise linear function where “a”, “b” and “c” represent the x coordinates of the three vertices of μA(x) in the fuzzy set A (Figure 1). The coordinate “a” is defined as the lower boundary in set A whose degree of membership is zero. The coordinate “c” is defined as the upper boundary

Figure 1. Triangular membership function.

whose degree of membership is zero, and coordinate “b” is the third apex of the triangle whose degree of membership is one. Equation (1) represents the mathematical formula used to calculate the degree of membership for any element “x” in a fuzzy set A:

t r i a n g l e ( x ; a , b , c ) = { 0 , x a x a b a , a x b c x c b , b x c 0 , c x (1)

The parameters {a, b, c} (with a < b < c) determine the x coordinates of the three corners of the underlying triangular MF.

2.1.2. Trapezoidal Membership Function

A trapezoidal MF is specified by four parameters {a, b, c, d} in Figure 2:

t r a p e z o i d ( x ; a , b , c , d ) = { 0 , x a x a b a , a x b 1 , b x c d x d c , c x d 0 , d x (2)

a lower limit a, an upper limit d, a lower support limit b, and an upper support limit c, where a < b <= c < d determine the x coordinates of the four corners of the underlying trapezoidal MF. A trapezoidal MF with parameter {a, b, c, d} reduces to a triangular MF when b is equal to c. Both triangular and trapezoidal MFs are straight line segments and so not efficient for nonlinear functions.

2.1.3. Sigmoid Membership Function

A sigmoid MF is defined by:

S i g ( x ; a , c ) = 1 1 + exp [ a ( x c ) ] (3)

Figure 2. Trapezoidal membership function.

where “a” controls the slop at the crossover point x = c. Sigmoid functions are employed widely as the activation function of artificial neural networks.

2.1.4. Gaussian Membership Function

Two parameters c and σ are used in Gaussian membership function:

g a u s s i a n ( x ; c , σ ) = e 1 2 ( x c σ ) 2 (4)

where c represents the MFs centre and σ determines the MFs width constant. They are well deployed in probability and statistics because of certain properties they possess such as invariance under multiplication (the product of two Gaussians is a Gaussian with a scaling factor) and Fourier transform (the Fourier transform of a Gaussian is still a Gaussian). This membership function (Figure 3) provides more accurate representation of the input-output relationship and hence, a more reliable evaluation [8] .

Figure 3. Gaussian membership function.

2.1.5. Generalized Bell Membership Function

A generalized bell MF (or Bell-shaped Function) is specified by three parameters {a, b, c} as shown in Figure 4:

Figure 4. Generalized bell membership function.

b e l l ( x ; a , b , c ) = 1 1 + | x c a | 2 b (5)

where the parameter b is usually positive. (If b is negative, the shape of this MF becomes an upside-down bell.) In probability theory, it is a direct generalization of the Cauchy distribution and also referred to as the Cauchy MF.

3. Materials and Methods

3.1. Data Collection

From the listed 27 blue chip companies in Nigerian Stock Exchange (that is, companies with long record of stable and reliable stock growth), the historical stock data of three companies that are already household names in Nigeria were selected as the research experimental data. Their daily price lists were captured from 2008 to 2011 (Table 1). The companies were: Dangote Sugar Refinery Plc (Food and Beverage), GlaxoSmith Kline Plc (Health) and Julius Berger Nig. Plc (Construction).

3.2. Input Parameters

Two sets of inputs (training data) were used―the stock inputs and the external factors as shown in Table 2. The stock inputs are the four technical indicators which are the outputs from the preprocessing unit while the external factors are the law suit and rumour. The external factors are based on expert’s opinion [9] [10] [11] [12] and were included with the aim of determining the effects of unknown factors in stock price prediction.

3.3. Fuzzy Modeling

The fuzzy controller was simulated using MATLAB as shown in Figure 5. It comprised three units: fuzzification, rule generation and defuzzification. The inputs into the fuzzy logic data predictor block are the training data that are the stock input parameters.

Table 1. Sample of Dangote Sugar dataset.

Table 2. Description of input parameters used as stock crisp values.

Figure 5. Fuzzy logic data predictor block.

3.3.1. Fuzzification

This method was used to transform the stock crisp values into grades of membership for linguistic terms of fuzzy sets. The training data are normalized through a customized transformation [3] .

Let X be a non-empty set of crisp stock values (Universe of Discourse) such that a fuzzy set A of the stock variable in X is characterized by its membership function:

μ A : X [ 0 , 1 ] (6)

and μ A ( x ) is interpreted as the degree of membership of stock data element x in fuzzy set A for each x X .

Where A is completely determined by the set of tuples:

A = { ( x , μ A ( x ) ) | x X } (7)

The fuzzy set used for the input stock classifiers for the technical indicators are BestBuy (BB), Buy (B), Sell (S) and BestSell (BS) while for the External Factors (which can be either positive or negative) are for Positive (Rumour)―Slightly Positive (SP), Positive (P), Very Positive (VP) and Extremely Positive (EP), and for negative (Law Suit)―Slightly Negative (SN), Negative (N), Very Negative (VN) and Extremely Negative (EN). The individual range is mapped on a scale of 5 - 50 for the technical indicators and 1 - 10 for the External Factors. Tables 3-6 show the Technical indicators inputs linguistic representation and membership function, Technical indicators control linguistic variable representation and membership function, external factors input linguistic representation and membership function and linguistic representation and membership function of the external factors outputs respectively.

Table 3. Technical indicators input linguistic representation and membership function.

Table 4. Technical indicators control linguistic variable representation and membership function.

Table 5. External factors input linguistic representation and membership function.

3.3.2. Choice of Membership Function (MF)

Gaussian Membership Function was used and implemented using gaussmf function to capture the stock dynamism by the membership function’s smoothness at its edges. Also, only Gaussian wave packets can achieve the minimum uncertainty principle [13] [14] .

The Gaussian Membership Function is calculated as follows:

Table 6. Linguistic representation and membership function of the external factors outputs.

f ( x i , σ , m ) = exp { ( x i m ) 2 2 σ 2 } (8)

where m represents the mean value, σ represents the standard deviation for a given membership function and x i represents the raw stock training data.

n e t i = x i (9)

o u t j = f ( n e t i , σ i j , m i j ) (10)

where o u t j represents the output corresponding to the jth membership function that corresponds to the input x i .

3.3.3. Rule Generation

The Multiple Input Multiple Output (MIMO) form was employed to represent the expert knowledge:

Fact: μ 1 is A 1 i and μ 2 is A 2 i and … and μ n is A n i .

Rule R i j : If μ 1 is A 1 i and μ 2 is A 2 i and … and μ n is A n i then T 1 is C 1 j , T 2 is C 2 j , …, T m is C m j , W i j .

Result: T 1 is C 1 j , T 2 is C 2 j , …, T m is C m j .

Where u 1 , , u n are the stock input linguistic variables (process state variables) and T 1 , , T m are the stock control Linguistic variables, A 1 i , , A n i and C 1 j , , C m j are the stock linguistic values of the linguistic variables u 1 , , u n and T 1 , , T m in the stock universe of discourse X and Y. The rules are weighted such that the degree of confidence with which the stock input fuzzy set A 1 i , , A n i (which is composed of fuzzy intersection (AND) of several univariate stock fuzzy sets) is related to the stock output fuzzy set C 1 j , , C m j is given by W i j [ 0 , 1 ] . When W i j is zero, the rule is inactive and does not contribute to the output. Otherwise, it partially fires whenever its antecedent is activated to a degree greater than zero. R i j represents the stock rule number.

The Number of Rules (NOR) was generated using Equation (11) as proposed by [15] :

N O R = x i c (11)

where x i is the number of stock input variables and c is the number of stock classifiers.

Figure 6 and Figure 7 show the Simulink block diagram of the fuzzification component structure using the Gaussian membership function and the Simulink block diagram of the input and output classifiers of the membership function respectively.

3.3.4. Antecedent Controller

Taking the stock inputs “a” and “b” to have their membership function in the interval [0, 1].

Such that:

Figure 6. Simulink block diagram of the fuzzification component structure using Gaussian membership function.

Figure 7. Simulink block diagram of the input and output classifiers of the membership function.

a = μ ( B B o ) and b = μ ( B o ) (12)

Its associated mapping is:

f : [ 0 , 1 ] × [ 0 , 1 ] [ 0 , 1 ] (13)

where “f” is the binary operator is T-norm as shown in Figure 17.

Thus,

T-norm T ( a , b ) (14)

= μ ( B B o ) μ ( B o ) (15)

where is the min operator.

The antecedent controller T-norm was employed because it is non decreasing in each argument, satisfies commutativity, associativity and the boundary condition a T 1 = a , where a denotes a general membership function and second binary condition a T 0 = 0 . Figure 17 depicts the Simulink block diagram showing the Internal Representation of each rule.

4. Results and Discussion

The results of the stock fuzzifcation used to capture the stock dynamism on Tables 3-6 are presented on Figures 8-15 showing when best to buy or sell stocks.

1) Technical Indicators Membership Function Plots

Figures 8-11 depict the membership function plots for the technical indicators―Open Price, High Price, Low Price and Close Price respectively.

2) External Factors Membership Function Plots

a) External Factors Input Membership Function Plots

Figure 8. Membership function of openprice.

Figure 9. Membership function of highprice.

Figure 10. Membership function of lowprice.

Figure 11. Membership function of closeprice.

Figure 12. Membership function of rumour.

Figure 13. Membership function of lawsuit.

Figure 14. Membership function of positive.

Figure 15. Membership function of negative news.

Figure 12 and Figure 13 depict the external factors input membership function for rumour and Law suit respectively.

b) External Factors Output Membership Function Plots

Figure 14 and Figure 15 depict the positive and negative effects of external factors output membership function. They show at what point and rate a customer can make a good profit or loss in stock market.

256 rules were generated with the four technical Indicators for the four stock classifiers (Best buy, buy, sell and best sell) as shown in Figure 16 and Figure 17 while 16 rules were generated with the two external factors for four stock classifiers each (very low gain, low gain, high gain, very high gain and very low loss, low loss, high loss and very high loss).

Figure 16. Simulink block diagram showing the input/output membership function connection to rules.

Figure 17. Simulink block diagram showing the internal representation of each rule.

The sampled rules generated for the technical indicators:

1) If (Openprice is Bestbuy) and (Highprice is Bestbuy) and (Lowprice is Bestbuy) and (Closeprice is Bestbuy), then (FuzzyOpen is Verypoor) (FuzzyHigh is Verypoor) (FuzzyLow is Verypoor) (FuzzyClose is Verypoor) (1).

2) If (Openprice is Bestbuy) and (Highprice is Bestbuy) and (Lowprice is Bestbuy) and (Closeprice is Buy), then (FuzzyOpen is Verypoor) (FuzzyHigh is Verypoor) (FuzzyLow is Verypoor) (FuzzyClose is Poor) (1).

3) If (Openprice is Bestbuy) and (Highprice is Bestbuy) and (Lowprice is Bestbuy) and (Closeprice is Sell), then (FuzzyOpen is Verypoor) (FuzzyHigh is Verypoor) (FuzzyLow is Verypoor) (FuzzyClose is Good) (1).

The sample rules generated for the external factors:

1) If (Rumour is Slightly positive) and (Lawsuit is Slightly negative), then (Positive is very low gain) (Negative is very low loss) (1).

2) If (Rumour is Slightly positive) and (Lawsuit is Negative), then (Positive is very low gain) (Negative is low loss) (1).

3) If (Rumour is Slightly positive) and (Lawsuit is Very negative), then (Positive is very low gain) (Negative is high loss) (1).

5. Conclusion

Soft Computing technique is ideal for solving real-world problems like stock market that has dynamic nature due to its robustness and tractability to handle imprecision and uncertainty. These abilities are attributed to fuzzy logic that helps experts to develop control systems that can handle vague data.

Conflicts of Interest

The authors declare no conflicts of interest.

References

[1] Investopedia (2013) Stock Market.
https://www.investopedia.com/terms/s/stockmarket.asp#axzz21jJu5E13
[2] Zadeh, L.A. (1965) Fuzzy Sets. Information and Control, 8, 338-353.
https://doi.org/10.1016/S0019-9958(65)90241-X
[3] Huang, Y., Lan, Y., Thomson, S., Fang, A., Hoffmann, W. and Lacey, R. (2010) Development of Soft Computing and Applications in Agricultural and Biological Engineering. Computers and Electronics in Agriculture, 71, 107-127.
https://doi.org/10.1016/j.compag.2010.01.001
[4] Klir, G.J., Yuan, B. and Clair, U. (1997) Fuzzy Set Theory: Foundation and Applications. Prentice Hall, New York.
[5] Nagwa, A.S. and Deepak, B.P. (2024) Usage of the Fuzzy Adomian Decomposition Method for Solving Some Fuzzy Fractional Partial Differential Equation. Advances in Fuzzy Systems, 2024, Article ID: 8794634.
https://doi.org/10.1155/2024/8794634
[6] Fentahun, M.K. and Glen, B. (2023) Application of Fuzzy Case-Based Reasoning and Fuzzy Analytic Hierarchy Process for Machining Cutter Planning and Control. Advances in Fuzzy Systems, 2023, Article ID: 8072930.
https://doi.org/10.1155/2023/8072930
[7] Liu, K. (2024) A New Fuzzy Joint Choquet Integral Method under Interval-Valued Function. International Journal of Fuzzy System Applications, 13, 1-21.
https://doi.org/10.4018/IJFSA.334699
[8] Hameed, I. (2011) Using Gaussian Membership Function for Improving the Reliability and Robustness of Students’ Evaluation Systems. Expert System with Application, 38, 7135-7142.
https://doi.org/10.1016/j.eswa.2010.12.048
[9] Beers, B. (2024) How the News Affects Stock Prices.
https://investopedia.com/ask/answers/155.asp
[10] Spiegel, U., Tavor, T. and Templeman, J. (2013) The Effect of the Quality of Rumor on Market Yields. International Journal of Business, 18, 273-281.
https://www.craig.csufresno.edu/IJB/Volumes/Volume18/V183.6.pdf
[11] Merenstein, A. (2006) An Analysis of Class Action Suits with a Special Emphasis on the Size Effect and the Filing Date.
http://stern.nyu.edu/sites/default/files/assets/documents/con_043276.pdf
[12] Pritchard, A.C. and Ferris, S.P. (2001) Stock Price Reactions to Securities Fraud Class Actions under the Private Securities Litigation Reform Act. SSRN Electronic Journal.
https://www.researchgate.net/publication/228140545_Stock_Price_Reactions_to_Securities_Fraud_Class_Actions_Under_the_Private_Securities_Litigation_Reform_Act
[13] Fitzpatrick, R. (2010) Heisenberg’s Uncertainty Principle.
https://farside.ph.utexas.edu/teaching/qmech/Quantum/node27.html
[14] Hill, M. (2013) The Uncertainty Principle for Fourier Transform on the Real Line.
https://math.uchicago.edu/~may/REU2013/REUPapers/Hill.pdf
[15] Alavala, C.R. (2012) Fuzzy Logic and Neural Networks, Basic Concepts and Application. New Age International (p) Limited Publishers, Daryaganj.

Copyright © 2024 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.