Due to its suitable power to anticipate using Non-Linear forecasting methodologies, LSTM (Long Short-Term Memory) has changed the approach to time series prediction several folds. Process compatibilities of technical identifiers and various financial benchmarks that are defining financial decision-making in international markets are affecting Bangladesh Market as well. Issues like MACD and RSI as a technical investigator and financial ratio aspects of EPS and PE Ratio play an important role in the selection of assets in DSE. Given adequate training in line with intended functionality models, RNN has the potential to think through in a similar manner and the probable results are exhibited in this paper. Because of the Gated Structure, which refers to retaining important information and discarding irrelevant information through diminishing gradient and exploding gradient, LSTM has achieved significant advances in nonlinear forecasting that is based on human behavior. In this study, we compared two alternative portfolios that will be dependent on LSTMs future forecasting capabilities in terms of projecting the greatest potential output, which is demonstrated using Portfolio Optimization principles.
LSTM can handle time series problems using a feed forward network with fixed time windows (Gers et al., 2002). The job most closely connected with LSTM occurs inside the confines of training under a given data series, and this training forecasting relates to a future point of interest. Our traditional analysis of assets based on Current Ratio and EPS are dependent on the assets of NYSE in much better assigning views (HM Sami, 2021). It has been shown that LSTM has accurately anticipated human motion and predictive-ness in terms of their behavior influencing movement choices in congested areas (Alahi et al., 2016). Alahi et al. have effectively developed a behavioral track in terms of intelligent tracking systems that mimic human behavior and decision patterns in smart set-tings. Wang et al. Investing risk has been shown to be directly related to less financial knowledge, and better financial decisions always lead to better, profitable financial decisions (Wang et al., 2011).
Various technical indicators like MACD and RSI plays important role in financial assets behaviors in order to predict its future goals (Chong et al., 2008). Its also seen that highly volatile market such as FOREX market also performs under the boundary constraints of MACD indicators (Zida et al., 2013). There is evidence that in the United States and Germany, investors prefer local investments rather than foreign mixed portfolios (Kilka et al., 2000). Our research work will focus on an enlightened view of the statistical control process of portfolio asset selection and time series-based decision making through nonlinear methods. In our research, we would evaluate pure stock portfolios under the guide of picking them based on sound financial principles, and we would compare stocks using performance optima-zations to improve financial performance. Its seen that due to MACD parameters and RSI indexing process major stock index like DJI & NASDAQ performed well through financial indicators (Chong et al, 2013). In terms of the accuracy of nonlinear fore-casting and time series forecasting, deep reinforce-ment learning has been found to play an effective role in portfolio management. Thus, our paper would attempt to reduce the risk variance of investment by combining finance and stock with proper financial indications for long-only gains rather than pure statistical evidence for portfolio investment. This investigation process wills describe the following events (Pathiranage, 2021):
Creating a Stock Portfolio from Scratch –
(a) Each stock would be chosen on the basis of a strong financial ratio as proof for an investment recommendation within the context of EPS and PE Ratio.
(b) We will also choose stocks using MACD and RSI.
(c) The non-linear prediction process using LSTM shows that the best stocks perform well in the long-only investment method, so that in the case of judging the best stocks, the best port-folio returns are selected within a time period.
Literature Review
In the financial market, the most important factor is still financial knowledge and risk perception in the choice of assets for investment purposes (Aren et al., 2016). It has been discovered that when financial literacy improves, better human decisions are made. Since human thinking ability determines the overall investment outlook of market behavior (Caparrelli et al., 2004), it is better to simulate future asset price forecasts with bias factors based on the non-linear forecasting principle and combine the training asset selection option in LSTM. It can be observed that LSTM is the most successful choice of holistic feature selection when it comes to learning the pattern of choices depending on diverse scenarios. It is built on a dilated causal convolution network that seeks to learn multiple features that are entirely trait dependent and multi-dimensionality reduction associated with multi-conditional data, making nonlinear prediction successful (Shen et al., 2020). Its also being assessed in the context of multi-range and multi-level charac-teristics being utterly under predicted using fixed time intervals (Shen et al., 2020 and Alahi et al., 2016). For the price of commodities, LSTM also effectively predicts the price of gold (Livieris et al., 2020). The prediction model will be correlated with the very-fication of the linear regression of theming global indices (Cao et al., 2018; Livieris et al., 2020). Since the closed structure supports the feed forward network, the network model can learn appropriately and can make accurate predictions (Gers et al., 2002). LSTM is considered to be able to effectively predict the price of Bitcoin, and learning and training are the only features for making accurate predictions (Wu et al., 2018). For the purposes of the selection process, we will use favorable financial ratios as an indicative reference as well as MACD & RSI as favorable fin-ancial indicators for the asset selection (Chong et al., 2007; Chong et al., 2013). Ever since (Henry Mar-kowitz, 1952; Markowitz, 1992) proposed the heyday of decision making on asset selection and portfolio performance optimization (Chen, 1981 and Beaver, 1966), people have seen the important role of finan-cial ratios in asset selection. It has been observed that LSTM provides better predictability than ARIMA (Siami et al., 2018). Our predictability characteristics depend on several factors consistent with the financial dependence of the asset. This study will look at how we may use the K Nearest Neighbor algorithm to create asset choices (Chen et al., 2017; Sami, 2021). Bodies Principle of investing in stocks with low volatility still plays a crucial role for financial invest-ment (Bodie, 1995). It has been discovered that EPS ratios play a crucial influence in asset selection for investing (Lin et al., 2011). We are also going to use MACD to make a list of stock that will do better. Then we will figure out which stock has both better EPS and favorable MACD. The final volumetric analysis will be performed using RSI indexing using the similar market parameters of NYSE, as the Bangladesh economy is highly correlated with the economic solidarity of foreign markets (Hassan et al, 2008). Combined with non-linear methods, LSTM is believed to be able to make accurate and positive predictions about the future aspects of any growth model (Livieris et al., 2020). For the fruit fly algo-rithm process, LSTM effectively predicts location attributes (Peng et al., 2020). Therefore, this docu-ment focuses entirely on LSTM, which is used for asset pricing related to future forecasts and accuracy (Sami & Arif, 2021).
Theoretical Framework
K Nearest Neighbor Algorithm
It can be seen that the nearest neighbor algorithm K is very successful in locating the best group of emp-loyees for selection through defined quality settings (Sami, 2021). This study would also establish a colle-ction of high-quality facts that could be used as standards for identifying the finest equities to invest in.
Point of Interest
EPS - According to CFI (Corporate Finance Insti-tution) and main GAAP accounting standards, EPS is defined as the ratio of Net Income to Weighted Average Outstanding Shares.
MACD - There are two ways to ways to evaluate stock price. One is fundamental analysis and another is technical analysis. Moving Average Convergence Divergence (MACD) is technical analysis method for forecasting stock market.
PE Ratio - The P/E ratio aids investors in deter-mining a stocks market value in relation to its ear-nings. In a nutshell, the P/E ratio reflects how much the mark-et is prepared to pay for a company now based on its previous or projected profits. A high P/E ratio indicates that a stocks price is high in com-parison to its earnings and may be overpriced. A low P/E, on the contrary, may suggest that the present stock price is cheap in comparison to earnings.
MACD (Moving Average Convergence & Diver-gence)
Gerald Appel created the MACD, a trend-follow-ing momentum indicator that depicts the connect-ion between two price moving averages (normally the close). Technical analysis is linear functions that are based on past trading data.
MACD = 12-Period EMA − 26-Period EMA
One can choose from variety of price data com-position like opening price, high price, low price, closing price etc. MACD is the result of subtracting
the long exponential moving average (EMA) from the short one, which offers a buying signal when the MACD crosses from zero to above, and a selling signal when the MACD crosses from zero to below. Moving averages are used to create the MACD; the value is determined by subtracting the longer expon-enttial moving average (EMA) from the shorter EMA. Formula as follows:
Where:
t=today; y=yesterday; N=number of days in EMA; k=2÷(N+1) or smoothing constant.
RSI (Relative Strength Index)
The relative strength index (RSI) is a technical ana-lysis indicator that evaluates the size of recent price fluctuations to determine if a stock or other asset is overbought or oversold. Values of 70 or higher on the RSI, according to traditional interpretation and use, signal that an investment is becoming overbought or overpriced, and may be poised for a trend reversal or corrective drop in price. A signal of 30 or below on the RSI suggests that the market is oversold or undervalued.
The RSI usually tracks a stocks rise over the previous 20 days.
Based on the evidence from accounting standards guidelines, it was found that most earnings per share of the major stock indices were shown to be greater than 1. Leong et al. mentioned that, along with the supporting evidence from GARP accounting stan-dards, it can be seen that most of the major stock indices recommend earnings per share above 1 as a benchmark. Sami & Arif have evaluated to find out that simple consideration of financially stable assets is good enough for financial evaluation (Sami & Arif, 2021). But in case of DSE the stock volatilities are pretty high and the cyclical pattern keeps arising despite of market control hence various technical in-dication are also important factors for asset selection for portfolio.
Algorithm 1
Volume & Affordability of Sales
Novy Marx mentioned that if we select stocks based on their quality attributes and then as quality increa-ses, we can expect to increase the pay for high-quality stocks (Novy Marx, 2013). The basic technique sug-gests focusing on average-quality equities that are available at a discount and can be anticipated using market-determined movement patterns.
LSTM (Long Short-Term Memory)
LSTM is a neural network structure, mainly based on artificial recurrent neural network, which provides the exclusive right to predict the correct prediction phe-nomenon. Through its network structure, it gets the capacity to analyze data sequences. The entire LSTM public unit consists of a unit, an entry door, an exit door and a forgetting door (Jiang et al., 2017);
(a) The unit structure remembers the value structure instead of arbitrary time intervals.
(b) The flow of information into and out of the cell is controlled by gates.
The organization of LSTM is to achieve its best fai-lure solution by eliminating the gradient problem. The solution method is enabled by the constant flow of input across gradient LSTM units (Wu et al., 2018). In the case of nonlinear time series predictions in-volving vanilla RNN through back propagation, due to the calculation process and the participation of finite precision numbers (rounding errors), RNN continues to use gradients as missing or explosive basic feeds without changes (they tend to at zero) or infinite change (towards infinity). Generally, LSTM contains a forget gate, which allows you to sequen-tially ignore the error values propagating backward from the output layer and slowly cut them through the feed forward neural network through repetition (Siami et al., 2019). The loop only allows the LSTM to train those gradients whose weight updates seem to be valid for future value benchmarks (Alahi et al., 2016). Finally, the actual weight update reference and gradient growth indicate the propagation factor associated with the time series prediction based on any value of the training and test values in terms of precision.
Portfolio Optimization
Investment portfolio is the combination of different assets in different proportions as an investment Ina specific entity. It has been observed that, in contrast to the case where a single asset is used as an investment measure to obtain profit, which will define risk-return parity, in the case of the lowest level of risk, the best combination of assets is associated with the best profit ability. It is typically a selection pro-cess that uses the right investment tools in the right proportions to generate the best return and balances the measures of risk and return associated with investing (Baumann et al., 2012).
The overall profitability of the investment portfolio depends directly on the weighted distribution of the investment in each asset in the portfolio and the profitability defined for each of these assets according to the risk factor. The ideal return point should be the actual mix of return and risk, after which each addi-tional unit of return would bring more than one additional unit of risk, as Markowitz Portfolio Theory directly relates return and risk as proportional to each other. As the probability of risk decreases with the introduction of less returning assets into the portfolio, the ideal return point should be the actual mix of return and risk, after which each additional unit of return would bring more than one additional unit of risk (Layard et al., 2008). As a result, when we achieve the highest Sharpe ratio, we may maximize the portfolios effective return.
Research Process -
a) According to various online stock recommend-ation platforms, 100 stocks are randomly selec-ted as investment assets, for example:
www.fknol.com; www.businessinsider.com; www.investing.com; and www.fools.com
b) The closest K algorithm is used to select stocks within the given priority EPS and MACD re-commended by effective research.
c) The selected stock is then undergone through the RSI indexing process in order to check the volumetric approaches of the stock.
d) Apply LSTM as a non-linear prediction method to each selected population for the priority time range for training purposes and subsequent testing purposes, so that the effective prediction quality of LSTM can be suggested in terms of accuracy.
e) Associate well-performing stocks with their LSTM forecast prices in PyPortfolioOpt for portfolio optimization.
With reference to the value of the Sharpe ratio and the return on investment in the context of the returns of the portfolios to determine profitability.
Its more vital to determine the standard ratio for which the companies may have better or higher priced future value in order to choose stocks based on effective financial ratio as a boundary line for criteria. According to Chen & Shimerda, the financial ratio values should be limited to the following:
EPS >>>> AS High as Possible 1.0
In the preliminary study, xi may be used as reference values for EPS. This research employs the K Nearest Neighbor clustering technique to pick assets that are effectively nearest to the desired point of reference recommended by expert re-search and conventional accounting rules. Ux denotes the average point for EPS.
Algorithm 1
Arg-Min (SQRT|| xi – Ux||^2 + || yi – Uy|| ^ 2) = Minimum Point of Difference
As a result, the optimal asset will have the smallest gap between the intended asset features and the target assets.
Min (ABS (K (Xi, Yi) – K (Mod X, Mod Y)))
ABS stands for absolute value. K (xi, yi) denotes the weight characteristics of EPS for certain assets. K denotes the values associated with each variable.
Algorithm 2
The asset selection procedure is now complete based on the evaluated criteria. It is clear that, following the selection process, we must determine which asset would provide the greatest return on investment in the future. To make this procedure effective, we used a non-linear time series price forecast in conjunction with LSTM, which has the capacity to recall the re-quired information for predicting while ignoring unnecessary data. In order to make the stock selection process much more effective, this research tends to analyze each quarterly returns of financial ratios with its previous ones
LSTM (Long Short-Term Memory) -The LSTM is a customized RNN (Recurrent Neural Network) that can recall important and necessary information in-stead of irrelevant information. In general, the acti-vation function is the first step in the RNN process. The weighted sum of input is converted into an output from a node or nodes of a layer in the network using the activation function. The activation function is denoted by the symbol a<t>. The output function refers to the previous time steps output, which is based on the input x<t> and activation function a<t>, which is based on the input and activation function values of the previous time instance, x<t-1> and a<t-1>. Y<t> denotes the output based on the input at that particular time step x<t>. It is critical that all of the following options operate properly in order for the activation functions to create output successfully.
All of these parameters influence the RNN structure, which is utilized to produce the follow-ing outcomes:
The bias of the activation function is connected to the weight allocation of Wax for input and Waa for acti-vation function in the activation function. In the same way, for the output activity:
The resulting activation is linked to the output bias factor and Wya as the output allocated weights. For price prediction, it is related to bias and market factor g1, while g2 remains the activation functions that take effect one after the other. The recurrent network is effective because of all of these functions. As a result, the entire RNN unit is defined as:
Where each time steps motion enables successful training based on the provided data generated by the network. Each of these processes demonstrates the positive aspect of the prior asset price and its rela-tionship to the current asset price.
In order to train the informations to acquire app-ropriate information in response to situational deve-lopments, as many examples as possible would be incorporated in this feed forward neural network system. The RNN design selectively permits biased conditional methods to be entirely reliant on the training process. Because each stock is related to the market through beta, but also has its own performance capacity (Stosic et al., 2019), bias is the most impor-tant factor in price prediction. There are different gated structures in the LSTM process, such as the ones below. The RNN design selectively permits bia-sed conditional methods to be entirely reliant on the training process. Because each stock is related to the market through beta, but also has its own performance capacity (Stosic et al., 2019), bias is the most impor-tant factor in price prediction. There are different
gated structures in the LSTM process, such as the ones below:
In the RNN procedure, represent the gate notation. The update gate, relevance gate, forget gate, and out-put gate are all represented by the symbols above. As a result, the gates allow for the remembering of fea-tures for price prediction or the cutting off of data for price prediction. The following function illustrates how gates are connected:
The sigmoid function is shown here to conform with the requirements of gated construction, but the relay and soft max functions may also be incorporated in this equation with respect to the demand of the scenario. When it comes to creating predictions, each function has its own set of benefits and applications.
g(z) is an output of the sigmoid function that exists between [0,1].
Tanh inadvertently refers to the valued answer of g (z) from [-1, 1]. Finally, relu
The highest value between 0 and z that the recurrent neural network operation can achieve.
Application through LSTM
LSTM is discovered to have multiple gates inside the processing unit when used in conjunction with RNN. As a result, the goal of LSTM is to aid in the deve-lopment of effective evaluation and training revo-lutions that assists:
a) The right number of trainings to help you in projecting the desired value for future fore-casting.
b) The output values that would help the activation functions for future values are highlighted using RNN trimmed techniques to purposefully man-age the exploding gradient problem since RNN encounters both exploding gradient and vani-shing gradient problems.
RNN reduces the possibility of infinite by preserving a parallelism during the boundary line clipping pro-cess. While RNN is capable of solving the exploding gradient problem, it is incapable of solving the vani-shing gradient problem. When we examine the gated structure of the RNN unit in the LSTM, we can see that there are four gates in the unit. C-<t> has a pri-mary output function. Previous activation functions and current input are linked to relevance gates. The situational bias is introduced to make the primary output effective in conjunction with the activation functions, which can be softmax, relu, tanh, sigmoid, and so on.
The primary output associated with the update gate structure and the forget gate model will be added to previous output in the case of final out-put function c<t> in order to determine if any required infor-mation is supposed to be remembered or not in order to make the prediction process much more efficient. As a result of this gated feature, the vanishing gradient problem is eliminated.
Furthermore, this procedure makes the activation function for the following stage very efficient, because the activation function remembers which important information is necessary for the pre-diction process at each phase of the final output.
Relevance with Financial Forecasting - Because financial forecasting relies heavily on nonlinear movements, LSTM provides far more accurate forecasts than linear prediction approaches such as linear regression and the ARIMA process (Abediyi et al., 2013). Each stage of the pricing process is refe-renced against a set level of prior level prices. We have included the following number of observation phases in the study process:
Epochs for Loss Reduction –When the prior step supplies irrelevant information to the forward step in an RNN, the loss function is designated under the jurisdiction of loss occurrence during the training process. Here, we can see that if the main output begins with less loss than the final output, then the prior information should be used in the feed forward process.
Because LSTM prefers to accomplish the exact step of loss reduction through its gated structure method, the loss in reference to predictions has been decree-sed with successful training. With favorable data, the epoch of 75 has produced effective forecasts for the process to be successful, as shown in our expanded Epoch calculation.
Back propagation Method - The derivative of loss L with regard to matrix W must be updated in refer-ence to each time step in order to make the financial price forecasting issue suggestively good with res-pect to time-based propagations. It has been dis-covered that when the necessary information is up-dated and sent through the activation phases, the corresponding weights that will be applied for pre-dicting the price will be changed in each step.
It can be shown that by using LSTMs observation stages and feed forwarding mechanism, the loss fun-ction may be decreased over time for big datasets. If we practice taking the same number of training steps on smaller datasets, the loss does not become decree-sed. Furthermore, it has been observed that the losses are decreased positively with smaller datasets and shorter training steps.
Portfolio Optimization- A portfolio is a collection of assets that, when correctly integrated, include the following factors:
a) Appropriate Time for Investment
b) Appropriate Amount for Overall Investment
c) Putting the correct amount of money into each asset
Would yield the highest potential return on a finan-cial market investment. As a result, the expected portfolio return will be defined as follows:
E (Pr) = Wai * Rai + ………………. + Wan*
Ran refers to all of the assets in the portfolio, while n refers to the portfolios ultimate asset number. W stands for the portfolios weight, or how much of an investment contribution we made. The return of each individual item in the portfolio is represented by the letter R. The reason for reducing risk-free earnings in relation to getting a return from the portfolio is that risk-free earnings are already making an acceptable profit throughout all investment processes, so the actual profit accrues only when the portfolio return is greater than the risk-free rate and the return difference is greater than portfolio risk.
Sharpe Ratio > 1 ………… Acceptable Sharpe Ratio <= 1 ………. Unacceptable
The concept is related to a lower contribution mar-gin. The selected assets were therefore employed for financial performance and optimized performance within the boundaries of these.
We have gathered 100 stocks that have been consi-dered for investment-by-investment portals from an internet portal of proposals for the purpose of study. After using the K closest Neighbor clustering met-hod, it was discovered that a sample of 8 stocks with higher EPS values, lower PE ratios, positive MACD indicator and less than 70 as RSI indicator. With the list of assets that are required to be the best possible mix therefore within the boundary of volumetric suggestions, it has been determined that the follow-ing list maintains the best possible asset selection list while posing minimal risk.
Our research process also tends to evaluate the selected stocks in reference MACD & RSI Indicator, the resultants values are described below:
Our research analysis uses relative association where it speaks to say if more of data in close by days sug-gests good MACD indication or RSI indication.
It was discovered that LSTM has considerable effecti- vity in connection to error calculations for the fore-casting process when they are effectively going through a particular number of epoch steps in order to anticipate future prices for stocks of DSE. The LSTM method has been conducted through nume-rous epoch stages in our research procedure in order to conform to a common pattern of comparable num-ber epoch practices to decrease the loss calculation.
The graph above depicts the average loss accum-ulation that occurs throughout the LSTM training process. Because the loss count virtually becomes null after the 50-60th Epoch, the total number of epochs for stocks is set at 75 to speed up the cal-culation procedure.
The accuracy results for the stocks are detailed below in order to assess the accuracy by predicting for each individual stock.
LSTM provides accurate forecasts for stocks. Des-pite the fact that this study compared ARIMA, SVR, Random Forest Regression, Decision Tree Regre-ssion, and Adaboost Method against other price fore-casting methods. However, many research studies have shown that LSTM is by far the most successful forecasting method.
Portfolio Optimization Process
The basic stock portfolio generated the following results using Portfolio Optimizer. As a result of LS-TMs excellent recommendations about these com-panies and their future price projections, such gains were attainable. After the adjusted portfolio optima-zation three stocks remained anonymous and various other stocks turned the portfolio gainer.
Real prices are contrasted to properly anticipated prices in terms of stock allocations and actual stock gains vs predicted stock gains. In terms of anti-cipated pricing and resource allocation, the predicted portfolio is 95.72 percent accurate. The best potential assets were effectively identified by the projected portfolio using LSTM; however the asset allocation for the real and predicted portfolios were somewhat different. The revised Sharpe ratios show a little discrepancy between the anticipated and real port-folios of 17.29 and 17.63, respectively. Because financial predictors are always in use, the best pos-sible depiction of prices is taken into account for that given time period. The goal of this study was to
depict the market performance of a mixed portfolio and a pure stock portfolio in a strongly optimistic market environment, using the quarters of January, February, and March of 2021 as the testing period. Due to the great profitability of the general market, this study procedure was purposefully designed to see if statistical and nonlinear forecasting methods might make the investment process more effective than the general market return scenario.
The Sharpe ratio in this diversified portfolio is over 16.5, indicating that each stock made sustainable gaining of around 65% throughout this 9-month period. Although we can see that three different stocks were present in this portfolio was included in the portfolio, the quarter-year jump is less than 6%, hence portfolio optimization automatically reduced them from getting selected.
Drawbacks & Further Improvements
It can be seen that the overall initialization of stock selection is solely based on financial ratios and mar-ket factor indicators, but this study requires more data because there are nearly ten additional financial ratios that are important for stock classification and selec-tion. There are various statistical indicators such as EMA, MACD, and Bollinger bands that can be used as de facto investment indicators, but this process has become solely reliant on financial ratios, and only in EPS for investment purposes, which appears to be a narrow section for research preview. Furthermore, it was discovered that only LSTM was utilized in this study article to show the price predicting procedure based on ideas from previous studies. More study suggests that LSTM is the best approach, and its evidence should be successful in the investment based fore-casting procedure.
Profit earnings for pure stock portfolios are greater, despite the fact that the observed Sharpe ratio lower for pure stock portfolios. So, in terms of profit poten-tial, we should consider investing only in stocks suggested by LSTM and other criteria we have mentioned.
Because this research paper is heavily data-driven, all data providers and internet resources will be com-pletely reliant on the research papers success.
In relation to the research, writing, and publishing of this paper, the authors have disclosed no potential conflicts of interest.
Academic Editor
Dr. Wiyanti Fransisca Simanullang Assistant Professor Department of Chemical Engineering Universitas Katolik Widya Mandala Surabaya East Java, Indonesia.
Senior Lecturer, School of Business, Canadian University of Bangladesh Dhaka, Bangladesh.
Sami HM, Fardous L, and Ruhit DS. (2021). Portfolio optimization in DSE using financial indicators, LSTM & PyportfolioOpt, Int. J. Mat. Math. Sci., 3(4), 74-84.https://doi.org/10.34104/ijmms.021.074084