Two-Stage Portfolio Optimization Integrating Optimal Sharp Ratio Measure and Ensemble Learning

The traditional portfolio theory has relied heavily on historical asset returns while ignoring future information. Based on ensemble learning and maximum Sharpe ratio portfolio theory, this paper proposes a two-stage portfolio optimization method by considering asset forecast information, aiming to improve the performance and robustness of a portfolio. In the first stage, concerning the underlying asset selection, we integrate six individual prediction models using the ensemble learning method to forecast the future return of assets where the assets with higher potential returns are selected for portfolio optimization. In the second stage, we propose a novel investment strategy by combining the forecasted returns of selected assets with the maximum Sharpe ratio portfolio model. In the empirical analysis, we employ the constituent stocks of the China Securities Index 300 (CSI 300) to test the out-of-sample performance of the proposed strategy with several traditional portfolio strategies, including minimum variance portfolio strategy, traditional maximum Sharpe ratio portfolio strategy, 1/N portfolio strategy, and CSI 300 index. Our analytical results show that (1) compared to individual forecasting models, the ensemble learning method is more accurate in forecasting stock returns, and (2) the proposed portfolio strategy largely outperforms most of its competitors in terms of the Sharpe ratio, Sortino ratio, Omega ratio, and Calmar ratio. This indicates that the proposed two-stage portfolio optimization method is of potential to construct a promising investment strategy due to its trade-off between historical and future information of assets.


I. INTRODUCTION
Since Markowitz [1] proposed the mean-variance (MV) portfolio theory, portfolio optimization has been one of the most popular topics in financial management. How to allocate assets effectively is a concern for scholars and investors. However, most relevant studies focus on the stage of optimal portfolio formation under the MV framework but ignore the pre-selection of stocks, which is the stage before optimal portfolio formation. Markowitz suggested ''do not put your The associate editor coordinating the review of this manuscript and approving it for publication was Mauro Tucci . eggs in one basket'', i.e., to reduce the portfolio risk by diversification effect. The mean-variance approach does not address the problem of determining the number of assets to invest in. Therefore, in terms of investment decisions, selecting high-quality assets in advance is very important for successful portfolio construction, and the obtained return of a portfolio from different asset selections has significant differences. For instance, Qi and Yen [2] employed the preselection strategy to select the assets with greater contribution to the Pareto frontier before constructing a portfolio. Their empirical results show that the proposed method with the pre-selection strategy is always closer to the Pareto frontier than the k-means strategy. Brito [3] applied the expected utility, entropy, and variance (EU-EV) model to select the promising stocks which can be used as a pre-selection model of mean-variance portfolio optimization problems, and their work reveals that the proposed stock selection model can build up efficient portfolios with a lower number of stocks.
However, these previous studies on asset pre-selection and portfolio optimization heavily rely on historical financial data of assets, e.g., focusing on transaction data, economic indicators, and technical indicators of assets [4]. In fact, the historical data cannot fully estimate the future return characteristics of these financial assets. With the development of machine learning and ensemble learning, in recent years, investors can forecast the future information of stocks (such as return and volatility), which can be incorporated into portfolio optimization and improve portfolio performance. Yu [5] used the radial basis function (RBF) neural networks to predict the returns of multiple assets, and employed these predicted results to solve the trade-off in the mean-varianceskewness (MVS) portfolio problem. Wang et al. [6] used Long Short Term Memory (LSTM) to predict stock returns to seek promising investment opportunities. Zhou et al. [7] adopted Support Vector Machines (SVM) to forecast the price movements of stocks, and combined them with the minimum variance model to construct a portfolio strategy. Summing up the above studies, one can find that the inclusion of forecasting information of assets tends to improve portfolio performance. Therefore, this paper aims to select high-quality assets from a large stock universe and construct a competitive portfolio with consideration of the forecasting information.
In the actual financial market, investors are interested in what is happening now, what is likely to happen to the returns and risks of assets, and what steps they should take to realize the optimal portfolio. Combing forecasting theory with portfolio selection may improve portfolio returns [8]. In particular, the expected return of the asset is a crucial factor in the portfolio optimization process [9]. Which is embodied in most classical portfolio theories, such as mean-variance, minimum variance, and maximum Sharpe ratio portfolios. At the same time, expected returns do not always reflect the actual return in the future. And the forecasted returns are also representative of the future return of the asset. Apart from this, we consider that forecast future returns of assets can be incorporated into pre-selection and portfolio construction.
Forecasting the future returns of assets is challenging due to the returns of financial assets are usually non-linear, dynamic, and complex. Currently, research on financial assets forecasting models mainly focuses on two main aspects: (i) traditional time series models (e.g., Auto Regressive Integrated Moving Average (ARIMA) and Generalized Auto Regressive Conditional Heteroskedasticity (GARCH)) [10], [11], (ii)machine learning models (e.g., Support Vector Machine (SVM), eXtreme Gradient Boosting (XGBoost), Light Gradient Boosting Machine (Light-GBM), and Long Short-Term Memory (LSTM)) [12], [13], [14], [15], [16], [17]. However, individual forecasting models may suffer from overtraining and overfitting problems, and these models may not be robust. In view of these problems, ensemble learning (EL) by integrating multiple single models has gained some popularity in financial asset forecasting. By combining various learning algorithms, ensemble learning forms committees to improve predictions (stacking and blending) or decrease variance (bagging) and bias (boosting), which is believed to perform better than single classifiers and regressors [18]. Ballings et al. [19] compared ensemble methods (i.e., random forest, AdaBoost, and kernel factory) with single classifier models (i.e., neural networks, logistic regression, SVM, and KNN) for forecasting stock direction changes. Their evidence indicates that the random forest model exhibits a superior performance than most models of consideration. Qi and Yen [2] combined XGBoost, Logistic Regression, and DNN with a linearly weighted method for default prediction and also obtained a favorable prediction result. Lu et al. [20] compared the performance of different forecasting models to predict oil futures risk volatility. The empirical results show that ensemble learning models tend to have better performance. Mohapatra et al. [21] developed ensemble machine learning models for predicting the stock returns of Indian banks using technical indicators. The empirical results also demonstrate that the ensemble learning models can improve the prediction accuracy compared to the single model.
Most of the traditional portfolio research ignores the selection of high-quality assets. Instead, they focus on how to improve the performance of the strategy. However, the preselection of high-quality assets is also a reliable guarantee for optimal portfolio formation. In addition, traditional portfolio theory tends to rely too much on expected returns and ignore future information, and with the development of machine learning and deep learning, predicting asset returns has become possible. In particular, we can obtain more accurate and robust predictions by integrating multiple single regressors using ensemble learning. However, most financial forecasting researches focus only on improving the predictive effect of asset returns, while ignoring applying their forecasting results to real investment markets, such as asset selection and portfolio, to give real investors more practical guidance. In fact, high accuracy does not mean the high performance of a portfolio. Therefore, how to combine the predicted information to construct an optimal investment portfolio strategy is a meaningful and promising research direction, which is exactly the problem this paper tries to solve.
Based on the above findings, the accuracy and robustness of the forecast are essential to determine whether the inclusions of the forecasted asset returns can improve the portfolio performance. When constructing a portfolio, it is necessary to make forecasts for a wide range of assets simultaneously, whereas most research use only a single forecasting model, perhaps leading to overfitting and overtraining. To tackle this problem, we integrate six individual prediction models by using three different ensemble learning methods to improve the accuracy and robustness of predictions. Further, given VOLUME 11, 2023 that the traditional portfolio theory tends to rely on expected returns estimated by historical return data while ignoring future information, we propose a novel portfolio optimization model that includes predicted returns, to achieve a trade-off between historical and future information of assets.
The purpose of this paper is to construct a portfolio optimization based on the asset returns forecasted by ensemble learning. We argue that a complete portfolio consists of two stages, where the first stage is the pre-selection of high-quality assets and the second stage is the determination of optimal weights for the portfolio. In the empirical part, we select the constituent stocks of CSI 300 to test for the capabilities of established and new methodologies alike. Specifically, taking the future returns of stocks as a vital factor when constructing a portfolio, we first propose a stock return forecasting model based on ensemble learning. The returns of these stocks on t + 1 are forecasted by using three ensemble models (i.e., linearly weighted method, equal weighted method, and Gradient Boosting Decision Tree) for six different single regression models (i.e., Support Vector Regression, eXtreme Gradient Boosting, Light Gradient Boosting Machine, Random Forest regression, Gradient Boosting Regression, and Long Short Term Memory model), respectively. Second, we use the forecasted returns to rank the daily stocks and select the top k stocks to invest in. Third, we combine the forecasted returns of selected stocks with the maximum Sharpe ratio portfolio theory to propose a new portfolio strategy. Finally, we perform an out-of-sample test for the proposed portfolio strategy and several traditional portfolio strategies and compare the impact of different forecasting models on the out-of-sample performance of the portfolio. The empirical results show that the proposed ensemble learning effectively forecast the future return of stocks and improve the robustness of predictions and portfolios. Furthermore, the proposed two-stage portfolio optimization strategy has a better performance than other strategies in terms of Sharpe ratio, Sortino ratio, Omega ratio, and Calmar ratio out of sample. More importantly, the above findings were further confirmed in the robustness test.
The remainder of this paper is as follows: Section II describes the models for forecasting (including six individual regression models and three different ensemble models) and then proposes the portfolio optimization strategy. Section III performs an out-of-sample test for the usefulness of the proposed approach. First, the future returns of stocks are forecasted by using the proposed ensemble learning models, whilst the forecasting performance of these models is compared. Then, we select the top-ranked stocks according to the forecasted returns of the best-performing model as the underlying assets to evaluate the out-of-sample performance of the proposed portfolio strategy and other traditional strategies. Finally, we perform a robustness test to verify the robustness of the model. Section IV summarizes the findings of this study and provides some practical suggestions for real investors.

II. METHODOLOGY
The proposed two-stage portfolio optimization consists of two parts. Namely, the first stage is stock selection, and the second is investment weight formulation. We must first forecast the future stock returns to construct the proposed portfolio optimization strategy. And based on the predicted returns, we can rank the stocks and construct the corresponding portfolio strategy. This section will describe the forecasting models and the proposed portfolio strategy.

A. MODELS FOR FORECASTING
The need to forecast a lot of stock return series requires the forecasting model to be simple and efficient. Thus, we choose six individual machine learning models which perform well and fast in financial time series forecasting for stock returns, which are Support Vector Regression (SVR), eXtreme Gradient Boosting (XGBoost), Light Gradient Boosting Machine (LightGBM), Random Forest regression (RF), Gradient Boosting Regression (GBR) and Long Short Term Memory model (LSTM). These models have achieved good performance in predicting stock and other financial time series [22], [23], [24], [25], [26], [27], [28], [29].
However, training each algorithm based on samples may lead to over-fitting problems, and we need to forecast a large number of stocks. To improve the accuracy and robustness of prediction, we introduce ensemble learning for stock forecasting. Ensemble learning is a machine learning method that uses multiple basic regression models to deal with the same problem. We choose SVR, XGBoost, LightGBM, RF, GBR, and LSTM as the weakly trained single regression. However, the above six single models were promoted to robust individual regression through the training of ensemble learning. Each model is trained separately on the training data, and then the ensemble model will determine the weight of every model based on its performance on the validation set. Finally, we will obtain a stronger regressor according to the determined weights. Moreover, the ensemble model can enhance the accuracy and robustness of prediction. We chose three ensemble methods to compare their performance in forecasting stock returns [15], [30].

1) LINEARLY WEIGHTED METHOD
The linearly weighted method is transparent, efficient, simple, and has superior performance for empirical application [31]. The formula is shown as follows: where w i is the weight of a single regression, w i > 0, w i = 1, and w i is determined by the mean absolute error (MAE) of the results for each model on the validation set. The higher the MAE of the model, the smaller the weight w i .

2) EQUAL WEIGHTED METHOD
The equal weighted method treats all single models equally, and we take the same weights for all models. The mathematical expression is expressed by where n is the number of single models and n > 0.

3) GRADIENT BOOSTING DECISION TREE
GBDT (Gradient Boosting Decision Tree) is a long-lasting model in machine learning. Its main idea is to use weak classifiers (decision trees) to iteratively train to get the optimal knot, which has the advantages of a good training effect and is not accessible to over-fit.
where h t (x) is the tth base learner for boosting, and α t is the parameter of tth base learner. The GBDT solution is based on forwarding iterations. The model of the t th iteration is optimized based on the model formed in the t − 1 iterations, which can be defined as: solving Eq. (4) is equivalent to minimizing the loss function L, and the loss function can be defined as: For datasets S = {x i , y i } N , and the corresponding objective function is L ({y i , F (x i )}), the negative gradient of the loss function of the ith sample at iteration t can be defined as: in order to reduce the loss function as fast as possible, at iteration t, we can update the target y t,i into the residual r t,i : Based on the obtained gradient descent direction, use the squared error to train a decision tree, fit the data {x i , y i } N .
then, use line search to find the best step for this direction search: therefore, the decision trees at iteration t can be re-expressed as: The final ensemble learner GBDT can be defined as:

B. THE PROPOSED PORTFOLIO OPTIMIZATION MODEL
After forecasting the stock returns, we can use the obtained predicted returns to rank the daily stocks and select stocks with high potential returns. Then the second task is investment weight formulation. The two-fund separation theorem states that the Markowitz classical mean-variance portfolio is the optimal combination of optimal tangency portfolio and risk-free assets, where the tangent portfolio is the maximum Sharpe ratio portfolio. Let R n denotes the vector of expected return, and r f denotes the risk-free return, x i denotes a vector of portfolio weights corresponding to the assets, and n denotes the covariance matrix of returns of the considered assets. The traditional maximum Sharpe ratio portfolio model can be described as follows: where the traditional maximum Sharpe ratio portfolio is estimated by √ x n x and R n . The problem is that the actual investment values of n and R n are unknown and have to estimate it. Letˆ n andR n represent the estimators of n and R n , e.g., the maximum likelihood estimators. With Equation (12) we can obtain thex. Since bothˆ n andR n are estimated values rather than true values, thex is also a random variable. However, in the practical investment, an estimated portfolio does not yield the maximum out-of-sample Sharpe ratio, sometimes even far apart from the real Sharpe ratio.
The existing portfolio models typically construct optimization objectives based on the return and risk of assets and then use historical returns as the sample to estimate the parameters of portfolios. However, the historical return characteristics of financial assets often do not reflect the future statistical characteristics of the underlying assets, making the out-of-sample performance often unsatisfactory [35], [36]. And forecasted stock returns are more reliable in some cases than expected returns which are estimated based on historical returns. Therefore, we combine the predicted stock return with the maximum Sharpe ratio portfolio theory to provide Investors with a novel portfolio strategy. The model is VOLUME 11, 2023 shown below: Here, R predict = (r 1 , r 2 , · · · , r n ) , and R predict is the forecast return. For convenience, the proposed portfolio strategy is denoted as x predict .
The proposed portfolio strategy combines forecasting information with the maximum Sharpe ratio portfolio theory. Considering the historical risk and the future return of stocks enables a trade-off between past and future performance, largely alleviating the previous strategy's over-reliance on the historical performance of the underlying assets.
To demonstrate the effectiveness of the proposed portfolio strategies, we introduce some classical portfolio strategies for comparison. First, disregarding return forecasts and focusing only on historical asset returns, we can construct the traditional maximum Sharpe ratio portfolio model as one of the benchmarks, for convenience, the maximum Sharpe ratio portfolio strategy and denoted as x max .
Then, according to [37], [38], and [39], the minimum variance portfolio usually has better out-of-sample performance than other mean-variance models. There we construct the minimum variance portfolio model as follows: (14) for convenience, the minimum variance portfolio strategy is denoted as x mv .
Also, we introduce the 1/N portfolio strategy for comparison with the proposed strategy, and the 1/N model is specified as follows: for convenience, the 1/N portfolio strategy is denoted as x ew , where I = (1, 1, · · · , 1) 1×n . In addition, this paper also introduces the CSI 300 index to represent the entire stock market and to compare it with the proposed portfolio strategies. For convenience, we give all the portfolio strategies considered and the corresponding abbreviations, as seen in Table 1. Therefore, the out-of-sample performance of each portfolio strategy can be evaluated by the following metrics. First, we introduce the Sharperatio as one of the metrics for evaluating the performance of different portfolio strategies, which is defined as: Var r p (16) whereĒ(r p ) represents the mean of out-of-sample returns for strategy p, and Var r p represents the out-of-sample variance, r f is the risk-free rate of return, and we assume r f = 0. Second, we introduce the Sortinoratio as one of the metrics for evaluating the performance of portfolio strategies. The Sortinoratio is defined as: Third, we introduce the Omega ratio as one of the metrics for evaluating the performance of portfolio strategies. The Omega ratio is defined as: where r represents the required return, which is used to distinguish between gains or losses. Return above the required return is considered a gain, and the part below the required return is considered a loss. Therefore, we consider the Calmarratio as one of the metrics for evaluating the performance of portfolio strategies. The Calmarratio is defined as: here,Ē(MDD) represents the expected maximum drawdown. Based on the above methodology, the framework of the proposed two-stage portfolio optimization model is shown in Fig. 1.

III. EMPIRICAL ANALYSIS A. DATA DESCRIPTIONS
We consider the constituent stocks of the CSI 300 index as our research subject. We select CSI 300 constituent stocks from 1 January 2020, to 30 June 2022, for our study. And we removed stocks with more than 5% missing data and those  that ceased to be listed during the period. We finally chose 168 stocks for this study. The specific stock information is in Table 2. Thus, we will collect historical stock trading data (including opening, closing, highest, lowest, and trading volume) for stock forecasting and portfolio optimization. These historical trading data can reflect stocks' historical performance and help us forecast stock returns and build portfolios.
In addition to historical trading data, technical indicators of stocks can be of great help when forecasting stock returns. Referring to [25], [40], [41], [42], [43], and [44], we use historical stock trading data and several technical indicators as inputs to the model. The technical indicators are the Stochastic Oscillator (KDJ), Relative Strength Index (RSI), and Moving Average Convergence and Divergence (MACD). We use these technical indicators such as A and B as effective characteristics to reflect financial markets. We can obtain these technical indicators by calculating the historical data of the stock. The formulas are as follows:

KDJ (K%)
: KDJ index is commonly used to analyze the short and medium-term trends of stock markets. We select the rapid indicator K value in the KDJ index for predicting stock returns. KDJ has a value between 0 and 100. Generally speaking, when the value is too high, it represents overbought, and when it is too low, it represents oversold. The formula for calculating K% is as follows:
MACD: It is a trend-following momentum indicator, a collection of three-time series calculated from historical prices, and shows the relationship between a fast and slow exponential moving average. It is commonly used to estimate the timing of buying and selling stocks. The formula of MACD is as follows (we set Fast = 12, Slow = 26,M = 9):

B. STOCK FORECASTING
Portfolio optimization is divided into two stages. The first stage is stock pre-selection (by predicting future stock returns through ensemble learning and selecting quality stocks from CSI 300 constituent stocks). The second stage combines the forecast results with traditional portfolio theory to construct portfolio optimization.
The first step in forecasting the future stock return is to select useful input indicators. Referring to [6] and [30], we use historical transaction data (opening price, closing price, highest price, lowest price, and trading volume), technical indicators (K%, RSI, and MACD), and the return of the stocks t days ago (t = 1, 2, 3, 4), all indicators are shown in Table 3. For stock i at time t the formula of return is defined as: Based on the above input indicators, First, we arrange the collected data in chronological order while normalizing the input data set and split the data from 1 January 2020, to 31 October 2021, as the training set, 1 November 2021, to 31 December 2021, as the validation set, and 1 January 2022 to 30 June 2022, as the test set. Second, we train the six single models (i.e., SVR, XGBoost, LightGBM, RF, GBR, and LSTM) using the data from the training set and validate the performance of the six single models with the data on the validation set. Third, based on the validation set results, the single models are integrated with three ensemble models, and the ensemble models will be trained and fitted using the training set and validated set. Therefore, we can finally obtain the return prediction on the test set.
To measure the results, we need some evaluation metrics. Referring to [41], we choose Mean Square Error (MSE), Root Mean Square Error (RMSE), Mean Absolute Error (MAE), and Hit Ratio (HR) as the evaluation metrics of the forecasting models. The specific calculation formula is given  as follows: where r i and r represent the actual return and predicted return of the ith stock at time t, respectively, n represents the number of samples, and if r i ·r i > 0, a i = 1, otherwise a i = 0. Table 4 shows the results of each forecasting model from 1 January 2022, to 30 June 2022, after parameter tuning.
The results show that the input indicators we selected can predict the stock's return well, the mean of RMSE of all models is below 0.025, and the mean of HR is higher than 50%. Moreover, the forecasting performance of the three ensemble models is better than the single regressions, and the linearly weighted ensemble model has the best performance in MAE, MSE, RMSE, or HR. The results show that the ensemble learning algorithm can improve future stock return forecasting accuracy and robustness. Furthermore, provide the basis for subsequent portfolio optimization. Table 5 shows the detailed performance of the linearly weighted ensemble mode: MAE, MSE, RMSE, and HR are 0.00494, 0.00005, 0.00673, and 0.61207 at the best performance, respectively, which means that for some stocks, the forecast results are very accurate. And Table 6 shows the results of each category of industry. It can be found that about one-third of the stocks belong to the manufacturing industry, while the forecast error of the manufacturing industry is a bit higher compared to other industries. Although only one stock belongs to agriculture, forestry, livestock farming, and VOLUME 11, 2023   fishery industry, its HR is the highest, reaching 58%. It is worth noting that indicators such as RMSE for real estate are the smallest in all categories of industry, which may be related to the almost constant rise in house prices in China.
Based on the obtained prediction results. We apply the predicted return of the best-performing linearly weighted ensemble model for stock pre-selection and out-of-sample testing in the following section.

C. STOCK PORTFOLIO OPTIMIZATION 1) STOCK PRE-SELECTION
We can select stocks to construct a diversified portfolio based on the predicted results. According to the forecast results of stock return, we rank the predicted returnsr i of stocks on day t + 1 and finally choose the top k stocks to invest. Most researchers suggest that individual investors should not and may not manage too many assets simultaneously [6], [7], [45], [46]. We assume that the investors should not hold more than ten assets simultaneously, then we choose that k ∈ { 3, 4, 5, 6, 7, 8, 9, 10} .

2) OUT-OF-SAMPLE TESTING
After selecting the higher quality stocks, the next step is making investment decisions among the selected stocks. We use the ''rolling sample'' approach mentioned by [35] to perform the out-of-sample test of the stock portfolio strategies. The test interval is from 1 January 2022, to 30 June 2022, total of 116 trading days. Furthermore, we assume the window length in the ''rolling sample'' is M . Let January 1, 2022, as the starting point (i.e., t = 1). The historical return data for M days before that point is used as the sample data for the benchmark, and we calculate the covariance matrix n between the selected high-quality stocks. Further, the portfolio strategies is derived. The corresponding portfolio return per holding period r p is calculated based on the realized return for the next trading period.
Similarly, when t = 2, we can update the stocks pool and covariance matrix n between stocks by using the return in the previous M days. In addition, the predicted returnr i and stock investment strategies can also be updated. Then, we can also calculate the portfolio return r p for the next trading day.
Using the rolling window method, we can obtain a series of 116 out-of-sample portfolio returns for each strategy. Therefore, based on the evaluation metrics, following [35], we assume that the window lengths M are 90, 120, 150, and 180, respectively. Then, we calculate the out-of-sample Sharpe ratio, Sortino ratio, Omega ratio, and Calmar ratio for each strategy. Meanwhile, we also compare the out-ofsample performance of different forecasting models. The corresponding results are shown in Table 7 -Table 14: When the window length M is 90, the results are shown in Table 7 and Table 8. In most cases, regardless of the value of, the proposed portfolio strategy x predict has a higher out-of-sample performance in the Sharpe ratio, Sortino ratio, Omega ratio, and Calmar ratio. According to the definition of k, we find that portfolio strategies perform better when k is small. In particular, when k = 3, all the investment strategies have the best performance in most cases. Meanwhile, most strategies outperform the CSI 300, indicating that the proposed stock pre-selection approach can improve the portfolio's return. In summary, with M = 90, the proposed portfolio strategy that incorporates return forecast information achieves the best out-of-sample performance in terms of Sharpe ratio, Sortino ratio, Omega ratio, and Calmar ratio. In particular, the best results are obtained when. Overall, whatever k is, in most cases, the proposed strategy x predict VOLUME 11, 2023  has a higher out-of-sample performance than other portfolio strategies and CSI 300 index. Table 8 represents the out-of-sample performance of the proposed linearly weighted ensemble model with different single forecasting models. In most cases, the proposed ensemble model outperforms the results of other forecasting models, except when k increase the results of LightGBM are better. But the proposed model always has the optimal outof-sample performance when k is small. The results show that the proposed linearly weighted ensemble model can improve the accuracy of forecasting future stock returns and enhance the effectiveness and robustness of the subsequent portfolio optimization compared to individual forecasting models. Table 9 - Table 14 show the results for different scrolling window lengths, and Table 15 shows the best results for all strategies. We can conclude with the following findings. In most cases, when k ∈ { 3, 4, 5, 6, 7, 8, 9, 10} , and M = 120, M = 150, or M = 180, and, all strategies outperform CSI 300 index. This further demonstrates the ability of the proposed stock pre-selection approach to enhance the portfolio's performance. From the results of Table 15, each portfolio performs best when k is 3, this is consistent with the findings of [46], indicating that investor should concentrate their wealth on a few stocks with investment value. Moreover, the proposed portfolio strategy always has a higher Sharpe ratio and Sortino ratio than other strategies and CSI 300 index, regardless of the window length M = 120, M = 150, or M = 180. This finding is consistent with the results in Table 7. The Omega ratio in Panel C further supports the conclusions obtained from the Sharpe ratio and Sortino ratio analysis. The Omega ratio of the proposed strategy is always higher than 1. Furthermore, the results of the Calmar ratio also indicate that the proposed portfolio strategy can achieve higher returns than other portfolios while controlling for drawdown risk.
Moreover, by comparing the performance of x predict and x max , the results suggest that R predict (the predicted return) plays a more significant role than R n (the expected return) in constructing a portfolio. As Table 10, Table 12, and  Table 14 shown, different forecasting models have a significant impact on the out-of-sample performance of the strategy. The results based on linearly weighted ensemble learning almost always outperform other single models in terms of  Sharpe ratio, Sortino ratio, Omega ratio, and Calmar ratio, showing that the proposed ensemble model can improve prediction accuracy as well as out-of-sample performance and robustness of portfolio. And this is consistent with the findings in Table 8.
Combining the results from Table 8 -Table 14, the proposed investment strategy x predict , which combines maximum Sharpe ratio portfolio theory with stock return forecasting, is the best-performing of all strategies, and CSI 300 index at M = 90 M = 120, M = 150, or M = 180. Moreover, strategy x LW −predict based on the linearly weighted ensemble model almost always has higher out-of-sample performance compared to other strategies based on single forecasting models (i.e, x SVR−predict , x XGBoost−predict , x LightGBM −predict , x RF−predict , x GBR−predict , x LSTM −predict ).
The above results demonstrate that the proposed stock preselection approach and portfolio optimization model, based on predicting stock return by ensemble learning, can improve portfolios' out-of-sample performance and robustness.

3) SENSITIVITY ANALYSIS
In this section, we perform a sensitivity analysis for different rolling window length (M ) and the select number of stocks (k). And we use the cumulative return of the investment strategy as the criterion for evaluation. The results are shown in Fig. 2 and Fig. 3.
From the results in Fig. 2, each strategy achieved the highest cumulative return at k = 3, and shows a decreasing trend as k increases. This result is consistent with the conclusion of [6], [7], [45], and [46] that individual investors should not hold too many assets at the same time.
From the results in Fig. 3, the cumulative returns of the maximum Sharpe ratio portfolio exhibit different degrees of VOLUME 11, 2023   volatility as M changes, i.e., as the time horizon of the historical performance of equity assets is considered in the construction of the investment strategy. Meanwhile, the proposed strategy has the highest cumulative return at all times, has maintained a stable cumulative return, and is more robust for different rolling window lengths than other strategies   (especially the maximum Sharpe ratio portfolio). Suggests that the proposed approach using predicted stock returns instead of expected returns in constructing portfolios improves the out-of-sample performance of the portfolios and their robustness.

D. ROBUSTNESS TEST
We further perform an additional out-of-sample test for the above two-stage portfolio approach to verify that the   to test the robustness of the proposed approach. Like CSI 300, we removed stocks with more than 5% missing data and those that ceased to be listed during the period. We finally chose 85 stocks for the test. The specific stock information is in Table 16. Similarly, we use the same methodology to forecast the returns of CSI 100 constituents, and the detailed results are shown in Table 17.
From the results in Table 17, it can be found that consistent with the results of CSI300, the linearly ensemble model has the best prediction performance in MAE, MSE, RMSE, or H R , while the other two ensemble models also work better than most individual models, indicating that the proposed approach is robust to different data sets.
Thus, we will use the linearly ensemble model for the subsequent out-of-sample tests, and the linearly ensemble model's detailed forecast results of each category of the industry are shown in Table 18. The manufacturing industry has the highest number of stocks among all industries, then the real estate has the smallest RMSE, MAE, and MSE, this may be related to the fact that house prices in China have been rising steadily.
Based on the forecast results, this paper also uses the ''rolling sample'' to carry out the out-of-sample test. Based on the above results, the out-of-sample performance of each strategy is robust when M = 180 in most cases, so we assume that M = 180. Then we can obtain the Sharpe, Sortino, Omega, and Calmar ratio for the different investment strategies. The optimal results for each investment strategy are shown in Table 19. The above results indicate that in most cases, for a given, select number of stocks, the Sharpe, Sortino, Omega, and Calmar ratio of strategy x predict is higher than other strategies or CSI 100 index. Additionally, we also find that the out-of-sample performance of strategies after stock pre-selection is better than CSI 100 in most cases. The above results indicate that the proposed two-stage portfolio optimization s is robust to different data samples.
In addition, Fig. 4 shows the sensitivity analysis for a different select number of stocks (k). Similarly, we find that portfolio strategies perform better when k is small. In particular, when k = 3, most strategies have the best performance. Moreover, as with the results of CSI 300, the proposed strategy is still relatively robust when the length of the rolling window varies, and in most cases, the proposed strategy x predict has the best out-of-sample performance.
From the above empirical results, the proposed two-stage portfolio optimization approach can efficiently improve the out-of-sample performance of portfolios. In addition, the results further suggest that investors should concentrate their wealth on a small number of assets which has high potential.

IV. CONCLUSION
This paper proposes a two-stage portfolio optimization model by combining the traditional portfolio theory with ensemble learning methods. Specifically, this model is composed of the following two stages: stock pre-selection and portfolio optimization. In the first stage, we integrate six machine learning forecasting models (i.e., SVR, XGBoost, Light-GBM, RF, GBR, and LSTM) with three ensemble methods to forecast future returns of CSI 300 constituent stocks, where the best-ranked stocks according to forecasted returns are selected into the latter stage. In the second stage, we establish a new portfolio model based on the forecasted returns of selected stocks and the maximum Sharpe ratio portfolio theory. The empirical application mainly focuses on the outof-sample performance of the proposed portfolio strategy and several traditional portfolios (i.e., maximum Sharpe ratio portfolio, minimum variance portfolio, 1/N portfolio, and CSI 300 index) under different window lengths M . In addition, we compare the out-of-sample performance between strategies based on the linearly weighted ensemble method and those based on individual forecasting models. The empirical results show that the forecasted returns of stocks based on ensemble learning can advance the performance and robustness of the portfolio, and the out-of-sample performance of the proposed strategy outperforms other traditional strategies in most cases. This indicates that the forecasted returns provide a better estimate of the true return of the assets in the portfolio optimization, and further suggests that using forecasted returns instead of historical expected returns is feasible. Meanwhile, we find that the strategies perform best when k is small. These results suggest that one should be aware that forecasting information on assets is equally important when constructing portfolios, rather than relying heavily on historical information. Moreover, the investor should adopt an under-diversification strategy instead of the traditional fulldiversification strategy. Our robustness test also confirms the above findings. Based on the empirical evidence, we further provide several practical suggestions for investors in constructing portfolios.
First, portfolio optimization should be separated into two stages, i.e., stock pre-selection and portfolio decision. In actual investment, the importance of pre-selection needs to be reinforced since high-quality stocks can directly improve the out-of-sample performance of a portfolio.
Second, in stock return forecasting, ensemble learning can prevent the occurrence of overfitting, and thus effectively advances the accuracy and robustness of forecasting.
Third, investors should not only consider the historical data of stocks, as they may not be consistent with future return characteristics. In this case, the forecasted information on asset returns needs to be incorporated into the portfolio optimization, to improve the effectiveness and robustness of the portfolio strategy.
Finally, investors do not need to hold a lot of stocks simultaneously. Instead, one can focus on including these highquality stocks with favorable future return information in the portfolio.
The current work in this paper could be further extended from the following three aspects. (i) This paper only considers the historical trading data and technical indices of stocks as characteristics to forecast future returns. However, many other factors could be used in the forecast procedure (such as investor sentiment and the COVID-19 epidemic). (ii) We only consider forecasted returns, while many other important factors may be predicted and applied to portfolio construction, such as risk, the direction of price movement, etc. (iii) There are many other quality assets besides stocks, so considering a more comprehensive range of asset classes to construct a portfolio is also a potential direction for future work.

DECLARATION OF COMPETING INTEREST
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
ZHONGBAO ZHOU is currently a Professor at the School of Business Administration, Hunan University. His research interests include reliability modeling, system optimization, and decision-making.
ZHENGYANG SONG is currently pursuing the master's degree with the School of Business Administration, Hunan University. His research interests include portfolio optimization and financial forecasting.
TIANTIAN REN is currently pursuing the Ph.D. degree with the School of Business Administration, Hunan University. Her research interests include portfolio optimization and performance appraisal.
LEAN YU is currently a Professor at the Business School, Sichuan University. His research interests include business intelligence, big data mining, economic forecasting, financial technology, and energy management.