# Stock Portfolio Management in the Presence of Downtends Using Computational Intelligence
## 4 Methods and Materials
### 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).  
\[r_{t}=\frac{p_{t}-p_{t-1}}{p_{t-1}} \tag{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; 7; 6]) 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