-
Notifications
You must be signed in to change notification settings - Fork 2
/
section_Proposed_Method_label_proposed__.tex
85 lines (55 loc) · 11.3 KB
/
section_Proposed_Method_label_proposed__.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
\section{Proposed Method}
\label{proposed-method}
\subsection{Dataset}
\label{dataset}
The dataset used in this work was first used by Brown, Pelosi, and Dirska \cite{brown2013dynamic}, and can be found at the UCI Machine Learning Repository under the name of "Dow Jones Index Data Set." In this work we only used the open, high, low, and close prices, and we obtained the average directional index (ADX), stochastic oscillator (SO), and relative strength index (RSI) for the dataset records by using an online tool called FreeStockCharts, which can be found at http://www.freestockcharts.com/. We added the TI to the stocks provided in the dataset by Brown et al. using FreeStockCharts, and downloaded the full historical data from the platform. A filtering was performed where only the relevant records were extracted (the same records that are present in the benchmarking dataset).
As a final step, another attribute was added to the dataset, which the authors of this work call "directional strength." This attribute tells how strong a movement was at a particular time in a time series, and what its direction was (downtrend or uptrend). An absolute value of 100 of the directional strength means that it was a very strong movement, where all the traders in that financial market agree to buy or sell, and a value of 0 means strong indecision. The directional strength indicator could have already been mentioned in the literature, but the authors of this work couldn't find a reference to this particular formula. The formula to calculate the directional strength is as follows:
\begin{equation} \label{directional-strength}
DS(t) = 100{{C(t) - O(t)} \over {H(t) - L(t)}}
\end{equation}
Where \textit{t} represents a particular point of time in a time series, \textit{O} represents the open price, \textit{H} the high, \textit{L} the low, and \textit{C} the close price.
\subsection{Decision Support System}
The final outcome of the proposed method is a recommendation to buy, sell or hold in a financial market. The system tells the user the direction which the market is going to take (downtrend or uptrend) and its strength, through the use of the directional strength indicator (see Subsection \ref{dataset}).
Nevertheless, the underlying method can be used to perform regression tasks, and it could be extended to perform classification tasks in a future work. What follows is the explanation of this underlying method.
\subsection{Communities of Agents}
\label{communities-of-agents}
As has been noted before, the proposed method is based on ABM. To implement a system based on ABM, we developed the concept of a community of agents. A community is a collection of agents, who are the final actuators in the environment (the simulated financial market). The action of each of the agents in the community involves providing certain trading force, which is a value between -100 and 100. The sum of all of the forces of the agents in a community must be equal to the observed or real directional strength indicator for a particular record in the dataset. A community receives its inputs, which are the TI ADX(\textit{t}), SO(\textit{t}), and RSI(\textit{t}), and give as output the DS(\textit{t+1}) (the directional strength of a future record, i.e. one data point in the future).
The method creates several communities, which exchange genetic material of its agents among them, in order to produce better performing communities, and their fitness is determined using a sum of the mean-squared error (MSE) and the absolute value of the sum of the forces of its agents. The use of this summation was determined to be a good fitness indicator by trial and error, but other fitness functions can be used. A flowchart depicting the algorithm that creates a population of these communities is presented in Figure \ref{flowchart-without-dynamic}.
\subsection{Fuzzy Inference Systems}
Each of the agents in the communities has a FIS that acts as its agent function. The inputs of this FIS, as has been mentioned before, are the ADX, SO, and RSI. The output is a real number between -100 and 100 that represents the directional strength. To arrive to this output number, one can choose a number of MF that act as inputs and a number of MF that act as outputs. By trial and error, the authors found that a number of 5 outputs gave good results in most cases. The FIS defuzzifies the aggregation of the MF at their activation level determined by its inputs, and this will represent a directional strength for that particular agent.
The rule set is depicted below, and is comprised of 15 rules: 5 outputs for each of the 3 TI. GPpred\textit{N} represents a predicate MF created by the GP algorithm and, similarly, GPcons\text{N} represents a consequent.
\begin{enumerate}
\item if ADX is GPpred1 then DS is GPcons1
\item if ADX is GPpred2 then DS is GPcons2
\item if ADX is GPpred3 then DS is GPcons3
\item if ADX is GPpred4 then DS is GPcons4
\item if ADX is GPpred5 then DS is GPcons5
\item if RSI is GPpred6 then DS is GPcons6
\item if RSI is GPpred7 then DS is GPcons7
\item if RSI is GPpred8 then DS is GPcons8
\item if RSI is GPpred9 then DS is GPcons9
\item if RSI is GPpred10 then DS is GPcons10
\item if SO is GPpred11 then DS is GPcons11
\item if SO is GPpred12 then DS is GPcons12
\item if SO is GPpred13 then DS is GPcons13
\item if SO is GPpred14 then DS is GPcons14
\item if SO is GPpred15 then DS is GPcons15
\end{enumerate}
\subsubsection{Genetic Programming}
In order to create the MF, a GP algorithm performs a number of operations among the initially generated communities. These operations are the classical crossover and mutation operations, along with two new operations: migration and replace. The crossover operation simply chooses a subtree of the GP function of the \textit{i}th agent of a community A, and passes it to the GP function of the \textit{i}th agent of a Community B. A subtree from the community B is passed to the GP function of the \textit{i}th agent. As a result, two new agents are generated and replace the old agents. To determine what communities are to be crossed over, a tournament is held where two random communities are chosen from the population, and the one with the lowest MSE plus the absolute value of the sum of forces (as explained is Subsection \ref{communities-of-agents} is chosen; this will obtain the first community. This process is repeated to obtain a second community. As for the mutation operation, a subtree from a community A is selected and randomly changed to produce a new GP function. The community to be mutated is randomly selected from the population.
The migration operation is a rather simple one. According to a migration chance, an agent from a community A will get interchanged with another agent from a community B. In order to determine if this interchange is to be performed, the algorithm checks if the sum of the forces of community A is of different sign than the sum of forces of community B. This ensures that the migration will produce a community closer to a zero-sum, i.e. the community will be closer to the observed or real prices. As for the replace operation, a whole new community is generated and replaces the community with the highest absolute value of the MSE plus sum of forces. All the four operations have a pre-established chance of occurring (except for the replace chance, which is currently being dynamically adapted by using a FIS. See Subsection \ref{dynamic-adaptation-of-the-replace-chance}). One can see a flowchart of the general process in Figure \ref{flowchart-without-dynamic}.
In addition to this set of operations, the GP algorithm uses the parameters of population size (in this case, the number of communities), the number of agents per community, the number of generations, how many inputs the agents will process (in this case, the TI), and how many outputs (which, in the end, as has been noted previously, get defuzzified into a directional strength value).
How the proposed method generates the MF is a novel or, at least uncommon, method (the authors of this work could not find any works that use this specific technique). The GP algorithm uses a sum of sines to produce functions that are converted to the MF of the FIS of the agents. A graphical representation of an input MF and an output MF are depicted in Figure \ref{input-mf} and Figure \ref{output-mf}, respectively. The GP algorithm uses only two operators: the sum and the sine operators. The sum of sines is represented by Formula \ref{sum-of-sines}.
\begin{equation} \label{sum-of-sines}
y = \sum_{i=1}^{n} a_{i} sin(b_{i}x + c_{i})
\end{equation}
Taking into consideration Formula \ref{sum-of-sines}, the GP algorithm uses the following literals set: \textit{a}, \textit{b}, and \textit{c} are random real numbers, where \textit{a} ranges from 0.0 to 0.3, \textit{b} ranges from 0.0 to 10.0, and \textit{c} ranges from 0.0 to 1.0. These ranges were obtained by trial and error, and other ranges could perform better. An additional real number literal is added to the set, which ranges from -1 to 1, along with the variable \text{x}, which takes the value of the current input (ADX, RSI or SO).
\subsection{Dynamic Adaptation of the Replace Chance}
\label{dynamic-adaptation-of-the-replace-chance}
The replace chance parameter, instead of being constant, is dynamically adapted using a FIS while the GP process is running. This idea was borrowed from the series of works by Castillo, et al. An example of this dynamic adaptation of parameters can be found in \cite{castillo2015new}, where the authors apply a FIS that controls the value of certain parameters in an ant colony optimization algorithm (ACO), proposing different architectures. Then, these architectures are compared in performance. In the end, the authors prove that the dynamic adaptation of parameters through the use of FIS can improve the performance of ACO. Additionally, one can find a survey of the application of this type of technique in the work by Valdez, Melin and Castillo \cite{valdez2014survey}.
In the proposed method, a similar approach is taken, where dynamic adaptation of parameters through FIS is used to avoid the stagnation of the GP algorithm. In this case, a stagnated GP algorithm would mean that it has been producing the same fitness over a number of generations, i.e., the absolute value of MSE plus sum of forces is not being lowered in the last N generations. To calculate this stagnation level, the authors of this work propose the stagnation index, which is described by Formula \ref{si}, where S(P) means the stagnation index of P, where P is the set of fitnesses over certain number of generations, and C(P) is the count of repeated fitnesses over the last N generations. For example, given the set P = {5, 5, 5, 3, 2, 1}, C(P) = 3.
\begin{equation} \label{si}
S(P) = 1 - \sqrt{1 \over C(P)}
\end{equation}
The stagnation index is given as input to a FIS, which gives as output a new replace chance for the replace operation. The objective of this dynamic adaptation of parameters is to obtain lower errors in a smaller amount of generations. This is proven in Section \ref{experiments-and-results}. Also, it is worth mentioning that this technique could be applied to the crossover, migration, and mutation chances, but due to a limitation of time, the authors of this work could only apply the technique to one parameter.
A flowchart depicting the modified GP algorithm is shown in Figure \ref{flowchart-with-dynamic}.