Stock Portfolio Management in the Presence of Downtrends Using Computational Intelligence

: Stock portfolio management consists of deﬁning how some investment resources should be allocated to a set of stocks. It is an important component in the functioning of modern societies throughout the world. However, it faces important theoretical and practical challenges. The contribution of this work is two-fold: ﬁrst, to describe an approach that comprehensively addresses the main activities carried out by practitioners during portfolio management (price forecasting, stock selection and portfolio optimization) and, second, to consider uptrends and downtrends in prices. Both aspects are relevant for practitioners but, to the best of our knowledge, the literature does not have an approach addressing them together. We propose to do it by exploiting various computational intelligence techniques. The assessment of the proposal shows that further improvements to the procedure are obtained when considering downtrends and that the procedure allows obtaining portfolios with better returns than those produced by the considered benchmarks. These results indicate that practitioners should consider the proposed procedure as a complement to their current methodologies in managing stock portfolios.


Introduction
Both individual and organizational investors commonly seek to take profits from stock markets. Among the different ways to exploit these markets, the literature has focused on the idea of buying cheap and selling expensive. The authors of [1] point out that there is an assumption in classical portfolio theory to manage the selected assets with the simplest trading strategy, which is a buy-and-hold approach. However, it is also common for practitioners to also seek profits when prices go down. There are several mechanisms that allow an investor to take profits in this situation (e.g., [2][3][4]).
Investing in stocks when their prices are expected to rise is known as opening a long position. In this scenario, the investor adopts the idea that stocks should be bought when they are the cheapest and sold when they are as expensive as possible; the difference between selling and buying prices constitutes the investor's basic earning. On the other hand, opening a short position means that the investor expects the stock prices to go down. According to [5], short selling allows the investor to profit from their belief that the price of a security will decline. Moreover, short selling is used by top-down and quantitative managers as a part of a neutral strategy (cf. [5]). In this case, the investor can, for example, borrow shares of the stock, sell them in this very moment and commit to return them at a moment in the future; so, to return them, the investor will have to buy them at whatever the price of the stock is at that moment in the future. Therefore, the earning of the investment here is also calculated as the difference between the selling and buying prices-just that the sell is produced first.
The highly complex decision-making process of allocating resources considering both uptrends and downtrends of prices requires sophisticated models and tools to achieve competitive results. Thus, this work proposes a comprehensive procedure based on computational intelligence that aids defining how investors should allocate their resources in the presence of both scenarios.
First, an artificial neural network (ANN) (cf. [6]) is used to estimate future prices. There are evident tendencies in the literature showing that ANNs have high accuracy, fast prediction speed and clear superiority in predictions related to financial markets (e.g., [7][8][9]). To perform these estimations, the ANN takes historical performances of the stocks considering the most common factors of the literature, such as stock prices and financial ratios (cf. [10]). Some additional financial indicators are used here to determine if the forecasted tendency (that the price will go up or down) is supported. These indicators are taken from the so-called fundamental analysis, a type of indicators often considered by practitioners (cf. [11]). Evolutionary algorithms (EAs) are then used to ponder these indicators altogether with the price estimation and determine which stocks should be considered by the investor for investment, either with a downtrend or an uptrend. Finally, EAs are also used to determine how much of the resources should be allocated to each of the selected stocks on the basis of statistical analysis to historical data. Here, only historical prices of the selected stocks are taken into consideration according to the approach described in [12].
The literature review presented in Section 3 shows that, although there are studies that consider both uptrends and downtrends in stock prices, as far as we know, there are no published works that comprehensively address the problem the way that is proposed here. That is, not only taking advantage of a future increase in prices by opening long positions but also taking advantage of future decrease in prices by opening short positions, while also forecasting stock prices, selecting the most plausible stocks and optimizing the stock portfolio. Our hypothesis is that a procedure that effectively implements all this provides better overall earnings for the investor. The hypothesis is based on the activities and interests of practitioners. We test this hypothesis by using extensive experiments with actual historical data.
The rest of the paper is structured as follows. Section 2 describes the fundamental theories that support this research. Section 3 presents the related literature. Section 4 describes the details of the techniques that compose the proposed procedure. In Section 5, we explained the experiments to test this work's hypothesis. Finally, Section 6 concludes this paper.

Background
This section provides a brief overview of the concepts and methods used in the proposed approach. These concepts and methods are (i) fundamental analysis, (ii) artificial neural networks and (iii) evolutionary multi-objective optimization. Furthermore, we provide a short description of multiobjective optimization problems in order to present a complete theoretical basis of the proposed approach.

Fundamental Analysis
One of the most used sources of information in the management of stock portfolios comes from the so-called fundamental analysis. The fundamental indicators provided by this analysis allow the practitioner to evaluate stocks from multiple perspectives. Such indicators are constructed from the financial statements that the companies (underlying the stocks) present publicly on a regular basis.
Fundamental indicators provide information that is often exploited in the literature to forecast future stock performance and to select the most competitive stocks. These indicators can be used both qualitatively and quantitatively. Regarding the latter, the financial information published by companies is synthesized in the form of ratios that shed light on the current state of the company, providing remarkable information on what can be expected from the financial health of the company and the possible future price of its stock. When this analysis is used in the literature, the fundamental indicators are usually aggregated in an overall assessment value that requires subjective preferences from the practitioner (cf. e.g., [13]); however, the aggregation procedure is not straightforward and represents an important challenge.
On the other hand, different fundamental indicators could be more convenient for companies with different types of activities ( [14]). Some fundamental indicators that can be used for trans-business companies are described in Section 4.1 (cf. [10,11,13,14]).

Artificial Neural Networks
Artificial neural networks are nowadays very popular among techniques from computational intelligence that have been used for many applications, such as classification, clustering, pattern recognition and prediction in diverse scientific and technological disciplines ( [15,16]). Similarly to other computational intelligence techniques, applications of ANN are very diversified due to its capability to model systems and phenomena from the fields of sciences, engineering and social sciences.
Analogously to a nervous system, an ANN is built from neurons, which are the basic elements for processing signals. Neurons are interconnected to form a network, with additional connections (synaptic relations) for input and output signals. Weights are assigned to each of these and other connection. The computing of suitable values for these weights is performed by training algorithms. An ANN needs to be trained before it can be used by using data from the system or phenomenon to model. Neurons are configured to form layers, in which neurons have parallel connections for inputs and outputs. ANN complexity varies from a network with a single layer of a single neuron to networks with several layers, each having several neurons. Networks with only forward connections are known as feedforward networks. Networks with forward and backward connections are known as feedbackward networks ( [15]). The term deep learning refers to ANN with complex multilayers ( [17]). Roughly speaking, deep learning has more complex connections between layers and also more neurons than previous types of networks. Some neural networks that form deep learning networks are convolutional networks, recursive networks and recurrent networks.

Multi-Objective Optimization Problem
Without loss of generality, a multi-objective optimization problem (MOP) can be defined in terms of maximization (although minimization is also common) as follows: where Ω is the set of decision variable vectors x = [x 1 , x 2 , . . . , x m )] that fulfill the set of constraints of the problem, and then F : It is evident that the notation used here states that all functions f i (objectives) should be maximized; however, it is also possible that one requires some functions f i to be minimized instead. To keep standard notation, we assume that the latter can be simply achieved by multiplying the minimizing function by −1.
In the context of stock portfolio management, the functions f i are usually in conflict with each other. This means that improving f j deteriorates f k for some j = k. Therefore, there is no solution x ∈ Ω that maximizes all the k objectives simultaneously. Nevertheless, it is still possible to define some solutions x that poses the best characteristics in terms of their impact on the objectives; this is commonly carried out through Pareto optimality (cf. [18]).
Let u, vs. ∈ R k denote impacts of solutions x and y, respectively. u dominates v if and only if u i ≥ v i for all i = 1, . . . , k, and u j > v j for at least one j = 1, . . . , k. Then, a solution x * ∈ Ω is Pareto optimal if there is no solution y ∈ Ω such that F(y) dominates F(x * ). Note that there can be more than one Pareto optimal solution. The set of all the Pareto optimal solutions is called the Pareto set (PS), and the set of all their corresponding objective vectors is the Pareto front (PF).

Evolutionary Multi-Objective Optimization
Multi-objective evolutionary algorithms (MOEAs) are high-level procedures designed to discover good enough solutions to MOPs (solutions that are close to the global optimum). They are especially useful with incomplete or imperfect information or a limited computing capacity ( [19]).
MOEAs address MOPs using principles from biological evolution. They use a population of individuals, each representing a solution to the MOP. The individuals in the population reproduce among them, using so-called evolutionary operators (selection, crossover, mutation), to produce a new generation of individuals. Often, this new generation of individuals is composed of both parents and children that posses the best fitness; this fitness represents the impact on the objectives of the MOP. Since each individual encodes a solution to the MOP, MOEAs can approximate a set of trade-off alternatives simultaneously The performance of MOEAs has been assessed in different fields (e.g., [20,21]). They have been widely accepted as convenient tools for addressing the problem of stock portfolio management ( [10][11][12]). The main goal of MOEAs is to find a set of solutions that approximate the true Pareto front in terms of convergence and diversity. Convergence refers to determining the solutions that belong to the PF, while diversity refers to determining the solutions that best represent all the PF. Thus, the intervention of the decision maker is not traditionally used in the process. Thus, rather little interest has been paid in the literature to choosing one of the efficient solutions as the final one in contrast to the interest paid in approximating the whole Pareto front.
Usually, two types of MOEAs are highlighted in the literature: differential evolution and genetic algorithms. Differential evolution (DE) has been found to be very simple and effective ( [22]), particularly when addressing non-linear single-objective optimization problems ( [23,24]). On the other hand, in a genetic algorithm (GA), solutions to a problem are sought in the form of strings of characters (the best representations are usually those that reflect something about the problem that is being addressed), virtually always applying recombination operators such as crossing, selection and mutation operators. GAs compose one of the most popular meta-heuristics applied to the Portfolio Optimization Problem ( [12]).
As a very effective and efficient way to address MOPs, the authors of ( [25]) exploited the idea of creating subproblems underlying the original optimization problem. This way, addressing these subproblems the algorithm proposed in ( [25]) indirectly addresses the original problem. In that work, the so-called Multiobjective Evolutionary Algorithm Based on Decomposition (MOEA/D) was presented. The goal of MOEA/D is to create subproblems such that, for each subproblem, a simpler optimization problem can be more effectively and efficiently addressed; each subproblem consists on the aggregation of all the objectives through a scalar function. MOEA/D was extended to the context of interval numbers in [12].

Literature Review
There are many contributions to portfolio management literature in recent years. In this section, we give an overview of some recent and relevant works on the following subjects: price forecasting, stock selection and portfolio optimization, as well as works on portfolio management by algorithms that exploits both uptrends and downtrends in stock prices.
Due to the non-linearity of stock data, a model developed using traditional approaches with single intelligent techniques may not use the resources in an effective way. Therefore, there is a need for developing a hybridization of intelligent techniques for an effective predictive model [26].

Portfolio Management: Price Forecasting, Stock Selection and Portfolio Optimization
In recent years, there have been plenty of contributions on price forecasting based on either statistical or computational intelligence methods (see [10,27]). The stock market is characterized by extreme fluctuations, non-linearity, and shifts in internal and external environmental variables. Artificial intelligence techniques can detect such non-linearity, resulting in much-improved forecast results [28].
According to [12], the investor or decision maker in the portfolio selection problem manages a multiple criteria problem in which, along with the objective of return maximization, he/she faces the uncertainty of risk. Different attitudes assumed by decision makers may lead them to select different alternatives. A way of modeling both risk and subjectivity of the decision maker in terms of significant confidence intervals was first proposed in [12]. The probabilistic confidence intervals of the portfolio returns characterize the portfolios during the optimization. The optimization is performed by means of a widely accepted decomposition-based evolutionary algorithm, the MOEA/D ( [25,66]). This approach is inspired on the independent works of ( [67,68]) on interval analysis theory.

Exploiting Uptrends and Downtrends in Strategies for Stock Investment
Regarding alternative strategies to the known buy-and-hold approach for stock investment, in ( [69]), the authors propose two new trading strategies to outperform the buy-and-hold approach, which is based on the efficient market hypothesis. The proposed strategies are based on a generalized time-dependent strategy proposed in ( [70]) but propose different timing for changing the buying/selling position. According to ( [71]), the decision to adopt a long or short position in an asset requires a view of its immediate future price movements. A typical short seller would have to assess the potential future behavior of the asset price by means of evaluating several factors, such as past returns and market effects as well as and technical indicators, such as market ratios ( [71]). There are a few works published in the literature to address the problem of trading strategies for the short position. An interesting work that considers not only the short position but both the short and long position is ( [72]), in which a simultaneous long-short trading strategy (SLS) is proposed. Such a strategy is based partially on the property that a positive gain with zero initial investment is expected, which holds for all discrete and continuous price processes with independent multiplicative growth and a constant trend. Other works based on SLS are ( [73][74][75]). However, these works show the results of the algorithm on a previously defined stock portfolio, unlike the proposed approach that comprehensively performs price forecasting, stock selection and portfolio optimization in the presence of both uptrends and downtrends.

Methods and Materials
The procedure followed here consists of applying several techniques from the so-called computational intelligence to address the complexity of stock investments in the presence of both increasing and decreasing prices. Future stock prices are forecasted using an ANN, as well as the tendency that such prices will show. These estimations are then combined with certain indicators from the fundamental analysis to define the stocks that will likely receive resources (the selected stocks). Finally, another evolutionary algorithm is used to optimize portfolios, i.e., to define the proportions of resources to be allocated to each stock.

An Artificial Neural Network to Estimate Future Prices
In this work, the immediate next period price of the considered stocks are estimated by means of an ANN. Following the recommendations of ([6,10,36]), we use a single-layer feedforward network (whose setting is created once per each stock) and train the ANN by means of the so-called extreme learning machine algorithm because of its superior capacities in similar problems to the one addressed here (cf. [7][8][9]).
The ANN works independently per stock to estimate its price in the subsequent immediate period. The return of each stock is used as the target variable, while thirteen variables are used as input to train the ANN. Let r t denote the stock return for a given period t. r t is calculated from the stock price for that period (p t ) and the immediate previous one (p t−1 ), as defined by Equation (1).
The high complexity involved in forecasting future stock prices requires one to consider a variety of transaction data as explanatory variables. Therefore, we followed the recommendations provided in ( [10,76,77]) to determine sixteen transaction data as explanatory variables to the forecasting model used here. The sixteen input variables are described as follows: Close price. Last transacted price of the stock before the market officially closes. Open Price. First price of the stock at which it was traded at the open of the period's trading. High. Highest price of the stock in the period's trading. Low. Lowest price of the stock in the period's trading. Average Price. Average price of the stock in the period's trading. Market Capitalization. Price per share multiplied by the number of outstanding shares of a publicly held company. Return Rate. Profit on an investment over a period, expressed as a proportion of the original investment. Volume. Number of shares traded (or their equivalent in money) of a stock in a given period. Total asset turnover. Net sales over the average value of total assets on the company's balance sheet between the beginning and the end of the period. Fixed asset turnover. Net sales over the average value of fixed assets. Volatility. Standard deviation of prices. General Capital. Number of preferred and common shares that a company is authorized to issue. Price to Earnings. Market value per share over earnings per share. Price to Book. Market price per share over book value per share. Price to Sales. Market price per share over revenue per share.
Price to Cash Flow. Market price per share over operating cash flow per share.
The training process consists of taking sixty historical values for these sixteen variables randomly out of a set of ninety historical periods and leaving the rest of values to test the ANN. After the ANN is trained, two errors are computed: training error and testing error. The lower the testing error, the better the predictive capacity the ANN has. Nevertheless, since the extreme learning machine algorithm uses a random procedure to compute the weights and bias of the network, we do not always obtain the same results. Therefore, we run the algorithm n a times and chose the one with better results. It is important to highlight that each input variable is normalized taking into account the sixty periods of the training data (the target variable is not normalized).
As mentioned before, our approach seeks to take advantage of market downtrends. To achieve this, we use the ANN's forecast. A long or a short position will be chosen according to the forecasted value of the return; that is, if the forecasted value for a stock return is positive, a long position is chosen, otherwise a short position is chosen

Evolutionary Algorithms to Select Stocks
It is common that practitioners use indicators from the so-called fundamental analysis to assess the financial health of stocks. Besides these indicators, here, we use the stock prices and tendencies forecasted by the ANN to define which stocks should be further considered for investment. To ponder all these values, we establish an optimization problem following the recommendations in ( [78]) and use an evolutionary algorithm to address it as recommended in ( [10]).
Let S = {s 1 , s 2 , . . . , card(S)} be the set of considered stocks, v j (s i ) be the evaluation of stock s i on the jth indicator, j = 1, . . . , N (for the sake of simplicity, assume that v 1 is the forecasted return as calculated by Equation (1)), and w i be the relative importance of each indicator and forecasted return (the latter is denoted by w 1 ). The score of stock s i can be calculated as follows (cf. [10,79]): Since increasing v j (s i ) for j = 1, . . . , N indicates the convenience of the stock, determining the most appropriate values for w j becomes crucial to determining the most plausible stocks as those that maximize Equation (2).
If we want to take advantage of market downtrends, sometimes we will be interested in obtaining the more negative returns to invest in a short position. To implement this idea, the value of each factor v j is taken as positive or negative according to the prediction given by the ANN model on the previous stage. Namely, if the ANN model predicts a positive stock return, a long position will be chosen for this stock and the factor values are taken as they are. However, if the ANN model predicts a negative stock return, a short position is chosen for this stock and the return and each factor value are multiplied by −1, so Equation (2) is still valid.
To determine the most convenient values for w j (j = 1, . . . , N), we use the function recommended in ( [78]). Let us define this function.
For a given historical period t, a set of predefined weights will allow one to determine the score of each stock; thus, the top, say, 5% of the stocks can be selected. These top stocks constitute the set of "selected" stocks, and the rest constitute the set of "non-selected" stocks for period t. Let R t selected and R t non−selected be the average returns of the stocks in these sets (as calculated by Equation (1)), respectively. The convenience of the predefined weights is then calculated as the arithmetic difference between the average returns of the selected and non-selected stocks that they produce, that is: where T is the number of historical returns used to assess the weights in W, W = [w 1 , w 2 , . . . , w N ] and ξ(W) is the convenience of the weights in W.
As was stated in Section 2.4, the differential evolution (DE) algorithm has been found to be highly effective in non-linear mono-objective optimization problems, especially in problems related to financial problems ( [11,23,24]); therefore, this type of algorithm represents serious advantages over other optimization algorithms, particularly over other meta-heuristics. We use here a basic version of the DE algorithm as presented by Algoritm 1 in ( [80]). Let us describe this algorithm.
To determine the best values for w j (i = 1, . . . , N), the decision variables considered by the DE will be the values w j such that each individual in the DE will contain the values for w j fulfilling the constraints of the problem: w j ≥ 0 and ∑ N j=1 w j = 1. Lines 1-8 of Algorithm 1 randomly initialize the population of the DE; that is, the lines initialize feasible individuals by placing them in a random position within the search space. 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 ∈ [0, 1], a differential weight, F ∈ [0, 2], and a number of individuals in the population, population size ≥ 4. Each individual in the population is represented by a real-valued vector z = [z 1 , z 2 , . . . , z N ] , where z j is the value assigned to the jth 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. z k ← z k /sum (k = 1, 2, . . . , N) 7: P ← P ∪ {z} 8: end while 9: j ← 1 10: while (j ≤ N iterations ) do 11: for all (z ∈ P) do 12: Randomly, define a, b, c ∈ P, such that z, a, b, c are all different 13: Randomly, define r ∈ {1, . . . , N} 14: for all (i ∈ {1, . . . , N}) do 15: Randomly, define u ∈ [0, 1] 16: If ξ(z) ≤ ξ(y), then replace z for y in P (see Equation (3)) 21: end for 22: end while 23: Select the individual z ∈ P with the highest value ξ(z); this individual represents the best set of weights w 1 , w 2 , . . . , w N for Equation (2).
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.

Optimizing Stock Portfolios
The final activity to perform stock investments consists of determining how the resources should be allocated. A given distribution of resources among the selected stocks is known as the stock portfolio. Defining the most convenient distribution of resources is known as portfolio optimization. In this final activity, the decision alternatives are no longer individual stocks but complete portfolios. Thus, it is necessary to determine multiple criteria to comprehensively assess portfolios.
Formally, a stock portfolio is a vector x = [x 1 , x 2 , . . . , x m ] such that x i is the proportion of the total investment that is allocated to the ith stock. Let r i be the return of the ith stock calculated according to Equation (1); the return of a given portfolio x is defined as follows: Of course, if we knew the t + 1 return of the stocks, we could allocate resources that maximize R(x) without uncertainty; however, since this is impossible, the multiple criteria used to assess portfolios are estimations of R(x). These estimations usually come from probability theory.
According to ( [12]), the most convenient portfolio x can be determined by optimizing a set of confidence intervals that describe the probabilistic distribution of the portfolio's return: Maximize is the expected return of portfolio x, P(ω) is the probability that event ω occurs and Ω is the set of feasible portfolios. Maximizing confidence intervals as conducted in Equation (5) does not mean increasing the wideness of the intervals; rather, it refers to the intuition that rightmost returns in the probability distribution are desired. We use the so-called interval theory ( [68]) to measure the possibility that a confidence interval is greater than another one. In interval theory, an interval number allows one to encompass the uncertainty involved in the definition of a quantity.
Since we are trying to find the best portfolios in terms of confidence intervals around their expected return, intervals further to the right are better (rather than comparing intervals in terms of their width). Therefore, the comparison method used must provide this feature. There are several works in the literature describing methods that possess this property (e.g., [81,82]); however, the method proposed in [83] is the most broadly mentioned in the literature [84].
The authors of [83] presented a possibility function to define the order between two interval numbers that has been increasingly used in the literature (e.g., [12,[85][86][87]). Let I = [i − , i + ] and J = [j − , j + ] be two interval numbers, and the possibility function presented in [83] is defined as follows: Since Problem (5) can potentially have many objectives defined as interval numbers as well as multiple constraints, we use MOEA/D (see Section 2.4), as advised by ([12]). In ( [12]), MOEA/D was adapted to deal with these types of objectives; the adaptation has been proven to provide good results in contexts related to stock investments. For reasons of space in this paper, the reader is referred to ( [12]) for specific details about this improvement to MOEA/D.

Experiments
The hypothesis that a procedure that comprehensively addresses the practitioners' main activities while also considering uptrends and downtrends produce better total earnings for the investor than when not doing it is tested by using extensive experiments with actual historical data.

Experimental Design
We used well-known data for our experiments; the historical prices and financial information about the stocks within the Standard and Poor's 500 (S&P500) index. The officially reported financial information was used to build criterion performances.
Data from some of the most recent ninety months were used as input in the experiments, i.e., from November 2013 to April 2021. This dataset contains both uptrends and downtrends, so it is convenient for the kind of tests performed here. From these periods, sixty are used to prepare (say, train) the algorithms, and the rest are used to assess the approach performance in a window-sliding manner. For example, the information on November 2013-October 2018 is used to determine the investments that should be carried out at the beginning of November 2018, and these investments are maintained the whole month. Then, the performance of the approach (i.e., the returns) is calculated at the end of November 2018 using Equation (4). Such a performance is compared to the benchmarks in that period. Later, the investments are neglected, and, independently, the lapse is slid one period; thus, now, the information of the sixty months-December 2013-November 2018-is used to determine the investments for December 2018, where the new approach performance is calculated and compared to the benchmarks. This procedure is repeated thirty times; so, the conclusions can shed light on the robustness and overall performance of the approach with a high degree of confidence.

Benchmarks
The Standard and Poor's 500 index is used to define the relative performance of the proposed approach. Stock indexes are often used by practitioners as benchmarks because they summarize valuable information regarding the main sectors of an economy. The S&P500 is perhaps the most well-known and used index; it aggregates information about the five hundred biggest publicly traded companies in the United States of America. Since we are making decisions considering information only from this index, comparing the performance of the proposed approach with it is fair. In addition to the S&P500 index, in order to validate our approach, we have included several benchmarks to measure the effectiveness of our proposal. These benchmarks are: the approach of ( [10]), the approach of ( [12]) and our approach without including downtrends.

Parameter Setting
The parameter values used by each of the techniques mentioned in Section 4 are defined here.
As explained above, the number of periods used to train the ANN for each stock is 60. The only hidden layer uses sixteen neurons. We observed in preliminary experiments that the ANN showed more efficiency when it uses the same number of neurons as inputs; the more neurons, the more unstable the ANN was and the fewer neurons, the less predictive capacity the ANN had. Each neuron of the ANN used the sigmoidal function as the activation function. The ANN was run n a = 50 times to train the ANN for each stock; finally, the ANN model with fewer testing errors was used to predict the return at time t + 1.
Regarding the selection of stocks, the DE defined to select the factor weights that maximize the objective function shown in Equation (3) uses common parameter values. The crossover probability was set to 0.9; the differential weight was set to 0.8; the population size was set to 200; the number of iterations was set to 100. After scoring and ranking the stocks, we only select the top 5% of all the stocks originally considered following the recommendations in [10].
Finally, the genetic algorithm used to address Problem (5) was described in detail in ( [12]), where it was based on the well-known MOEA/D and adapted to deal with parameter values defined as interval numbers. We use one hundred generations as the stopping criterion, two solutions as the maximum number of solutions replaced by each child solution, a probability of selecting parents only from the neighborhood (instead of the whole population) of 0.9, one hundred subproblems, and twenty weight vectors in the neighborhood of each weight vector. Two confidence intervals are considered by MOEA/D as objectives to be maximized (see Equation (5)): θ β 30 (x) and θ β 50 (x) according to the recommendations in ( [12]). The constraints considered by MOEA/D are x i ≥ 0 and ∑ x i = 1.
It is worth mentioning that the code for implementing the algorithms described here are original developments of the authors. The code was written in Matlab and Java and will be probably publicly presented in the form of a complete software system.

Results
The proposed approach uses components that exploit randomness to explore the search space. Here, we intend to discard the effects produced by such randomness by running our approach many times; particularly, each stochastic component runs twenty times for each of the thirty back-testing periods mentioned in Section 5.1. Doing it this way sheds light on the robustness of our approach and allows us to reach sound conclusions. By following the recommendations in [88], the performance of our approach is evaluated by using the quantiles Q 10 , Q 20 , Q 50 (median), Q 80 and Q 90 (see Figure 1). As is noted in [88], distribution solutions of stochastic optimization algorithms are often asymmetrical; hence by using quantiles, we could obtain more insights into our approaches. However, Figure 1 shows that, in our case, Q 50 and the mean are almost always overlapped. Furthermore, (Q 10 , Q 20 ) and (Q 80 , Q 90 ) are symmetrical with respect to the mean. This behavior indicate that the performance of our approach is practically normally distributed.
Therefore, in this study, the average returns of our approach is used to be compared with several benchmarks, as shown in Table 1 and Figure 2. For simplicity, the results are discussed hereafter as if the returns were not averages. In order to validate our approach, in this section, we have included several benchmarks to measure the effectiveness of our proposal. These benchmarks are: (a) the market index S&P500, (b) the approach of [10], (c) the approach of [12] and (d) our approach without including downtrends.
From Table 1 and Figure 2, we can see that, in terms of the expected value, the worst overall return was produced by investing according to the S&P500 index, while the best overall return was achieved by investing in a portfolio produced by the proposed approach that takes advantage of both positive and negative trends. Figure 2 shows that the portfolio that considers negative trends is almost always in the top two from all the approaches. Furthermore, the returns obtained using this approach show that this model is not affected by the downtrends in the market as the benchmarks, as seen in the fall of all approaches from Jan 2020 to Mar 2020. Remarkably, this behavior did not prevent the proposed approach from exploiting the clear overall uptrend produced from Apr. 2020 to Apr. 2021, as can be clearly seen in Table 1.   From Table 2, we can see that the proposed approach outperforms the benchmarks at the end of the thirty periods: the sum of returns is approximately 41% better than Yang et al. 2019 ([10]), 25% better than Solares et al. 2019 ([12]), 48% better than the one that only considers positive trends and more than 90% better than the market index. Moreover, the cumulative returns of our proposal is 63% better than Yang et al. 2019 ([10]), 35% better than Solares et al. 2019 ([12]), 75% better than the one that only considers positive trends and 141% better than the market index. This performance can be seen in Figures 3 and 4.
Both Figures 3 and 4 describe the evolution of the portfolio returns in an aggregate way throughout the whole time lapse (i.e., November 2018 to April 2021). However, Figure 3 shows this evolution from the perspective of the sums of the returns, while Figure 4 shows the cumulative returns. Both figures can be relevant to the practitioner. The former shows the overall performance of the approach without considering the exact period where the return was obtained, while Figure 4 allows one to ponder the impact of the period where such a return was obtained. Let us unfold the latter. Figure 4 shows the amount that the investor would obtain if he/she takes their investment in a given period. For instance, an investment of USD 1000 at the beginning of November 2018 using the proposed model would have become USD 992 (i.e., −0.80%) if the investor would have withdrawn the investment at the end of May 2019. However, if he/she continues until April 2021, the investment would have become USD 1952 (i.e., +95.28%). In this sense, it is clear that the proposed approach outperformed the benchmarks by creating a portfolio that includes long and short positions. This result shows the potential of our proposal, which could be improved in future approaches by including stocks from other indexes, more technical/fundamental variables, etc.
In both Figures, it can be seen that, for the first fourteen periods (November 2018 to December 2019), the market does not move significantly in any direction; however, for the remaining periods, the market starts both negative and positive trends. A higher final return achieved by our proposal indicates that it is taking advantage of these trends overall. These results also show that considering negative trends is crucial. The figures show that the final average return is better if negative trends are considered when building stock portfolios. Table 2. Sum of returns and cumulative returns. In the case of the algorithms, the return is averaged over twenty runs.

Sum of Returns
Cumulative Returns

S&P500 Index
Yang et al.
Solares et al.   According to Figure 2 and Table 1, the worst return obtained by our approach was in Dec 2018. This is also shown in Figure 4, where the detriment is caused by the higher negative return produced in this period. In that moment, the system decided to open long positions and allocate high proportions of investments to some stocks with bad actual returns. This was due to the good historical performance of such actions that indicated a good statistical behavior. Several external issues affect the performance of a stock in the market, such as the case of Nvidia corporation as reported in the news [89]. Thus, a way of improving the proposed system in the future is by considering criteria coming from the so-called sentiment analysis [90] that takes into consideration such factors.
On the other hand, as a way of measuring the performance of our proposal and comparing the results with some benchmarks, the Sharpe ratio r sharpe and Sortino ratio r sortino are used. These ratios are defined as where R p is the average portfolio return, R f is the best available risk-free security rate, σ p is the portfolio standard deviation and σ p,d is the portfolio standard deviation of the downside. These indexes measure the risk per return obtained in comparison with a riskfree asset. In particular, the Sharpe ratio describes how much return is received per unit of risk; meanwhile, the Sortino ratio describes how much return is received per unit of bad risk. Therefore, the higher these indexes are, the more convenient for investment the asset is. We have considered the Treasure Bond of USA a risk-free security, with a value of 3% of annual return. We also considered the Treasure Bond of USA as the minimal acceptance ratio (MAR) to compute the downside deviation. R p , σ p and σ p,d are taken from Table 1. Table 3 shows the Sharpe and Sortino ratios for the all the benchmarks and our proposal. According to the results, our proposal has the best performance for both indexes; overall, it has higher returns by considering the risk.

Conclusions
Building stock portfolios with high returns and low risk is a common challenge for researchers in the financial area. Usually, the most common practice is to select the more promising stocks according to several factors, such as financial information, news of the market and technical analysis. Several approaches that use computational intelligence algorithms have been proposed in the literature to deal with the overwhelming complexity of building a stock portfolio. Usually, these approaches consider up to three activities to build a portfolio: return forecasting, stock selection and portfolio optimization. These activities decide which stocks should be supported, as well as the proportions of the investment to be allocated to them, by comparing the historical and forecasted performance of potential stock investments. However, to the best of our knowledge, these approaches do not comprehensively address the three activities when considering downtrends in stock prices.
In this paper, a comprehensive approach to stock portfolio management is proposed; the approach includes stock price forecasting, stock selection and stock portfolio optimization while taking advantage of market downtrends.
Stock price forecasting is carried out through an artificial neural network (ANN) trained by the extreme learning machine (ELM) algorithm. Forecasting the price of a given stock allows the comprehensive approach to focus on uptrends or downtrends (i.e., going long or short, respectively) for that stock. Stock selection is modeled as an optimization problem that seeks to determine the most plausible stocks; thus, a differential evolution is exploited on the basis of the forecasted price and a set of factors of the so-called fundamental analysis. Finally, portfolio optimization is conducted through a genetic algorithm that uses confidence intervals of the portfolio returns to determine the best stock portfolio.
Using preliminary experimentation, we found that the ELM was better than other methods (ANN with back-propagation, random forest, support vector regression) at forecasting the trend of the stock price but not the best at forecasting stock returns. Therefore, more research should be conducted to discover better configurations of the ANN with ELM or to decide if the forecasting stage should be changed. However, further research on this, as well as on methods to increase the performance of the next stages of the comprehensive approach, is beyond the scope of this work, so the authors will address these issues in future works.
Regarding the assessment of the comprehensive approach, the obtained results show that stock selection and portfolio optimization stages make more profitable portfolios when negative trends of stocks are taken into account to take advantage of downtrends of the market (see Table 2 and Figures 3 and 4). Furthermore, the results show that not only a traditional benchmark, the Standard and Poor's 500 index, is outperformed by the proposed approach but also approaches that do not exploit negative market trends (e.g., [10,12]).
This research work could be improved by the following possible future directions: I A deeper study of the forecasting stage to test the performance of several AI methods by employing more data or different financial variables; II A deeper study on the selection stage to evaluate the performance of the system by employing different financial variables to build the stock portfolio; III A deeper study of the performance of the system by modifying different parameters in the optimization stage and comparing the results with other approaches; IV New experiments to show the robustness of the approach regarding (i) the number and type of alternatives in the universe of stocks, (ii) the number of selected stocks and (iii) the parameter values.