# Stock Portfolio Management in the Presence of Downtends Using Computational Intelligence
## 4 Methods and Materials
### Evolutionary Algorithms to Select Stocks
To ensure feasibility, the values for \(w_{j}\) in each individual are normalized in Lines 5 and 6. The parameters used by the DE algorithm consist of a crossover probability, \(CR\in[0,1]\), a differential weight, \(F\in[0,2]\), and a number of individuals in the population, \(population_{size}\geq 4\). Each individual in the population is represented by a real-valued vector \(z=[z_{1},z_{2},\ldots,z_{N}]^{\top}\), where \(z_{j}\) is the value assigned to the \(j\)th decision variable and \(N\) is the number of decision variables (in Problem (2), the decision variables are the \(N\) weights). The termination criterion used here for the search procedure consists of a predefined number of iterations (generations). The evolutionary process is performed in Lines 9-22. Here, for each generation of the DE, the solutions in the population are evolved such that the new population is composed of the best solutions found so far. Finally, the best solution found overall is selected in Line 23. ```
0:\(N_{iterations}\), \(CR\), \(F\), \(population_{size}\)
0: The values \(w_{1},w_{2},\ldots,w_{N}\) found that best solves Problem (3)
1:\(P\leftarrow\emptyset\)
2:\(i\gets 1\)
3:while (\(i\leq population_{size}\)) do
4: Randomly, define \(z_{k}\in[0,1]\) for \(z=[z_{1},z_{2},\ldots,z_{N}]^{\top}\)
5:\(sum\leftarrow\sum_{k=1}^{N}z_{k}\)
6:\(z_{k}\gets z_{k}/sum\) (\(k=1,2,\ldots,N\))
7:\(P\gets P\cup\{z\}\)
8:endwhile
9:\(j\gets 1\)
10:while (\(j\leq N_{iterations}\)) do
11:for all (\(z\in P\)) do
12: Randomly, define \(a,b,c\in P\), such that \(z\), \(a\), \(b\), \(c\) are all different
13: Randomly, define \(r\in\{1,\ldots,N\}\)
14:for all (\(i\in\{1,\ldots,N\}\)) do
15: Randomly, define \(u\in[0,1]\)
16: If \(u<CR\) or \(i=r\), set \(y_{i}=a_{i}+F\cdot(b_{i}-c_{i})\), otherwise set \(y_{i}=z_{i}\)
17:endfor
18:\(sum\leftarrow\sum_{k=1}^{N}y_{k}\)
19:\(y_{k}\gets y_{k}/sum\) (\(k=1,2,\ldots,N\))
20: If \(\xi(z)\leq\xi(y)\), then replace \(z\) for \(y\) in \(P\) (see Equation (3))
21:endfor
22:endwhile
23: Select the individual \(z\in P\) with the highest value \(\xi(z)\); this individual represents the best set of weights \(w_{1},w_{2},\ldots,w_{N}\) for Equation (2). ```  
**Algorithm 1** Differential evolution used to address Problem (3). Different fundamental indicators could be more convenient for companies with different types of activities (see, e.g., [14]). We use here some fundamental indicators that can be used for trans-business companies following the works in ([10; 11; 13; 14]). In this work, we use \(N=13\) factors to define the score of each stock as described below. Forecasted return: Output of the ANN. Return on equity: Net income over average shareholder's equity. Return on asset: Net income over total assets. Operating income margin: Operating earnings over revenue. Net income margin: Total liabilities over total shareholder's equity. Levered free cash flow: Amount of money the company left over after paying its financial debts. Current ratio: Current assets over current liabilities. Quick ratio: (Cash and equivalents + marketable securities + accounts receivable) over current liabilities. Inventory turnover ratio: Net sales over ending inventory. Receivable turnover ratio: Net credit sales over average accounts receivable. Operating income growth rate: (Operating income in the current quarter \(-\) operating income at the previous quarter) over operating income in the previous quarter. Net income growth rate: (Net income after tax in the current quarter \(-\) net income after tax at the previous quarter) over net income after tax in the previous quarter.