Fuzzy Expert System For Stock Portfolio Selection
Fuzzy Expert System For Stock Portfolio Selection
India
Abstract
Selection of proper stocks, before allocating investment ratios, is always a cru-
cial task for the investors. Presence of many influencing factors in stock perfor-
mance have motivated researchers to adopt various Artificial Intelligence (AI)
techniques to make this challenging task easier. In this paper a novel fuzzy ex-
pert system model is proposed to evaluate and rank the stocks under Bombay
Stock Exchange (BSE). Dempster-Shafer (DS) evidence theory is used for the
first time to automatically generate the consequents of the fuzzy rule base to
reduce the effort in knowledge base development of the expert system. Later
a portfolio optimization model is constructed where the objective function is
considered as the ratio of the difference of fuzzy portfolio return and the risk
free return to the weighted mean semi-variance of the assets that has been used.
The model is solved by applying Ant Colony Optimization (ACO) algorithm
by giving preference to the top ranked stocks. The performance of the model
proved to be satisfactory for short-term investment period when compared with
the recent performance of the stocks.
Keywords: Ranking of stocks, Stock Portfolio Selection, Fuzzy rule-based
system, Dempster-Shafer Theory.
1. Introduction
2
by identifying 7 factors influencing the stock market. A rule base of total 932
rules was constructed for this purpose. Though no proper portfolio optimization
model was used in this work, the outcome of the model proved to be satisfactory.
But the major concern of this model can be the development time and cost due
to repetitive expert interactions for the development of the model. Authors
have used only fuzzy set theory to deal with the inherent uncertainty present in
the rule base though fuzzy set theory is more effective in dealing with vagueness
in the model than addressing inherent uncertainty of the model [27]. In another
significant work Xidonas et al.[7] developed an expert system for the selection
of equity securities but the concerns remained more or less same as the previous
one.
In this proposed work selection of stocks are made with the help of an ex-
pert system where the fuzzy rule base is automatically generated by applying
DS evidence theory. This has considerably minimized the development time
and cost as no cost is incurred here in terms of experts’ consultations for the
construction of the rule base. DS evidence theory is well known for its capa-
bility of dealing with incomplete and uncertain information. So another level
of uncertainty handling mechanism beside fuzzy set theory is incorporated in
the model. Though there are many factors which function as evidences of stock
performance, here four most popular performance indicators: Price to Earning
Ratio (P/E), Price to Book Value (P/B), Price to Sales ratio (P/S) and Long
Term Debt to Equity ratio (LTDER) are initially identified and their historical
data for all the registered stocks under BSE, are collected during the period of
FY 2003-04 to FY 2011-12. In the first phase of the design, these four factors
has functioned as input variables of a fuzzy inference system in the proposed
model and their historical data have been used to generate the consequents of
the fuzzy rules with the help of DS evidence theory. The model is tested with
the historical data of FY 2012-13, when values of these four factors for each
stocks are provided as input to the fuzzy inference system and then they are
ranked based on their defuzzified output. In the second phase, a portfolio op-
timization model is constructed and then it is solved with ACO by considering
top 10 stocks, as per the previous ranking, in the portfolio, to allocate invest-
ment ratios by giving preferences to the top ranked stocks. As mentioned earlier
the model is tested with the data of FY 2012-13 to predict the performance of
different stocks in FY 2013-14 and FY 2014-15, the performance of the model is
proved to be satisfactory when compared with their actual performance. Figure
1 depicts the brief structure of the article.
The rest of the paper is organized as follows: Section 2 gives brief description
about the four identified factors and their importance in stock performance.
In Section 3 design of the proposed fuzzy expert system model is elaborated.
Portfolio construction using top 10 stocks is discussed in Section 4. Result
analysis and comparison with recent performance of stocks is done in Section 5
and finally Section 6 concludes the discussion.
3
Figure 1: Design diagram of the proposed inflation forecasting model
2.
There are many technical and fundamental factors which influence the stock
market directly or indirectly. In this work four fundamental factors Price to
Earning Ration (P/E), Price to Book Value (P/B), Price to Sales ratio (P/S)
and Long Term Debt to Equity ratio (LTDER) are identified and their brief
definitions are given below:
4
In general, If P/B value is low then it suggests that the stock is undervalued
and it could also mean that something is going wrong with the company.
DS evidence theory and fuzzy rule based expert system are hybridized in
this work to evaluate and rank the stocks under BSE. Brief introduction of DS
evidence theory and fuzzy rule based expert system are given here before their
application in the proposed model is elaborated.
5
where ∅ denotes the empty set. The most important task in applying evidence
theory is Basic Probability Assignment (BPA). A BPA is a function from P (Θ)
to [0, 1] defined by:
m : P (Θ) → [0, 1]
(7)
X 7→ m(A)
and which satisfies the following criteria:
X
m(X) = 1;
X∈P (Θ) (8)
m(∅) = 1.
m = m1 ⊕ m2 ⊕ m3 ... ⊕ mI (11)
With the help of Equation (11) multi source information can be fused into a
single framework in belief theory very easily and it proved to be very effective
when it is applied in fuzzy rule generation discussed later in Section 3.3.3.
6
Fuzzy expert system is an expert system that uses fuzzy logic instead of
Boolean logics in its knowledge base and derives conclusion from user inputs
and fuzzy inference process [34]. Figure 2 depicts the basic architecture of a
fuzzy expert system.
7
• Explanation Facility: This particular module explains every steps in
reasoning process of the ES.
• Knowledge Acquisition Facility: This module provides an automated
facility for the user to enter knowledge in the system.
• User Interface: All kinds of interactions of the user with the system is
facilitated by this module. This is used to accept inputs from the user
and display the outcomes of the inference process.
3.3.2. Fuzzification
Fuzzification is a process of taking a crisp value as input and transforming
it into the degree required by the terms. Uncertainty basically comes from
imprecision, vagueness or ambiguity and one of the best ways to represent these
in any variable can be in the form of fuzzy variable. Fuzzy membership functions
8
are used to represent the fuzzy variables. All four factors have been illustrated
in TABLE II in terms of fuzzy linguistic variables and each of them has three
linguistic values, Low, Standard and High. Trapezoidal membership function
has been used to represent the inputs within the range of [0, 10].
Table 2: Membership functions for the linguistic values of the Input Variables
9
to its standard value. Again, when P/E value found to be much lower than
its standard value, 65% of total stocks under BSE performed average and S/R
value also found to be average. So 0.6 degree of belief is assigned towards the
hypothesis {Average Performance} when P/E ratio is lower than its standard
value. Similarly, when the value of P/E ratio was much higher than the stan-
dard value then it was found that 70% of stocks under BSE performed poor
and S/R value was also very high. So 0.7 degree of belief is assigned towards
the hypothesis {Poor Performance}. In the same way initial believes or Basic
Probabilities are assigned for all other factors as mentioned in Table 3.
Now to elaborate further let us consider the following four sample rules with
their initial belief:
Rule 1. IF P/E is Low THEN Performance will be Average (m1 (A P ) =
0.6).
Rule 2. IF P/B is Standard THEN Performance will be Average (m2 (A P ) =
0.6).
Rule 3. IF P/S is High THEN Performance will be High (m4 (H P ) = 0.75).
The above four rules represent the belief towards the performance of stocks with
respect to the values of four input factors as the presence of evidences. Now
consider the IF part of Rule 1 and Rule 2 as the first two evidences and m1 and
m2 as mass functions for them respectively.
10
Now from Rule 1, m1 (A P ) = 0.6 and m1 (Θ) = (1 − 0.6) = 0.4, where,
m1 (Θ) represents the degree of belief in the rest of the hypotheses present
in the hypothesis set. Similarly, from Rule 2, m2 (A P ) = 0.6 and m2(Θ) =
(1 − 0.6) = 0.4. Now these two mass functions are combined using Dempster’s
rule of combination (Equation 9) to obtain a new function m3 as mentioned in
Table
The new mass value m3 for the same hypothesis set is calculated as:
m3 (A P ) = 0.36 + 0.24 + 0.24 = 0.84
(12)
m3 (Θ) = 0.16
Now consider the IF part of the Rule 3 as the new evidence and m4 be
the new mass function. From Rule 3, m4 (H P ) = 0.75 and m4 (Θ) = (1 −
0.75) = 0.25. Now again, m3 and m4 are combined to generate new mass m5
as mentioned in Table 5.
New mass values m5 for the hypothesis set are calculated as below:
0.21
m5 (A P ) = = 0.567
1−0.63
0.12
m5 (H P ) = 1−0.63 = 0.324 (13)
0.04
m5 (Θ) = 1−0.63 = 0.108
Now if we consider the IF part of the Rule 4 as the last evidence and m6
as its mass function then we get m6 (H P ) = 0.6 and m6 (Θ) = (1 − 0.6) = 0.4.
Now finally, m5 and m6 are combined as mentioned in Table 6 to generate the
final mass values mf for the hypothesis set (Equation 14).
11
Table 6: Combination of mass considering all four evidences
0.113
mf (H P ) = 1−0.578 = 0.267
0.198
mf (A P ) = 1−0.578 = 0.469
0.07 (14)
mf (P P ) = 1−0.578 = 0.165
0.37
mf (Θ) = 1−0.578 = 0.087
Following the same procedure final mass values for the rest 80 rules are
calculated. For the hypothesis High Performance(H P) maximum and minimum
mass values (mf ) are found to be 0.9916 and 0 respectively. As mass values for
any hypothesis can lie between 0 and 1 we have divided the favourability of
any stock, based on the mf (H P ) of the rules, into three categories: Highly
Favourable (0.76 ≤ mf (H P ) ≤ 1), Moderately Favourable (0.46 ≤ mf (H P ) ≤
0.75) and Not Favourable (mf (H P ) ≤ 0.45).
So the combined version of the four sample rules mentioned earlier is formed
as:
“IF P/E is Low AND P/B is Standard AND P/S is High AND LTDER
is High THEN the stock is Not Favourable”.
In this way total 81 fuzzy rules are formulated using DS evidence theory to
develop the knowledge base of the proposed DS-fuzzy inference system and the
above mentioned three selection categories are converted into fuzzy linguistic
variables with trapezoidal membership values as shown in Table 7 for output of
the proposed inference system.
Fuzzy Trapezoidal
Output Variable Linguistic Values
Membership
Not Favourable (0 0 0.172 0.448)
Selection (Range: 0
Moderately
to 1) (0.34 0.46 0.57 0.75)
Favourable
Highly Favourable (0.64 0.88 1 1)
Figure 3 shows the snapshot of the fuzzy rule base and Figure 4 shows the
sensitive analysis for the same when designed in MATLAB.
12
Figure 3: Fuzzy rule base of the DS-fuzzy system for Stock Selection
Figure 4: The Sensitive analysis of the DS-fuzzy system for Stock Selection
13
3.3.4. Defuzzification
The process of obtaining a single value that represent the best outcome of the
fuzzy set evaluation is known as defuzzification [37]. Though there are many
other popular defuzzification methods namely, Bi-sector, Mean of Maximum
(MOM), Smallest of Maximum (SOM), Largest of Maximum (LOM), in this
proposed model ‘Centroid’ is used for the defuzzification purpose due to its
wide range of acceptability. This method was introduced by Sugeno in 1985
and it can be expressed as:
R
µC (z) · zdz
∗
z = R (15)
µC (z)dz
e
e
Where z is the output variable, z ∗ is the defuzzified output value and µC (z) is
the aggregated membership function. e
Defuzzified
Sl. No Name of the Stocks
Values(FY 2012-13)
1 Hindustan Unilever Ltd. 0.8644
2 Sun Pharmaceutical Inds. Ltd. 0.8457
3 I T C Ltd. 0.5369
4 Coal India Ltd. 0.534
5 Tata Consultancy Services Ltd. 0.4936
6 Infosys Ltd. 0.3842
7 Dr. Reddy’S Laboratories Ltd. 0.3553
8 Bajaj Auto Ltd. 0.3292
9 Hero Motocorp Ltd. 0.3002
10 Cipla Ltd. 0.285
4. Portfolio Construction
The first phase of stock portfolio selection, i.e. the selection of suitable
stocks, is achieved in the previous section. In this section a portfolio construction
14
model is discussed to determine optimum investment ratios for the selected
securities such that the overall return is maximized under a tolerable risk.
Values for α,β, γ, M and m are decided based on the investor’s preferences.
15
Thus the final portfolio optimization model can be summarized as below:
P
E( r˜i xi )−rf
M aximize µs
Subject to,
rp > α, vp > β, sp > γ
(19)
Pn
xi = 1, xi ≤ M, xi > 0, ∀i
i=1
To execute the above algorithm in this work, initially 2000 random solutions
are generated for the ant colony of 50 ants. Total 400 iterations are used for the
optimization purpose while lifetime for each ant is considered as 20.
16
In Equation (19), r˜i is represented as a triangular fuzzy number. The Ex-
pected Return (E), Variance (Var), Skewness (Skew) and Semi-variances of these
top 10 securities for past five years (2008-09 to 2012-13) as used in the above
algorithm are calculated by the following theorem and are mentioned in Table
9
Theorem 4.1. Let à = (a, b, c) be a triangular fuzzy number. The the weighted
possibilistic mean, variance and skewness can be calculated as [40]:
= 16 (a + 4b + c)
E(Ã)
1 2
V ar(Ã) = 18 (a + b2 + c2 − ab − bc − ca)
(20)
19(a3 +c3 )−8b3 −42b(a2 +c2 )+12b2 (a+c)−15(a2 c+ac2 )+60abc
Skew(Ã) = √ √
10 2( a2 +b2 +c2 −ab−bc−ca)3
When the algorithm is executed in MATLAB with the above dataset and
considering other parameters as rf = 0.01, β = 0.5, α = 0.05, γ = 0.001,
M = 0.8 and µs = 0.0016, the maximum return is found as 0.1317. The
proposed ratio allocation for this return is given in Table 10 .
The convergence of the objective values as per the proposed model is depicted
in Figure 5 and the accumulation of ants to the optimum objective values in
each iteration is depicted in Figure 6.
17
Table 10: Ratio allocation for the proposed portfolio
28
27
26
25
24
23
22
21
0 100 200 300 400 500
50
45
40
35
30
25
20
15
10
0
0 100 200 300 400 500
18
5. Result Analysis
From the above table we can find a match of 9 companies for FY 2013-14 and a
match of 11 companies for FY 2014-15. As S/R values are effective performance
indicator of stocks, it can be concluded that the proposed model will give better
19
return in short-term investment period.
In the second stage by considering top 10 stocks under BSE, based on their
S/R values for FY 2012-13, a portfolio is constructed using the same ACO
algorithm and the objective function (Eq. 19). The optimum return is found to
be 0.0740, which is much less than the expected return (0.1317) of the proposed
model.
In the third stage another portfolio is constructed using the same ACO
algorithm, where all 30 registered companies were under BSE are considered.
But the optimum return found to be 0.0624 which is much lower than the return
calculated by the proposed model. This again proves that the proposed model is
more effective in portfolio construction. Figure 7 compares the returns of these
three portfolios.
6. Conclusion
In this research a novel fuzzy expert system model is designed and implemented
to evaluate and rank the stocks under BSE. DS-evidence theory is used for
the development of the fuzzy rule base to reduce the overall implementation
time and cost of the system. A portfolio optimization model is constructed
by considering the ratio of the difference of fuzzy portfolio return and risk free
return to the weighted mean semi-variance of the assets as the objective function.
ACO is used to obtain the optimum value of this portfolio.
As the outcome of this model found to be satisfactory, this can be imple-
mented for any stock exchanges around the world but the selection of critical
factors may vary over different stock exchanges. This fuzzy expert system model
can be used to rank any set of alternatives based on the factors influencing them.
The portfolio optimization model and the related ACO algorithm can be used
to optimize any rank-preference based portfolios.
20
References
21
[15] S. O. Olatunji, M. S. Al-Ahmadi, M. Elshafei, Y. A. Fallatah, Saudi arabia
stock prices forecasting using artificial neural networks, in: Applications
of Digital Information and Web Technologies (ICADIWT), 2011 Fourth
International Conference on the, IEEE, 2011, pp. 81–86.
[16] F. A. De Oliveira, L. E. Zárate, M. de Azevedo Reis, C. N. Nobre, The
use of artificial neural networks in the analysis and prediction of stock
prices, in: Systems, Man, and Cybernetics (SMC), 2011 IEEE International
Conference on, IEEE, 2011, pp. 2151–2155.
[17] J.-S. Chen, Y.-T. Lin, A partitioned portfolio insurance strategy by a rela-
tional genetic algorithm, Expert Systems with Applications 36 (2) (2009)
2727–2734.
[18] T.-J. Chang, S.-C. Yang, K.-J. Chang, Portfolio optimization problems
in different risk measures using genetic algorithm, Expert Systems with
Applications 36 (7) (2009) 10529–10537.
[19] J.-S. Chen, J.-L. Hou, S.-M. Wu, Y.-W. Chang-Chien, Constructing in-
vestment strategy portfolios by combination genetic algorithms, Expert
Systems with Applications 36 (2) (2009) 3824–3828.
[20] J. R. Jiao, Y. Zhang, Y. Wang, A heuristic genetic algorithm for product
portfolio planning, Computers & Operations Research 34 (6) (2007) 1777–
1799.
[26] F. Tiryaki, M. Ahlatcioglu, Fuzzy stock selection using a new fuzzy rank-
ing and weighting algorithm, Applied Mathematics and Computation 170
(2005) 144–157.
22
[27] R. M. Rodrı́guez, L. Martı́nez, F. Herrera, Hesitant fuzzy linguistic term
sets for decision making, Fuzzy Systems, IEEE Transactions on 20 (1)
(2012) 109–119.
[28] A. P. Dempster, Upper and lower probabilities induced by a multivalued
mapping, The annals of mathematical statistics (1967) 325–339.
[36] L.-X. Wang, A course in fuzzy systems, Prentice-Hall press, USA, 1999.
[37] E. W. T. Ngai, F. K. T. Wat, Design and development of a fuzzy expert
system for hotel selection, Omega 31 (4).
[38] M. Dorigo, M. Birattari, T. Stützle, Ant colony optimization, Computa-
tional Intelligence Magazine, IEEE 1 (4) (2006) 28–39.
23