scieee AI-readable full text Open interactive document viewer

Stock Portfolio Management based on AI technology.

Ordieres-Meré, Joaquín; Moreno Alonso, Alejandro

Abstract

Forecasting stock performance is crucial for formulating a profitable trading approach aimed at achieving significant gains. In addition, prediction results serve as essential prerequisites for creating and optimizing active investment portfolios. However, predicting stock movements presents a formidable challenge due to the presence of various factors that contribute to uncertainty and instability. This paper introduces the use of a long- and short-term memory network to forecast stock movements by analyzing past data as a component to be used in portfolio optimization. To establish an effective investment portfolio, a hybrid portfolio optimization proposal is made to enhance portfolio performance while considering the diversification of assets through categories. The sensitivity of the proposed technique to the parameters is explored to understand the advantages and limitations of the different choices.

Full text

Received: Added at production Revised: Added at production Accepted: Added at production DOI: xxx/xxxx REGULAR MANUSCRIPT Stock Portfolio Management based on AI technology. Alejandro Moreno Alonso (0000-0002-8353-7596).1Joaquín Ordieres-Meré (0000-0002-9677-6764).2 1Universidad Pontificia de Comillas, C/ Alberto Aguilera 23, Madrid, 28015, Madrid, Spain 2Escuela Técnica Superior de Ingeniería Industrial, Universidad Politécnica de Madrid, C/ José Gutiérrez Abascal 2, 28006, Madrid, Spain Correspondence Corresponding author Joaquín Ordieres-Meré, C/ José Gutiérrez Abascal 2, 28006, Madrid. Email: [email protected] Abstract Forecasting stock performance is crucial for formulating a profitable trading approach aimed at achieving significant gains. In addition, prediction results serve as essential prerequisites for creating and optimizing active investment portfolios. However, predicting stock movements presents a formidable challenge due to the presence of various factors that contribute to uncertainty and instability. This paper introduces the use of a longand short-term memory network to forecast stock movements by analyzing past data as a component to be used in portfolio optimization. To establish an effective investment portfolio, a hybrid portfolio optimization proposal is made to enhance portfolio performance while considering the diversification of assets through categories. The sensitivity of the proposed technique to the parameters is explored to understand the advantages and limitations of the different choices. KEYWORDS Stock prediction; Portfolio management; Machine learning; Hybrid portfolio optimization; Sliding time window; Topic-oriented categories of assets. 1 INTRODUCTION. Portfolio is a set of financial assets consisting of various securities such as stocks, bonds, exchange-traded funds (ETF), real estate, cryptocurrency, alternative assets, and derivative products, held by a particular person or group (Akkaya, 2021). Therefore, a portfolio can be understood as a compilation of investment assets or stocks baskets, and portfolio management involves the process of making investment decisions based on customized tactical strategies to maximize returns for different investment time frames, through a cohesive investment strategy, timeline and risk tolerance (Ta et al., 2020). Two widely used strategies for overseeing investment portfolios are conventional and quantitative methodologies, both of which have seen the introduction of numerous techniques over the course of several decades. These strategies exhibit certain shared traits, including the examination of a restricted range of impactful variables that Journal of Forecasting 2024;00:1–23 wileyonlinelibrary.com/journal/ © 2024 Copyright Holder Name 1 2Moreno-Alonso A. et al. influence the values of the stocks, the analysis of previous data to assess these variables, the establishment of criteria for selecting stocks and the ongoing evaluation of performance as time progresses (Yun et al., 2020). However, traditional portfolio management is heavily based on in-depth analysis, consideration of regime changes, key characteristics, and qualitative factors. In contrast, quantitative portfolio management emphasizes exploring a wider range of investment options, maintaining discipline, verifying strategies, managing risks, and seeking lower fees. Mathematical and statistical methods constitute a dominant part among the methods (Varga-Haszonits et al., 2016). Since mean variance analysis, the first modern portfolio management method that uses a mathematical and statistical approach, has been introduced, a variety of variants of the methods have been studied (Kalayci et al., 2019). Lately, machine learning (ML)-driven techniques have been increasingly regarded as substitutes and additions to traditional statistical methods. This shift is driven by the exceptional accuracy achieved through rapid advances in both machine learning and computational hardware. Haugen & Baker (1991) concisely proclaimed that matching the market is an inefficient investment strategy. These authors presented one of the first empirical studies of the minimum-variance portfolio. Their contention is that even under the assumption of rational investor behavior and optimization of risk-return equilibrium in an informationally efficient capital market, theory indicates that cap-weighted portfolios can still be deemed inefficient investments. Although some studies provide a framework for portfolio management based on prediction, these studies do not apply recent developments in prediction models, such as novel deep learning techniques and LSTM (Yun et al., 2020). Without a lack of generalization capabilities, in this work, portfolio components will be selected among stocks due to the relatively high frequency of price information available through the market, which makes it easy to optimize the involved decision-making process. Therefore, this work aims to introduce such a framework in an inductive way, based on the constructive methodology adopted. The justification for optimization needs is evidenced because there are three types of investors in financial markets: foreign (institutional), (domestic), institutional, and individual investors. Although several studies on trading performance have concluded that foreign and institutional investors perform better than individual investors (Agarwal et al., 2009; Bae et al., 2008). Cheong et al. (2017) argue that the stronger performance of foreign and institutional investors may be attributable to their access to optimal portfolios. Therefore, the application of a similar approach can significantly benefit individual investors, avoiding the use of volume levels as a significant indicator in stock markets. Whereas stock selection strategies strongly affect portfolio performance, investors aim to maximize their expected return while maintaining the risk bounded. In addition, in recent times the strategy can also include stress preferences that regulate type investment, such as environmental, social, and governance principles (ESG). Stock Portfolio Management based on AI technology. 3 For the evaluation of the methods, the indices of the stock market are commonly used. Since the indices are synthetic, they can hardly represent the actual buy/sell costs of a market. In this work, the sliding window configuration is adopted to provide a more effective way to evaluate procedures. The subsequent sections of the paper are organized in the following manner. Section 2 presents a brief review of relevant publications and justifies the novelty of the present work. Section 3 elaborates on the proposed method, including the framework that is being proposed. Section 4 explains the results obtained according to the method and the data selected in Section 3. Finally, Section 5 discusses the results, and Section 6 concludes with the global assessment, limitations, and proposals for future research. 2 STATE OF THE ART. As claimed in Henrique et al. (2019), due to the large number of variables that could potentially affect stock values, as well as unanticipated noise, forecasting stock markets is a difficult job. The Efficient Market Hypothesis (EMH) Fama (1970) and the Random Walk theory Malkiel (2003) state that market returns cannot be precisely predicted. This belief is based on the presumption that investors are rational and that everyone has access to all data from the public market. The EMH has been frequently challenged and different works by behavioral economists and econometricians Hsu et al. (2016); Rachev et al. (2002) have shown that there is reason to question this hypothesis, as shown by the development of consistently profitable factors based on market anomalies (Azevedo & Hoegner, 2022; Azevedo et al., 2023). Price evolution is a confluence of buyers and sellers whose economic decisions are driven by expectations. These expectations are not only rational, they are also built on personal beliefs, often faced with social influence. Since the 1990s, empirical data published by behavioral finance specialists have shown that investor psychology is what drives the stock market (Daniel et al., 1998). The capital asset pricing model (CAPM) has been subject to extensive scrutiny since its inception in the 1960s (Neslihanoglu et al., 2017). Specifically, the effectiveness of the market capitalization weighted index has been challenged, leading academics and professionals to propose various alternative investment options. Traditional models for predicting market behavior were those based on fundamental analysis (company evolution) or technical analysis (price evolution) (McMillan, 2016). The ongoing introduction of new models and concepts in this domain has played a crucial role in the advancement of modern financial theories. Complex networks, now widely used as analytical tools, have evolved notably in portfolio optimization in recent times, becoming increasingly sophisticated (Guerard Jr et al., 2015; Karathanasopoulos et al., 2017; Lin & Taamouti, 2024). 4Moreno-Alonso A. et al. In the context of optimal portfolio construction, research in the timber and forest sector demonstrates that incorporating Environmental, Social, and Governance (ESG) scores into investment strategies can achieve risk-adjusted returns comparable to traditional investments. This supports the feasibility of socially responsible investments in maintaining financial performance while promoting sustainability (Arreola Hernandez & Al Janabi, 2020; Lööf et al., 2023). Furthermore, studies in Latin America confirm that portfolios with high-ESG stocks outperform those with low-ESG or non-reporting companies, showcasing the benefits of ESG criteria in investment decision making (Useche et al., 2023). Portfolio management encompasses the tasks of choosing stocks to incorporate into a portfolio, determining the allocation of capital to each stock, and identifying the moments that require portfolio rebalancing. Throughout this process, it is crucial to take into account the investor’s risk tolerance, as certain investors are more open to assuming higher levels of risk in hopes of achieving potentially larger returns. In this work, the authors implicitly propose to adopt an active management strategy, which allows us to make decisions both on stocks and on the time to rebalance the portfolio. In recent years, several groundbreaking contributions have emerged in the field of stock portfolio optimization, incorporating advanced machine learning techniques and innovative algorithms. These contributions have significantly improved the precision and efficacy of stock market predictions and portfolio management. Academics strive to reconcile the dual objectives of maximizing returns and minimizing variance, which initially appear contradictory, in order to optimize diversified portfolios. They develop new models and estimation methods to enhance the Markowitz model. The application of network theory to portfolio research offers a fresh approach to solving asset selection challenges. In this framework, assets are viewed as nodes, and the relationships between assets form interconnected edges (Tumminello et al., 2005). One notable advancement is the mean Value-at-Risk (VaR) model combined with AdaBoost prediction, which has demonstrated superior performance in the optimization of the multi-national stock market portfolio compared to other machine learning regression models (Behera et al., 2023). This model improves the predictability and reliability of financial returns, providing investors with robust tools to manage multi-national portfolios. Another significant development is the use of longand short-term memory (LSTM) deep learning models (DL) to predict future stock prices with high precision. The method has been successfully applied to different sectors of the Indian stock market, offering convenient predictions that aid in optimizing portfolios of stocks (Sen et al., 2021). Similarly, according to Jang & Seong (2023), by integrating modern portfolio theory with deep reinforcement learning, it is possible to outperform traditional algorithms in terms of Sharpe ratio, annualized return and maximum Stock Portfolio Management based on AI technology. 5 drawdown (Dacorogna et al., 1999). This combination leverages the strengths of both theoretical and practical approaches to achieve optimal portfolio performance. However, portfolio optimization currently lacks the flexibility to create a parametric selection of stocks from diverse categories beyond their sectors, hindering the ability to assess performance under constraints related to diversification, adherence to ESG principles and other criteria. Therefore, this research aims to address these limitations and incorporate advanced forecast capabilities with advocating attributes such as the ability to regularly rebalance portfolio compositions. This approach seeks not only to address performance issues but also to accommodate dynamic changes in stock categorization across different categories. 3 DATA AND METHODOLOGY. In this section, the authors aim to present the value proposal for the adopted approach, which is based on a proposed conceptual framework enabling splitting the problem between the stock forecasting problem and the optimization at risk one. Taking into account the high transaction costs in practice and the limited capital and energy of investors, the number of assets included in the portfolio n is set to 3, 6 and 9, as an example. This allows us to analyze the performance of different portfolio configurations and thus select the most suitable number of investments. In fact, the proposed optimization algorithm is introduced as well as a dataset to provide an illustrative experiment. Then, the stock forecasting problem is introduced as an uncoupled problem but critical to enable independent optimization and rebalancing strategies. Framework Portfolio construction involves two main processes: asset selection and weight allocation. Regarding asset selection, Markowitz’s theory states that including negatively correlated assets enhances risk diversification (Lee et al., 2016). To assign quantities to selected assets, strategies based on the minimum-variance and mean-variance models are referential approaches (Clarke et al., 2006; Goktas & Duran, 2019). They are based on the compensation strategy that provides a degree of stability to the portfolio over time. Almost all approaches to optimizing a portfolio of stocks deal with these two coupled problems. Instead, the main contribution of this research is not to select individual assets, but to expand the concept of targeted asset to a category, depending on their sector or other aspects such as ESG performance. Then, the idea is 6Moreno-Alonso A. et al. to consider the variance to decide about weights, but in combination with the expected performance of these stocks, with some estimation of the computational uncertainty of the prediction while a minimum number of categories are required to build the portfolio. This aspect is very relevant since the selection not only looks for diversification like the variance principle, but also looks at considering the expected performance, which is more proactive (see Figure 2). ST-1Z ST-1X ST-1A CAT 1 ST-NZ ST-NX ST-NA CAT N ST-BT ST-DH ST-1Q PTF X Attributes | Correlations | Forecasts F I G U R E 1 Selection of portfolio assets considering categories, variance and expected performance. The proposed approach has the additional effect of enabling an uncoupled configuration, since the prediction of future evolution of stocks can be carried out at any time and with different models and techniques. The optimization of portfolios built over families of stocks can be independently assessed, and when necessary, a rebalancing proposal can be the result of an optimization process that also considered transaction costs (see Figure 2). Optimization algorithm. The optimization problem involves different subproblems. The first is related to the selection of stocks from different categories to set up the portfolio mix. The second is the rebalancing approach at discrete times according to the Stock Portfolio Management based on AI technology. 7 t0t1tktn Portfolio selection Portfolio assessment Portfolio assessment Portfolio closeup time Portfolio assessment Per sock in the portfolio: A) Assess its performance B) When underperforming below the expected averaged value. b.1) Evalute the next stock in the category with lower variance and higher expected return. b.2) Evaluate the new forecast against the revised forecast for the current stock and transaction costs. b.3) if b.2) is positive proceed rebalancing that stock. F I G U R E 2 Discrete rebalancing strategy. investment strategy selected by the owner of the portfolio. Finally, the last one, which can be done regularly and uncoupled from the two others is the regular forecast of the different stocks potentially targeted by the owner of the portfolio, since they are part of the different categories under consideration. Let us formulate these problems. The owner of the portfolio has selected the interesting groups of stocks according to his priorities, and each group is hereinafter named a category that depends on the owner’s criterion. In the following, it is assumed that there are Kcategories. That is, let Sbe the set of assets, where {S=∪K k=1Ck}. Obviously, different assets belong to different categories Ck. Formally, let us introduce the matrix Bto describe the relationship between assets and categories, such as Bij =     1if asset ibelongs to Cj 0otherwise The selection of assets looks is based on minimum-variance and maximize the expected return in the defined horizon of portfolio. Finally, it takes the sum of the assets’ weights to be one as a constraint and aims to find the optimal weight for the defined objectives. min –→ ω(–→ ωt∑ cov –→ ω–λ· card(S) ∑ i=1 ωir(i,tn)) s.t.                –→ ωt·–→ 1 = 1 r(i,tn) = 100 ·ln (Pi(tn) Pi(t0))∀i∈1, . . . ,card(S) |B–→ ω|0≥N (1) 8Moreno-Alonso A. et al. where Σcov represents the covariance matrix of the returns on assets when assets belong to different categories and one otherwise. card(S)is the cardinality of the portfolio (number of different assets); and Pi(t)represents the closing price of the asset iat time t.Trepresents the horizon for the planned investment portfolio, and N is the minimum acceptable diversification in categories of the portfolio measured by the norm L0. Finally, λ> 0 is a parameter that allows one to accommodate the relevance of variance and the range of benefits. If we consider the rebalancing subproblem, the formulation at time tsis presented in Eq. 2. min ––→ ωj(–→ ωjt∑ cov –→ ωj–λ· card(S) ∑ i=1 (ωj ir(i,tn) – TCj i(ts))) s.t.      –→ ωjt·–→ 1 = 1 |B–→ ωj|0≥N (2) where ωjrefers to the weight of the asset ibeing replaced in the portfolio by the asset jat time tswhere this asset still belongs to the same category kas i. The –→ ωjrepresents the whole set of portfolio weights where the asset iwas replaced by the asset j, both belonging to the same category, and TCj i(ts)represents the transition costs for the replacement of the asset j by the asset i at time ts.ϵrepresents the minimum threshold to avoid taking actions without enough motivation. Finally, the previous algorithms are supported by the need for an independent and robust estimate of the closing prices of assets at the selected time horizons ts∈t0,· · · ,tn. To facilitate this approach, this research was intended to use cutting-edge technologies from the machine learning area. As discussed in the state of the art, the most promising tools are related to the field of recurrent neural networks by using LSTM as well as to the Transformers, where multi-heading attention mechanisms can help to estimate trends based on the observation of historical evolution observed in the past. In this case, the problem can be operated at the stock level, after observing that a single general model performed worse than individual models per asset Candemir & Karahan (2024)). Therefore, additional effort has been made to model and understand the behaviors of these models to improve the estimation of r(ts). In 2017, a seminal paper Vaswani et al. (2017) introduced the Attention mechanism in LSTM, applied to the NLP domain. On the other hand, one of the first studies to suggest the use of an LSTM + Attention mechanism for multivariate prediction of time series is (Shih et al., 2019). H. Li et al. (2018) used a multi-input Attention LSTM to separate useful information from negatively associated elements and eliminate their noise. Qiu et al. (2020) used an Attention mechanism to de-noise historical stock data. Similarly, Y. Li et al. (2022) combined a transformer encoder and an Attention mechanism together with social media tweets to predict stock movements. Social networks are used only to select the most relevant stocks for the study. Stock Portfolio Management based on AI technology. 9 This experiment uses neural network Keras front end run on Google’s Tensorflow library using Python language to perform network implementation. To evaluate the predictive power of sentiment, we consider a persistence model as a benchmark and compare their results with LSTM, stacked-LSTM, bidirectional-LSTM, CNN-LSTM, AttentionLSTM and multivariate LSTM. We consider the predictive power through different forecasting horizons. Machine learning algorithms with memory features extend the forecasting capacity in a daily-weekly range according to Shah et al. (2019) works. We have experimented with different numbers of neurons as part of our hyperparameter tuning process. The aim was to find the optimal number of neurons that would result in a prediction model that is neither underor over-fitting the data. Bhandari et al. (2022) found that 100-50-20 neurons may be the most appropriate configuration for a 3-layer model, which is consistent with our work. According to Zhang et al. (2018), the number of hidden layers that minimize model error is 3. The different models use a sliding window of length 15, 25, 50 & 75 days to forecast 2, 8, 16, 30, 60 and 90 days ahead. MSE error of the models of the proposed models is calculated in the test set. All simulations have been repeated ten times, gauging the random set-up of weights and the random seed. The learning ability of the LSTM network is determined by the amount of neurons it contains. The batch size indicates how many input samples your LSTM should examine before changing the weights. Our LSTM univariate model involves 25, 50 & 75 hidden neurons in the hidden layer with a batch size of 500. Training the LSTM network involves selecting the training parameters: different window sizes: 15, 25, & 50 days. The activation function is ReLu and the optimizer selected is ADAM, while the mean square error (MSE) was selected as a loss function. To produce a significant number of tests with such a diverse set of configurations, a tool has been developed and made available on gitgub https://github.com/jordieres/Finance-AI. Unlike RNN, LSTM can preserve memory and state related to past activation rather than completely replacing it. They can retain characteristics for a long time thanks to the memory effect, which also makes it possible for backpropagation to occur across a number of constrained nonlinearities, reducing the risk that the gradient will vanish and allowing the RNN to learn the long-range dependencies across time steps. The rate of adjustments determines the gradient value. Its structure is well known: •The input gate controls how much of the new cell state should be retained. •The forget gate controls how much of the current memory should be forgotten. •The output gate controls how much of the cell state should be revealed to the network’s upper levels. 16 Moreno-Alonso A. et al. 0,00001 0,0001 0,001 0,01 0,1 1 0 5 10 15 20 25 30 35 40 45 12345678910 Simulation Number minCat NumIter Card(Stk) PredPerf Lambda Variance (a) Variance vs λ. 0 10 20 30 40 50 0 1 2 3 1 2 3 4 5 6 7 8 9 10 Simulation Number minCat Card(Stk) SR DD (b) SR & DD factors F I G U R E 5 Alternative configurations for a Portfolio. Each simulation corresponds to a different configuration of a Portfolio. The simulation numbers correspond to the same experiment on both Figures 5a and 5b for a numerical method in this small-scale experiment for simplicity. This method minimizes an objective function in a multidimensional space through a direct search, which is based on function comparison and is particularly useful for nonlinear optimization problems where derivatives are not readily available. However, the Nelder–Mead technique is a heuristic search method that can converge to non-stationary points in problems that can be solved by alternative methods (Gao & Han, 2012). Larger problems may require a tuning of the technique in use, depending of circumstances. However, grouping stocks into categories significantly reduces computational effort while increasing the conceptual meaning of investment decisions to be made. The experiments carried out are summarized in Figure 5, where each simulation corresponds to a different configuration. In Figure 5a the bar graphs are related to the left scale, as well as the predicted performance. Meanwhile, the variance and λcurves are related to the right units, represented on a natural logarithmic scale. In Figure 5b the performance portfolio evaluation metrics have been presented, operating against the right scale of the graph, while the bar graphs reflect the structure of the portfolio in terms of the categories required and finally used and are related to the left scale of the graph. In this way, the interpretation becomes clearer for the decision-making process. 5 DISCUSSION. The approach adopted to establish the configuration of the portfolio facilitates the consideration of different AIbased algorithms. In this work, we have implemented several recurrent neural network-based algorithms, such as lstm, stacked lstm, CNN with lstm and attention lstm. In addition, we have implemented different technologies, such as transformers with both individual and multidimensional dimension and multiple attention heads. The multidimensionality involved variables such as volatility, volume of operations, technical indicator RSI, sentiment for the asset from the general public and from specific operators, in addition to the future closing price. Such diversification Stock Portfolio Management based on AI technology. 17 in forecast algorithms brought additional insights, which evidenced that lstm models have a superior performance for short-term prediction (around 30 days), while transformers show greater stability in prediction. This behavior is not uniform across the assets, and every asset has its own behavior, which is an additional aspect where multiple modeling provides a good flexibility. When multidimensionality is considered, the improvement was lower than originally expected. The main reason for this behavior is the limited amount of data available, since we operate on a daily basis and, although we started collecting data when sentiment was initially recorded, the available data set includes nine years and a half, but when operating in such multidimensional space, the effect curse of dimensionality takes place (Poggio et al., 2017). The different simulations represented in Figure 5 correspond to different mixtures of stock selections, except the first, which is a portfolio selected by humans (baseline) where no optimization was performed. As a result, the optimization process did not require any iterations. Simulations 2 through 5 were conducted under the condition that the portfolio must contain at least three categories. In each successive simulation, the weight (λ) assigned to the expected performance relative to covariance was increased tenfold. It is evident that for very low values of λ, the variance between assets remains low. However, as λincreases, the correlation between assets increases over time. This increase in correlation can reduce the resilience of the portfolio, although it also enhances the expected performance ri(tn). The analysis of the information derived for the same simulations and shown in Figure 5b requires one to know that the barchars are related to the left scale and the curves are related to the right scale. It makes clear that the SR factor for portfolio configurations with higher number of categories involved are less productive but more diverse, while configurations with two categories allow proposals involving three categories effectively involved but SR is significantly high. On the other hand, simulations two and three show that the Drawdown factor is positive, which means that the highest effectiveness of the portfolio can be reached earlier than its expected life. The hybrid approach, which integrates asset covariance and expected performance with artificial intelligence techniques, emerges as a valuable tool. It offers a knowledge-based framework that is well suited for the portfolio configuration optimization technique employed in this paper. The ability to assess the portfolio across different time periods and re-optimize it as needed creates a robust environment for evaluating and adjusting the chosen strategy based on empirical evidence. This approach also allows estimation of uncertainties associated with the assets, providing an additional layer of information that can be used to mediate decision-making. 18 Moreno-Alonso A. et al. 6 CONCLUSIONS. In coherence with Behera et al. (2023) this paper confirms the power of combining the mean value-at-risk (VaR) model and AI-based prediction of asset evolution for portfolio optimization. In fact, this paper shows that technology supports not just the definition of the portfolio but also rebalancing during its life, including reconsideration of relative importance between individual criteria. Uncoupling the forecast of asset evolution from the optimization itself enables us to use different algorithms independently. Having different estimations from different techniques allows one to implement advanced techniques such as kernel density estimation (KDE) for the application of kernel smoothing, i.e., a nonparametric method to estimate the probability density function of a random variable based on kernels as weights. By this way, indirect estimation for uncertainty can be derived and it can be incorporated as moderator in the selection of assets for the portfolio. The sliding window revealed itself as a convenient approach that balances the historical time frame and variability, facilitating an agnostic understanding of the change over time. In this way, patterns can be normalized independently on the specific asset value, which facilitates learning the evolution of assets. Despite of the flexibility, there is a limitation when an asset has strong variations never seen before and exceeding what it was seen before. To mitigate such unexpected behavior, normalization preserves 5% of empty space, looking to tolerate these effects, and still having enough room to represent pattern variability. Another significant contribution is that assets can be structured according to different criteria driven by customer preferences, making it possible to enable optimization by constraining the minimum number of categories to be considered in the portfolio. This feature aligns well with the beliefs and principles of customers, while performance is still taken into account, as well as value at risk. More research is needed to accommodate sets of customer portfolio with a more stable and larger investment policies from larger operators, in particular when respecting specific customer beliefs, since additional opportunities can be better handled than just operating each portfolio as independent. In addition, further research to extend quantum optimization to the hybrid approach presented here is something to be explored. From a practical perspective, the adopted strategy to uncouple asset forecast and portfolio optimization significantly facilitates the computational effort, while portfolio optimization or portfolio rebalancing takes short effort and time, becoming a task that can be included in routine management activities. AUTHOR CONTRIBUTIONS The two authors have contributed equally to this article. Stock Portfolio Management based on AI technology. 19 ACKNOWLEDGMENTS The authors acknowledge the discussions that occurred within the CETIS PhD program seminars. They also acknowledge the great seminal work carried out by Mr. Víctor Vallejo Carmona within his bachelor thesis. Finally, they also want to thank the support of the Grant PID2022-137748OB-C31 funded by MCIN/AEI/10.13039/501100011033 and, by “ERDF A way of making Europe”, by the “European Union”. FINANCIAL DISCLOSURE This research was partially funded by the Spanish Agencia Estatal de Investigación through the Grant PID2022137748OB-C31 funded by MCIN/AEI/10.13039/501100011033 and, by “ERDF A way of making Europe”, by the “European Union”. CONFLICT OF INTEREST The authors declare that they have no potential conflict of interest. REFERENCES Agarwal, S., Faircloth, S., Liu, C., & Rhee, S. G. (2009, February). Why do foreign investors underperform domestic investors in trading activities? evidence from indonesia. Journal of Financial Markets,12(1), 32–53. Retrieved from https://doi.org/10.1016/j.finmar.2008.04.001 doi: 10.1016/j.finmar.2008.04.001 Akkaya, M. (2021). Behavioral portfolio theory. In Applying particle swarm optimization: New solutions and cases for optimized portfolios (pp. 29–48). Springer. Arreola Hernandez, J., & Al Janabi, M. A. (2020). Forecasting of dependence, market, and investment risks of a global index portfolio. Journal of Forecasting,39(3), 512–532. Azevedo, V., & Hoegner, C. (2022, August). Enhancing stock market anomalies with machine learning. Review of Quantitative Finance and Accounting,60(1), 195–230. Retrieved from https://doi.org/10.1007/s11156-022 -01099-z doi: 10.1007/s11156-022-01099-z Azevedo, V., Hoegner, C., & Velikov, M. (2023). The expected returns on machine-learning strategies. Available at SSRN. Bae, K.-H., Yamada, T., & Ito, K. (2008, January). How do individual, institutional, and foreign investors win and lose in equity trades? evidence from japan. International Review of Finance,6(3-4), 129–155. Retrieved from https://doi.org/10.1111/j.1468-2443.2007.00062.x doi: 10.1111/j.1468-2443.2007.00062.x Behera, J., Pasayat, A. K., Behera, H., & Kumar, P. (2023, April). Prediction based mean-value-at-risk portfolio optimization using machine learning regression algorithms for multi-national stock markets. Engineering Applications of Artificial Intelligence,120, 105843. Retrieved from http://dx.doi.org/10.1016/j.engappai.2023.105843 doi: 10.1016/j.engappai.2023.105843 20 Moreno-Alonso A. et al. Bhandari, H. N., Rimal, B., Pokhrel, N. R., Rimal, R., Dahal, K. R., & Khatri, R. K. (2022, 9). Predicting stock market index using LSTM. Machine Learning with Applications,9(May), 100320. Retrieved from https://doi.org/ 10.1016/j.mlwa.2022.100320https://linkinghub.elsevier.com/retrieve/pii/S2666827022000378 doi: 10.1016/j.mlwa.2022.100320 Bhowmik, R., & Wang, S. (2020). Stock market volatility and return analysis: A systematic literature review. Entropy,22(5), 522. Bordino, I., Battiston, S., Caldarelli, G., Cristelli, M., Ukkonen, A., & Weber, I. (2012). Web search queries can predict stock market volumes. PloS one,7(7), e40014. Candemir, I., & Karahan, C. C. (2024, May). Testing asset pricing models with individual stocks: An instrumental variables approach. Borsa Istanbul Review. Retrieved from http://dx.doi.org/10.1016/j.bir.2024.05.005 doi: 10.1016/j.bir.2024.05.005 Cheong, D., Kim, Y. M., Byun, H. W., Oh, K. J., & Kim, T. Y. (2017, December). Using genetic algorithm to support clustering-based portfolio optimization by investor information. Applied Soft Computing,61, 593–602. Retrieved from https://doi.org/10.1016/j.asoc.2017.08.042 doi: 10.1016/j.asoc.2017.08.042 Chowdhury, E. K., Dhar, B. K., & Stasi, A. (2022). Volatility of the us stock market and business strategy during covid-19. Business Strategy & Development,5(4), 350–360. Clarke, R., De Silva, H., & Thorley, S. (2006). Minimum-variance portfolios in the us equity market. Journal of Portfolio Management,33(1), 10. Dacorogna, M. M., Gencay, R., Müller, U. A., & Pictet, O. V. (1999). Effective return, risk aversion and drawdowns. SSRN Electronic Journal. Retrieved from http://dx.doi.org/10.2139/ssrn.162232 doi: 10.2139/ssrn.162232 Daniel, K., Hirshleifer, D., & Subrahmanyam, A. (1998, 12). Investor Psychology and Security Market Underand Overreactions. The Journal of Finance,53(6), 1839–1885. Retrieved from http://doi.wiley.com/10.1111/ 0022-1082.00077 doi: 10.1111/0022-1082.00077 Dash, R., & Dash, P. K. (2016). A hybrid stock trading framework integrating technical analysis with machine learning techniques. The Journal of Finance and Data Science,2(1), 42–57. Fama, E. F. (1970, 5). Efficient capital markets: A review of theory and empirical work. The Journal of Finance, 25(2), 383. Retrieved from https://www.jstor.org/stable/2325486?origin=crossref doi: 10.2307/2325486 Gao, F., & Han, L. (2012). Implementing the nelder-mead simplex algorithm with adaptive parameters. Computational Optimization and Applications,51(1), 259–277. Goktas, F., & Duran, A. (2019). A new possibilistic mean–variance model based on the principal components analysis: An application on the turkish holding stocks. Journal of Multiple-Valued Logic & Soft Computing,32. Guerard Jr, J. B., Markowitz, H., & Xu, G. (2015). Earnings forecasting in a global stock selection model and efficient portfolio construction and management. International Journal of Forecasting,31(2), 550–560. Haugen, R. A., & Baker, N. L. (1991). The efficient market inefficiency of capitalization–weighted stock portfolios. Stock Portfolio Management based on AI technology. 21 The journal of portfolio management,17(3), 35–40. Henrique, B. M., Sobreiro, V. A., & Kimura, H. (2019). Literature review: Machine learning techniques applied to financial market prediction. Expert Systems with Applications,124, 226–251. Retrieved from https://doi.org/ 10.1016/j.eswa.2019.01.012 doi: 10.1016/j.eswa.2019.01.012 Heston, S. L., & Sinha, N. R. (2016, 6). News versus Sentiment: Predicting Stock Returns from News Stories. Finance and Economics Discussion Series,2016(048), 1–35. doi: 10.17016/feds.2016.048 Hira, Z. M., & Gillies, D. F. (2015). A review of feature selection and feature extraction methods applied on microarray data. Advances in bioinformatics,2015(1), 198363. Hsu, M.-W., Lessmann, S., Sung, M.-C., Ma, T., & Johnson, J. E. (2016, 11). Bridging the divide in financial market forecasting: machine learners vs. financial economists. Expert Systems with Applications, 61(May), 215–234. Retrieved from https://linkinghub.elsevier.com/retrieve/pii/S0957417416302585 doi: 10.1016/j.eswa.2016.05.033 Jang, J., & Seong, N. (2023, May). Deep reinforcement learning for stock portfolio optimization by connecting with modern portfolio theory. Expert Systems with Applications,218, 119556. Retrieved from http://dx.doi.org/ 10.1016/j.eswa.2023.119556 doi: 10.1016/j.eswa.2023.119556 Kalayci, C. B., Ertenlice, O., & Akbay, M. A. (2019, July). A comprehensive review of deterministic models and applications for mean-variance portfolio optimization. Expert Systems with Applications,125, 345–368. doi: 10.1016/j.eswa.2019.02.011 Karathanasopoulos, A., Mitra, S., Skindilias, K., & Lo, C. C. (2017). Modelling and trading the english and german stock markets with novelty optimization techniques. Journal of Forecasting,36(8), 974–988. Lee, H.-S., Cheng, F.-F., & Chong, S.-C. (2016). Markowitz portfolio theory and capital asset pricing model for kuala lumpur stock exchange: A case revisited. International Journal of Economics and Financial Issues,6(3), 59–65. Li, H., Shen, Y., & Zhu, Y. (2018). Stock Price Prediction Using Attention-based Multi-Input LSTM. In Proceedings of machine learning research (Vol. 95, pp. 454–469). Li, Y., Lv, S., Liu, X., & Zhang, Q. (2022). Incorporating Transformers and Attention Networks for Stock Movement Prediction. Complexity,2022. doi: 10.1155/2022/7739087 Lin, W., & Taamouti, A. (2024). Portfolio selection under non-gaussianity and systemic risk: A machine learning based forecasting approach. International Journal of Forecasting,40(3), 1179–1188. Long, W., Lu, Z., & Cui, L. (2019, 1). Deep learning-based feature engineering for stock price movement prediction. Knowledge-Based Systems,164, 163–173. doi: 10.1016/j.knosys.2018.10.034 Lööf, H., Sahamkhadam, M., & Stephan, A. (2023). Incorporating esg into optimal stock portfolios for the global timber & forestry industry. Journal of Forest Economics,38(2), 133-157. Retrieved from http://dx.doi.org/ 10.1561/112.00000560 doi: 10.1561/112.00000560 Malkiel, B. G. (2003, 3). The efficient market hypothesis and its critics. Journal of Economic Perspectives, 22 Moreno-Alonso A. et al. 17(1), 59–82. Retrieved from https://www.aeaweb.org/articles.php?doi=10.1257/089533003321164958 doi: 10.1257/089533003321164958 Mao, Y., Wei, W., Wang, B., & Liu, B. (2012). Correlating S&P 500 stocks with Twitter data. In Proceedings of the first acm international workshop on hot topics on interdisciplinary social networks research - hotsocial ’12 (pp. 69–72). New York, New York, USA: ACM Press. Retrieved from http://dl.acm.org/citation.cfm?doid= 2392622.2392634 doi: 10.1145/2392622.2392634 McMillan, D. G. (2016). Which Variables Predict and Forecast Stock Market Returns? SSRN Electronic Journal, 44(June), 0–28. Retrieved from https://www.ssrn.com/abstract=2801670 doi: 10.2139/ssrn.2801670 Neslihanoglu, S., Sogiakas, V., McColl, J. H., & Lee, D. (2017). Nonlinearities in the capm: evidence from developed and emerging markets. Journal of Forecasting,36(8), 867–897. Poggio, T., Mhaskar, H., Rosasco, L., Miranda, B., & Liao, Q. (2017). Why and when can deep-but not shallownetworks avoid the curse of dimensionality: a review. International Journal of Automation and Computing,14(5), 503–519. Qiu, J., Wang, B., & Zhou, C. (2020). Forecasting stock prices with long-short term memory neural network based on attention mechanism. PLoS ONE,15(1), 1–15. doi: 10.1371/journal.pone.0227222 Rachev, S. T., Stoyanov, S. V., Biglova, A., Fabozzi, F. J., Lo, A. W., Mackinlay, A. C., … Brown, E. (2002, 9). A non-random walk down wall street. Journal of Economic Surveys,40(4), 269–281. Retrieved from http:// doi.wiley.com/10.1111/1467-6419.00091 doi: 10.1111/1467-6419.00091 Sen, J., Dutta, A., & Mehtab, S. (2021, October). Stock portfolio optimization using a deep learning lstm model. In 2021 ieee mysore sub section international conference (mysurucon) (pp. 263–271). IEEE. Retrieved from http://dx.doi.org/10.1109/MysuruCon52639.2021.9641662 doi: 10.1109/mysurucon52639.2021.9641662 Shah, D., Campbell, W., & Zulkernine, F. H. (2019). A comparative study of lstm and dnn for stock market forecasting. Proceedings - 2018 IEEE International Conference on Big Data, Big Data 2018,1(December), 4148– 4155. doi: 10.1109/BigData.2018.8622462 Shih, S. Y., Sun, F. K., & Lee, H. y. (2019). Temporal pattern attention for multivariate time series forecasting. Machine Learning,108(8-9), 1421–1441. Retrieved from https://doi.org/10.1007/s10994-019-05815-0 doi: 10.1007/s10994-019-05815-0 Souza, T. T. P., Kolchyna, O., Treleaven, P. C., Aste, T., Treleaven, P. C., & Aste, T. (2015, 7). Twitter Sentiment Analysis Applied to Finance: A Case Study in the Retail Industry. arXiv,1(July), 19. Retrieved from http://arxiv.org/abs/1507.00784http://www.mendeley.com/research/twitter-sentiment -analysis-applied-finance-case-study-retail-industry/ Swathi, T., Kasiviswanath, N., & Rao, A. A. (2022). An optimal deep learning-based lstm for stock price prediction using twitter sentiment analysis. Applied Intelligence,52(12), 13675–13688. Ta, V.-D., Liu, C.-M., & Tadesse, D. A. (2020). Portfolio optimization-based stock prediction using long-short term Stock Portfolio Management based on AI technology. 23 memory network in quantitative trading. Applied Sciences,10(2), 437. Tang, B., & Matteson, D. S. (2021). Probabilistic transformer for time series analysis. Advances in Neural Information Processing Systems,34, 23592–23608. Tumminello, M., Aste, T., Di Matteo, T., & Mantegna, R. N. (2005, July). A tool for filtering information in complex systems. Proceedings of the National Academy of Sciences,102(30), 10421–10426. Retrieved from http:// dx.doi.org/10.1073/pnas.0500298102 doi: 10.1073/pnas.0500298102 Useche, A. J., Martínez‐Ferrero, J., & Alayón‐Gonzales, J. L. (2023, October). Socially responsible portfolios, <scp>environmental, social, corporate governance (esg) efficient frontiers, and psychic dividends. Corporate Social Responsibility and Environmental Management,31(2), 1323–1339. Retrieved from http://dx.doi.org/10.1002/ csr.2635 doi: 10.1002/csr.2635 Valle-Cruz, D., Fernandez-Cortez, V., López-Chau, A., & Sandoval-Almazán, R. (2022). Does twitter affect stock market decisions? financial sentiment analysis during pandemics: A comparative study of the h1n1 and the covid-19 periods. Cognitive computation,14(1), 372–387. Varga-Haszonits, I., Caccioli, F., & Kondor, I. (2016, December). Replica approach to mean-variance portfolio optimization. Journal of Statistical Mechanics: Theory and Experiment,2016(12), 123404. doi: 10.1088/17425468/aa4f9c Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., … Polosukhin, I. (2017, 6). Attention is all you need. IEEE Industry Applications Magazine,8(1), 8–15. Retrieved from https://ieeexplore.ieee.org/ document/974352/http://arxiv.org/abs/1706.03762 doi: 10.1109/2943.974352 Yang, N., Fernandez-Perez, A., & Indriawan, I. (2022). The price impact of tweets: A high-frequency study. SSRN Electronic Journal. Retrieved from https://www.ssrn.com/abstract=4153783 doi: 10.2139/ssrn.4153783 Yun, H., Lee, M., Kang, Y. S., & Seok, J. (2020, April). Portfolio management via two-stage deep learning with a joint cost. Expert Systems with Applications,143, 113041. doi: 10.1016/j.eswa.2019.113041 Zeng, A., Chen, M., Zhang, L., & Xu, Q. (2023). Are transformers effective for time series forecasting? In Proceedings of the aaai conference on artificial intelligence (Vol. 37, pp. 11121–11128). Zhang, J., Wang, P., Yan, R., & Gao, R. X. (2018). Deep learning for improved system remaining life prediction. Procedia CIRP,72(January), 1033–1038. Retrieved from https://linkinghub.elsevier.com/retrieve/pii/ S2212827118304335 doi: 10.1016/j.procir.2018.03.262