A Machine Learning Integrated Portfolio Rebalance Framework with Risk-Aversion Adjustment

We propose a portfolio rebalance framework that integrates machine learning models into the mean-risk portfolios in multi-period settings with risk-aversion adjustment. In each period, the risk-aversion coefficient is adjusted automatically according to market trend movements predicted by machine learning models. We employ Gini’s Mean Difference (GMD) to specify the risk of a portfolio and use a set of technical indicators generated from a market index (e.g., S&P 500 index) to feed the machine learning models to predict market movements. Using a rolling-horizon approach, we conduct a series of computational tests with real financial data to evaluate the performance of the machine learning integrated portfolio rebalance framework. The empirical results show that the XGBoost model provides the best prediction of market movement, while the proposed portfolio rebalance strategy generates portfolios with superior out-of-sample performances in terms of average returns, time-series cumulative returns, and annualized returns compared to the benchmarks.


Introduction
The purpose of financial portfolio optimization is to allocate the capital weights among a set of assets in an optimal manner such that the investor's utility is maximized. The earliest study in the portfolio optimization field dates back to the 1950's with the mean-variance model proposed by Markowitz (1952), which seeks the optimal trade-off between the reward and risk measures represented by the mean and the variance of the portfolio returns. Though the mean-variance model is widely used in practice, it has two main well-known limitations. The solution of the mean-variance model is consistent with the principle of utility maximization only if the asset returns are normally distributed or the utility function is quadratic, where the normality and quadraticity are not usually satisfied in the real financial world. To mitigate the shortcomings of the variance, many other risk measures have been investigated, which include but are not limited to the semi-variance (Markowitz 1959;Markowitz et al. 1993), semi-deviation Ruszczyński (1999, 2001), mean absolute difference (Konno and Yamazaki 1991), Value-at-Risk (Duffie and Pan 1997;Gaivoronski and Pflug 2004), Conditional-Value-at-Risk (CVaR) (Rockafellar and Uryasev 2000), Entropic Value-at-Risk (EVaR) (Ahmadi-Javid 2012), and Gini's Mean Difference (Shalit and Yitzhaki 1984;Yitzhaki 1982). We refer to Fabozzi et al. (2010) for a detailed review of risk measures. Each of the risk measures employed in the portfolio optimization framework constitutes a family of mean-risk models.
The efficient solutions of the bi-objective mean-risk portfolios can typically be achieved by solving one of the three optimization models: (1) maximizing the expected return subject to an upper-bounded budget level on the risk measure; (2) minimizing the risk measure while requiring the mean return industry for price forecasting, market pattern recognition, and movement prediction. An excellent survey paper by Thawornwong and Enke (2004) reviews different neural network approaches used in 45 journal articles for stock returns forecasting. Chen et al. (2008) propose a dynamic proportion portfolio insurance (DPPI) strategy based on the popular constant proportion portfolio insurance (CPPI) strategy. The constant multiplier in CPPI is generally regarded as the risk multiplier. Since the market changes constantly, we think that the risk multiplier should change according to market conditions. This research identifies risk variables related to market conditions. Ko and Lin (2008) introduce a resource allocation neural network model to optimize the investment weight of a portfolio. This model will dynamically adjust the investment weight as a basis of 100% of the sum of all of the asset weights in the portfolio. The experimental results demonstrate the feasibility of optimal investment weights and the superiority of ROI of the buy-and-hold trading strategy compared with the benchmark Taiwan Stock Exchange (TSE). Freitas et al. (2009) present a new prediction-based portfolio optimization model that can capture short-term investment opportunities, which utilizes the neural network to predict stock returns and derive a risk measure based on the prediction errors. Chen et al. (2010) describe a decision-making model of dynamic portfolio optimization for adapting to the change in stock prices based on an evolutionary computation method known as genetic network programming (GNP). The proposed model, making use of the information from technical indices and candlestick chart, is trained to generate portfolio investment advice. Within the framework of Bayesian analysis, Zhou et al. (2014) construct portfolios with out-of-sample return forecasting based on the latent threshold dynamic models by considering the dependencies among the sparse factors.
In a more recent study, Ji et al. (2019) propose a multi-period dynamic portfolio optimization framework that allows the investor to adjust his or her risk attitude (i.e., risk-aversion coefficient) by fusing the market trend movement information predicted by machine learning models using a set of technical indicators as the input features. The proposed framework consists of two steps: first, a set of technical indicators (e.g., moving averages, momentum, relative strength index) generated from a market index (e.g., S&P 500) will feed the machine learning classification models (e.g., logistic regression, support vector machines) to predict the market movement (e.g., going up or down). Secondly, by adjusting the risk-aversion coefficient according to the predicted market movement, the investor will solve a mean-risk portfolio optimization model to obtain the portfolio weights and carry the portfolio into the next period. They employ Gini's Mean Difference as the risk measure in the portfolio optimization. Our paper is an extension of the work by Ji et al. (2019), with significant improvements from the following three perspectives:

1.
More flexible selection of the risk-aversion coefficient. In Ji et al. (2019), they assume that the risk-aversion coefficient is selected from a finite and ordered set that is pre-determined by the investor. The selection of the risk-aversion coefficient is limited within this prescribed set and is only allowed to change according to its adjacent values. In this study, we modify the objective function of the mean-risk optimization model into a normalized version, so that the predicted probability of market movement from the machine learning models can be directly incorporated as an input of the risk-aversion coefficient, which alleviates the complication of specifying a prescribed set.

2.
More technical indicators are used to train the machine learning models. Ji et al. (2019) employ 9 different technical indicators to feed the machine learning classification models, while we will consider an extensive set of 14 technical indicators with a total of 37 features or predictors generated by the different parametric settings of those indicators.

3.
More comprehensive empirical tests are conducted to derive numerical insights. Using the rolling-horizon approach, Ji et al. (2019) conduct numerical tests with a horizon of 156 periods (3 years), with 104 periods in each rolling-window for in-sample training and portfolio optimization, and 52 periods (1 year) for out-of-sample performance evaluation. In this study, we carry out the empirical tests with a longer horizon of 1252 periods (24 years from 1995 to 2018), with 260 periods (5 years) in each rolling-window and 992 periods (19 years) for the out-of-sample performance evaluations.
The remainder of this paper is organized as follows. Section 2 introduces the Mean-Gini model using Gini's Mean Difference as the risk measure, the employed technical indicators and machine learning classification models. The machine learning integrated portfolio rebalance framework is established in Section 3. The results of empirical studies are reported in Section 4. Section 5 concludes the paper.

Preliminaries
To be self-contained, we will revisit the three key parts to establish the machine learning integrated portfolio rebalance framework. Section 2.1 reviews the Gini's Mean Difference (GMD) and Mean-Gini portfolio model. Section 2.2 illustrates the 14 technical indicators employed in our study. Section 2.3 briefly introduces two machine learning approaches, that is, logistic regression (LR) and extreme gradient boosting (XGBoost).

Gini's Mean Difference and Mean-Gini Model
We first revisit the Mean-Gini portfolio optimization model, which employs a portfolio's mean return as the reward measure and Gini's Mean Difference (GMD) as the risk measure. Yitzhaki (1982) firstly proposed adopting Gini's Mean Difference as a risk measure in portfolio analysis. Numerous studies have been contributed to the literature following the stem; see Yitzhaki (1983), Shalit and Yitzhaki (1984), Ringuest et al. (2004), Ji et al. (2017b), Ji et al. (2018), Shalit and Greenberg (2013), Sehgal and Mehra (2017) for examples. We are motivated to use GMD for three main merits: (i) GMD is demonstrated to be consistent with second-order stochastic dominance and is a coherent measure of risk (see Artzner et al. 1999); (ii) in contrast to variance, GMD does not require the normality assumption of asset returns nor the quadratic utility function of the investor; and (iii) GMD provides diversity of the constructed portfolios, which is in agreement with the Basel II Accord recommendations (Basel Committee on Banking Supervision 2004).
Let us first introduce some notations before stepping into the mathematical definitions. We denote by J the total number of periods of historical data, and let I be the total number of candidate assets/stocks to be considered to construct portfolios. Our decision variable, w i , i = 1, . . . , I, represents the capital weights (i.e., percentage of the capital) invested in asset i. Let r ij denote the historical return of asset i in period j, i = 1, . . . , I and j = 1, . . . , J. The mean return of asset i is denoted by µ i .
With the above notations, we thus can compute the portfolio return R j in period j, j = 1, . . . , J, and the mean return of the portfolio R as follows: The Gini's Mean Difference (GMD) is defined as one half of the mean absolute difference between all pairs of realizations of the portfolio return Yitzhaki (1982). We let the Gini's Mean Difference be denoted by G, and it can be formally formulated as follows: Employing the mean return (R) as the reward measure and the GMD (G) as the risk measure, the Mean-Gini model can be formulated in the form of maximizing the risk-adjusted mean return.
In the objective function (4), α ≥ 0 is a user-defined risk-aversion coefficient representing the attitude of the investor toward the risk. Constraints (6) to (8) linearize the GMD expression (3) by introducing auxiliary non-negative variables R jj that represent the positive difference between the pair of portfolio realizations, that is, R jj = max{R j − R j , 0}, j, j = 1, . . . , J; j = j . Constraint (9) enforces all available capital to be invested in the portfolio. Constraint (10) prevents short selling.
In the above Mean-Gini model, the risk-aversion coefficient α is a predefined parameter input, seeking a trade-off between two objectives (maximizing the expected return R and minimizing the risk G), by imposing a penalty on the risk. By solving the above model with various α value, one can trace out the Mean-Gini efficient frontier of the portfolios. In a multi-period setting with portfolio rebalance strategy, the risk-aversion coefficient should be adjusted according to the risk attitude of the investor which is heavily steered by the market trend movements. That is, when the market is going up, the investor is less risk-averse (or even risk-seeking), thus looking for higher returns by setting a small value on the coefficient α; whereas if the market is going down, then the investor becomes more risk-averse, thus aiming to reduce risk by adjusting the coefficient α to a large value.
The selection of the risk-aversion coefficient α is arbitrary. To provide an unbiased assessment, it is critical to ensure that this coefficient has a similar impact on the mean return and GMD objectives. We thus transform the original objective function (4) into a normalized version. The normalized Mean-Gini (NMG) model reads: where R and G represents the expected return and Gini's Mean Difference of the constructed portfolio, respectively. G min denotes the minimal GMD, which can be obtained by minimizing GMD as a single objective without constraints imposed on expected return. R min denotes the minimal expected return corresponding to the portfolio with G min . R max and G max represent the maximal expected return and GMD when solving the model with the single objective of maximizing the expected return with no restrictions on the risk measure GMD. After the min-max normalization, the two terms R−R min R max −R min and G−G min G max −G min will range from 0 to 1. In addition, we use the weighted coefficient λ and 1 − λ associated with the return and risk objectives, respectively, where λ ∈ [0, 1] is a user-defined parameter representing the probability of the market going up. When λ = 1, that is, the probability of the market going up is 1, then the NMG model reduces to the form of maximizing the expected return solely, which reflects the risk-seeking attitude of the investor during an upward trend. When λ = 0, that is, the probability of the market going down is 1, then the NMG model is equivalent to minimizing the risk measure GMD, which captures the risk-averse preference during a downward trend. By adopting the risk-aversion coefficient λ with a probability interpretation, it allows us to integrate this (predicted) probability obtained by machine learning classification models for predicting the movement of the market.

Technical Indicators
We use a set of technical indicators generated from a market index as the predictors or features in order to build the machine learning classification models for market movement. A market index, such as Standard & Poor's 500 (S&P500) and Dow Jones Industrial Average (DJIA), is generally developed to measure the weighted value of a section of the stock market, thus intuitively a reliable indicator representing the market trend. The task of the machine learning models is to predict the movement (i.e., up or down) of the market via a set of technical indicators that are related to the past values and volume pattern of a market index. There are hundreds of technical indicators available with various definitions to capture different information. We refer the interested readers to Colby (2002) for more comprehensive descriptions for the technical indicators. Here, we only introduce briefly the 14 popular and widely used indicators adopted in the machine learning models within our study, The above 14 technical indicators are widely used both in the academia and the finance industry. Each of them is equipped with different parameters. To keep the paper succinct as well as self-contained, we provide a brief description of each technical indicator in Appendix A with Table A1 summarizing the equations to compute them. Using different parameter settings, we create a total of 37 versions of different indicators, which are adopted as predictors (or called features) to train the classification models, with the target to predict the movement (i.e., up or down) of the market trend in the near future in a probabilistic manner. Table 1 lists the indicators and the parameter settings used to predict the direction of market. In the first column, the number in the '[ ]' after the acronym of the indicator shows the number of versions of that indicator being used. For example, SMA[3] means that we compute 3 different versions of SMA with 3 different numbers of periods to compute the averages, which are 3, 5 and 10 as shown in the second column of the table. Number of periods to average over: 3,5,10

Machine Learning Classification Models
In this subsection, we will describe two machine learning approaches for classification tasks: logistic regression (LR) and the extreme gradient boosting (XGBoost). We shall briefly present the mathematical formulation of the models, but skip the technical solution details, since that discussion is outside the scope of this paper.
We let the target variable Y be defined as a binary variable vector indicating whether the market index goes up (i.e., y t = 1) or goes down (i.e., y t = 0) in time period t. The technical indicators computed from the market index data are regarded as the predictor vector x.

Logistic Regression
The logistic regression model can be expressed via different forms. Considering m predictors in a data set, we can write the logistic regression model in the probit format as: where p(X) = Pr(Y = 1|x 1 , ..., x m ) represents the probability that market index goes up. This probability p(X) can be used as a direct input value for the risk-aversion coefficient λ in the NMG model (11). Based on probit function, we can get the following equation where the p(X) 1−p(X) is called odds. The value of odds ranges from 0 to ∞. These odds indicate the likelihood that the market goes up over that of market goes down. By taking the logarithm on both sides of the odds equation, we can get the following function in the logit format.
2.3.2. Extreme Gradient Boosting (XGBoost) Gradient boosting machine (GBM) is a statistical framework that casts boosting as a numerical optimization problem where the objective is to minimize the loss of the model by adding weak learners using a gradient descent-like procedure. XGBoost improves upon the based GBM framework through system optimization and algorithmic enhancements. XGBoost is widely used for solving machine learning problems and data mining challenges, and it has displayed excellent performance in various applications (Chen and Guestrin 2016). Considering a data set with n observations and m predictors, a tree model uses K additive functions to build a model.
T is the number of leaves. Every f k has an independent tree formation q and leaf weight w. The following regularized objective function is used to learn in the model. where The regularization term Ω is used to penalize the model's complexity and to avoid over-fitting. The logistic loss is computed as: Unlike logistic regression with a clear and explicit equation to calculate the probability and interpret the relationship between the target variable and predictors, the results of XGBoost are generated from a collective set of classification trees.

Machine Learning Integrated Portfolio Rebalance Framework
After specifying the Mean-Gini model, technical indicators and the machine learning models, we are now ready to establish the machine learning integrated portfolio rebalance framework. Figure 1 depicts the overview of the portfolio rebalance framework. The proposed framework encompasses two phases. In the predictive modeling, the historical information (including open, low, high, close prices and volume) of a market index such as S&P 500 will be collected and used to generate the technical indicators, which will be treated as the predictors or features to the machine learning models (e.g., logistic regression, XGBoost) to predict the market movement trend. The predicted probabilities of market going up will then be utilized to represent or adjust the risk-aversion coefficient λ, which is an input parameter of the portfolio optimization modeling phase. In the portfolio optimization models, we collect the historical prices of assets or stocks in the market (e.g., S&P 500), and compute the returns. After solving the portfolio optimization models with the risk-aversion adjustment, we apply the obtained portfolio weights into the future market.
In a multi-period setting with a finite horizon, to build the predictive models and conduct the out-of-sample performance tests of the generated portfolios, we adopt a rolling horizon procedure similar to DeMiguel et al. (2009) and proceed with our portfolio rebalance approach as follows:

1.
A specific market is selected (e.g., S&P 500), historical information of the market index and a set of assets that belong to that market are collected. A window of τ periods are used as in-sample periods to build the machine learning models in a cross-validation manner and to construct the NMG portfolios. In our tests, τ is selected to be 260 that covers weekly returns over 5 years.

2.
Within the in-sample periods up to time period t, the 14 technical indicators (i.e., SMA, WMA, EMA, MACD, RSI, ADX, CCI, SMI, EMV, MFI, CMF, VWAP, BBands and SAR) are computed from the index value and are fed to the two machine learning models (i.e., LR, XGBoost) to obtain the market movement with predicted probabilities λ t+1 . The tuning parameters of machine learning models are selected via cross-validation. Using the new or updated risk-aversion coefficient, we solve the NMG model to obtain portfolio weights within the training window.

3.
We carry out the rolling horizon procedure each time by adding the data of the next week (period) in the out-of-sample periods and dropping the data of the earliest week from the in-sample periods. The technical indicators, machine learning models results, and portfolio optimization models are updated on a weekly basis.

4.
We repeat this procedure until the end of the selected dataset, which generates T − τ portfolios. The weight of asset i in time period t is denoted by w it , for t = τ, . . . , T − 1. Holding the portfolio weights w it for one week gives the out-of-sample return at time t + 1 : R t+1 = ∑ I i=1 w it r i,t+1 , where r i,t+1 denotes the return of asset i in out-of-sample period t + 1. We then evaluate the out-of-sample portfolio performance and compare them to other benchmarks.
We emphasize that our proposed framework is a general framework that can be easily extended to employ various types of technical indicators, machine learning classification models with predicted probabilities, and mean-risk portfolio optimization models, not limited to the ones presented in the current paper. We refer interested readers to Colby (2002), Cervelló-Royo and Guijarro (2020) and Fabozzi et al. (2010) for more choices of technical indicators, machine learning algorithms, and mean-risk portfolio models.

Computational Tests
In this section, we carry out a series of tests with empirical data to evaluate the portfolio performance generated by the machine learning integrated Mean-Gini portfolio rebalance framework. Section 4.1 introduces the data sets and experimental design. Section 4.2 describes the metrics to evaluate portfolio performances. Section 4.3 provides the results of machine learning models and derives insights regarding the out-of-sample performance of the risk-aversion adjusted portfolios.

Data and Experimental Design
Our experiments were conducted with data from Standard & Poor's 500 (S&P500) stock market, which is a stock market index based on the capitalization of the 500 representative US companies. The entire dataset were downloaded via R programming language using the getSymbols function within the quantmod package. We collected the data of S&P 500 index, 25 risky assets, and 1 risk-free asset (13 Week Treasury Bill) from 01/09/1995 to 12/31/2018 with 1252 weekly returns. These 26 assets constitute the asset candidates pool to construct the portfolios. The tickers and companies of the 26 assets are listed in Table 2. The adjusted close prices were used to compute the technical indicators. We selected the 25 risky assets in Table 2 with three factors-(i) The selected assets have no missing values within the studied time horizon; (ii) The selected assets are not high volatile assets, with volatility lower than 0.5; (iii) The selected assets are diversified to reflect the market index. The selected 25 assets cover 9 out of 11 S&P 500 sectors. The selected 25 assets remained in the S&P 500 index during the testing period. This could potentially lead to a survivor bias and a possible slightly skewed over-performance of the portfolios when compared to the S&P index. However, we note that the comparisons among the constructed portfolios are valid considering they use the same dataset. In addition, similar empirical evaluations of the asset universe have been commonly employed in the literature (see, e.g., Disatnik and Benninga 2007 and Urbán and Ormos 2012). We conducted the tests following the rolling-horizon approach with a training window for 260 periods (5 years). In each window, we built the logistic regression and XGBoost models, and predicted the probability of the market going up in the 261st period. The predicted probability will be used as the risk-aversion coefficient λ in the NMG model to construct the Mean-Gini portfolio. We carried the portfolio weights into the 261st period and obtained a portfolio return and validated the prediction accuracy of the machine learning models. We then dropped the data of the 1st week and added the data of the 261st week to build the second training window and repeated the training of the machine learning models and constructing Mean-Gini portfolios. We repeated this procedure until the end of the entire dataset.
For comparison purposes, besides the two Mean-Gini portfolios constructed via logistic regression and XGBoost with risk-aversion adjustment, we used the following four benchmarks: (1) Mean-Gini portfolio with fixed risk-aversion coefficient λ = 0.5; (2) The equal weights portfolio, that is, the capital is equally assigned into the 26 assets over all testing periods; (3) The S&P 500 market index; (4) The classical minimal variance (MinVar) portfolio (i.e., a portfolio that minimizes the variance of returns). We note that there are many candidates on the mean-variance efficient frontier to be selected, we pick this MinVar as a baseline for comparison.
The R software was used to compute the technical indicators from the S&P 500 index and build the machine learning models via a cross-validation procedure to generate the market movement predictions. The AMPL modeling language was used to formulate the NMG and MinVar portfolio optimization problem, and each problem instance was solved by the commercial solver Cplex with version 12.6. All tests were conducted on a 64-bit desktop with Intel(R) Core(TM) i5-6500 processor, running at 3.2GHz CPU and with 8GB RAM.

Performance Metrics
To evaluate the out-of-sample performance of the portfolios, we employed the following six metrics based on time-series returns and asset weights. • The out-of-sample average weekly return: • The out-of-sample standard deviation: • The out-of-sample Gini's Mean Difference (GMD): • The out-of-sample Sharpe ratio: (21) • The out-of-sample cumulative return: • The out-of-sample annualized return:

Computational Results and Insights
In this section, we first present the results of logistic regression and XGBoost models for market trend predictions, then assess the out-of-sample performance of the constructed portfolios.

Results of Machine Learning Models
We compared the prediction accuracy of the two models by setting a cutoff value for probability level p = 0.5, that is, if the predicted probability is greater than or equal to 0.5, then the market is predicted to move upward; otherwise, it is predicted to move downward. The prediction accuracy of logistic regression model is 0.5857. The accuracy of XGBoost is 0.5958, which is 1.01% better than logistic regression.
We generated a total of 37 predictors with different parameter settings of the 14 employed technical indicators (see Table 1 for more details). Figure 2 displays the relative importance of different predictors with the XGBoost algorithm averaged over all 992 windows. The five most important technical indicators are EMV, MACD, RSI, ADX and SMI. The performance of the technical indicators is sensitive to the parameters defining them, among which the number of periods to average over plays a critical role. EMV(n = 10) taking the average over 10 periods is the most important predictor. Considering that the other two versions of EMV with n = 3 and n = 5 do not appear in the top list, using a longer average period for EMV is more appropriate to train the model. A similar pattern can be detected for the RSI indicator. All three versions of RSI with n = 10, 5, 3 are important predictors, while RSI(n = 10) is more important than RSI(n = 5), then followed by RSIn = 3. The impacts of periods on MACD and ADX are the opposite, that is, the indicators with shorter periods are more important than those with longer periods. For example, MACD(2, 3, 3) weighs more importantly than MACD(3, 4, 5), while RSI(n = 10) weighs more than RSI(n = 5) and RSI(n = 3). SMI shows a different pattern that SMI(n = 3) has almost identical importance to SMI(n = 10), while they are both much better than SMI(n = 5). Figure 3 plots the histogram of the predicted probabilities of the 992 XGBoost models on a 0.1 bin width. The extreme probability predictions, such as p ∈ [0, 0.1] and p ∈ [0.9, 1.0], are relatively small with frequency of 50 and 58, respectively. The highest frequency is found in the interval of [0.8, 0.9] with 122. A bi-modal distribution pattern can be roughly observed with a symmetric line at p = 0.5.

Evaluation of Portfolio Out-of-Sample Performance
We next present the results of the out-of-sample portfolio performance. We compared the performance of six portfolios as follows: (1) LR: the NMG portfolios generated with risk-aversion adjustment by logistic regression model; (2) XGBoost: the NMG portfolios generated with risk-aversion adjustment by XGBoost model; (3) λ = 0.5: the NMG portfolios with fixed risk-aversion coefficient being equal to 0.5; (4) Equal Weights: the portfolio with equal weights assigned across all assets; (5) S&P 500: the S&P 500 market index; (6) MinVar: the portfolio with minimal variance. Table 3 displays the performance comparisons of the above six portfolios with respect to the performance metrics including the out-of-sample average return, standard deviation, Gini's Mean Difference, Sharpe ratio, cumulative return, annualized return. Figure 4 shows the time-series cumulative returns of the six portfolios across the out-of-sample periods. The performance of portfolios (LR and XGBoost) generated by our proposed machine learning integrated portfolio rebalance framework shows superior performance compared to the other four benchmark portfolios in terms of return measures, that is, average return, cumulative return, and annualized return. Suppose the investor is profit-driven, then the LR and XGBoost portfolios are convincing choices to be adopted. The XGBoost portfolios display the best performance among all portfolios with respect to average return (0.35%), cumulative return (1511.73%) and annualized return (15.76%). The LR portfolios have a close performance to the XGBoost portfolios, with an average return of 0.33%, cumulative return of 1390.65% and an annualized return of 15.28%. In terms of cumulative return at the end of the testing periods, XGBoost (resp. LR) portfolios is 1.31, 1.63, 21.70 and 40.91 (resp. 1.12, 1.42, 19.88 and 37.55) times better than λ = 0.5, Equal Weights, S&P 500 index, and MinVar portfolio, respectively. The MinVar portfolio has the best performance with respect to the out-of-sample risk measures such as standard deviation and Gini's Mean Difference. The MinVar portfolio is the most conservative and diversified portfolio. MinVar portfolio puts weights into all 26 assets across all 992 periods, while focusing more on risk-free assets. Each constructed MinVar portfolio invests more than 90% of the capital into the risk-free asset, leading to very low values of risk measures (e.g., standard deviation at 0.04% and GMD at 0.02%), as well as low return measures (e.g., average return at 0.03%, cumulative return at 36.07% and annualized return 1.63%). The lowest standard deviation of MinVar leads to its highest Sharpe ratio at 0.8820, which dominates all 5 other portfolios. Excluding the MinVar portfolio, the LR portfolio has the highest Sharpe ratio. The XGBoost portfolio does not beat the Equal Weights portfolios with respect to Sharpe ratio (0.0948 vs. 0.0955), but it still beats the λ = 0.5 portfolio (0.0878) and S&P 500 (0.0335). The performance of the portfolios is consistent in terms of standard deviation and GMD, the MinVar has the lowest value, followed by Equal Weights, S&P 500, λ = 0.5, then by LR and XGBoost.
From Figure 4, the LR and XGBoost portfolios show dominance over the benchmarks S&P 500 and MinVar portfolio across the testing periods. The dominance relationship becomes more significant starting in 2009, after the financial crisis in 2008. The portfolios generated by our machine learning integrated framework with risk-aversion adjustment provide convincing results, by outperforming the one without risk-aversion adjustment (λ = 0.5), and the other three classical benchmarks (Equal Weights, S&P 500 and MinVar) in terms of average return, cumulative return and annualized return, which also display great performance with respect to Sharpe ratio.

Summary and Future Studies
In this paper, we propose a machine learning integrated mean-risk portfolio rebalance framework with risk-aversion adjustment in a multi-period setting. When rebalancing the portfolio, a set of technical indicators are fed to the machine learning classification models to predict the probability of market movement, and investors can thus adjust the risk-aversion coefficient accordingly in the mean-risk optimization to obtain portfolio weights. In our study, we employ the Gini's Mean Difference as the risk measure in our portfolio optimization model. We use 14 popular technical indicators generated from a market index (S&P 500) to train the machine learning models (logistic regression and XGBoost). Within a rolling-horizon procedure, we conduct an extensive set of empirical tests to assess the prediction results of the machine learning models and evaluate the out-of-sample performance of the resulting portfolios. We find that XGBoost model provides better performance prediction. The LR and XGBoost portfolios generated by our proposed framework show great performance in terms of average return, cumulative return and annualized return compared to the three other benchmarks.
For future research, we aim to expand the proposed framework to the index tracking optimization problem (see for example, García et al. 2018a) that utilizes the predictive modeling power to detect the market movement trend for better tracking performance. Moreover, we would also like to incorporate more practical constraints when building the mean-risk portfolio optimization models, such as the bound and cardinality constraints (see Guijarro and Tsinaslanidis 2019), and evaluate the performance of the proposed framework with a larger as well as a more comprehensive dataset.

Conflicts of Interest:
The authors declare no conflict of interest.

Appendix A. Description of Technical Indicators
We provide below the brief description of the 14 employed technical indicators. Table A1 summarizes the equations to compute the indicators.

1.
Simple Moving Average (SMA): SMA is defined as a simple linear (equally-weighted) rolling mean of the closing prices of an asset in the past n periods. We let the prices be denoted by P M , P M−1 , P M−(n−1) .

2.
Weighted Moving Average (WMA): WMA is an adapted version of SMA, where the weight assigned to each period is not identical, but decreases in an arithmetical progression. In an n-period WMA calculation, the latest period has weight n, followed by the second latest period's weight n − 1, until down to one. 3.
Exponential Moving Average (EMA): Compared to the linear decreasing of weight in WMA, EMA is computed with the weighting for each older datum decreasing exponentially in an iterative procedure. 4.
Moving Average Convergence/Divergence (MACD): MACD is a classical trend-following momentum indicator of the exponential moving average (EMA) of a stock or index that is used to identify short-term momentum. More specifically, MACD is calculated by subtracting the long-term EMA from the short-term EMA to obtain an intermediate trend line. An EMA is then plotted over the intermediate line to identify the buy or sell signal of the asset or the index. When the resulting MACD falls below the signal line, it is a bearish signal, which indicates that it may be time to sell. Conversely, when the MACD rises above the signal line, the indicator gives a bullish signal, which suggests that the price of the asset is likely to experience upward momentum.

5.
Relative Strength Index (RSI): RSI shows the strength or speed of the asset price by means of the comparison of the individual upward or downward movements of the consecutive closing prices. It is computed as the ratio of recent upward price movements to the absolute price movements. For each time period, an upward movement U (i.e., if P M − P M−n > 0) or a downward movement D (i.e., if P M − P M−n < 0) is characterized depending on the relative difference between the current price P M and the previous price P M−n . 6.
Average Directional Movement Index (ADX): The ADX is a combination of the positive directional indicator (denoted by +DI) and the negative directional indicator (denoted by −DI) with a smoothed moving average. The positive/negative directional movement (+DM and −DM) is calculated in a similar way as the upward/downward movement shown in RSI. 7.
Commodity Channel Index (CCI): CCI measures the current price level relative to an average price level over a given period of time to identify a new trend or warning of extreme conditions. The CCI is calculated as the difference between the typical price of a commodity and its simple moving average, divided by the mean absolute deviation of the typical price. The index is usually scaled by an inverse factor of 0.015 to provide more readable numbers: 8.
Stochastic Momentum Index (SMI): The SMI calculates where the close is relative to the midpoint of the high/low range. The values of the SMI range from +100 to −100. When the close is greater than the midpoint, the SMI is above zero, and when the close is less than the midpoint, the SMI is below zero. Extreme high/low SMI values indicate overbought/oversold conditions. A buy signal is generated when the SMI rises above −50, or when it crosses above the signal line. A sell signal is generated when the SMI falls below +50, or when it crosses below the signal line. Also look for divergence with the price to signal the end of a trend or indicate a false trend. 9.
Ease of Movement (EMV): The EMV describes the relationship between the price change and volume. To calculate EMV, we need to calculate midpoint move firstly. The midpoint move is computed by today's high and low price, and yesterday's high and low price. Then the box ratio is generated by volume, high and low price. The EMV is the ratio between the midpoint move and the box ratio. High EMV indicates when price goes up with small volume. 10.
Money Flow Index (MFI): The MFI measures the selling and buying pressure based on both volume and price. We can use MFI to identify the level of overbought or oversold which can present a warning of unsustainable price extremes. 11.
Chaikin Money Flow (CMF): The CMF quantifies the amount of Money Flow Volume during a given time period. CMF is an oscillator which is between −1 and +1. The CMF quantifies the buying and selling pressure on a given time period. When CMF moves into positive (resp. negative) territory, it indicates a buying (resp. selling) pressure. Therefore, an uptrend (resp. downtrend) is revealed by positive (resp. negative) CMF. 12.
Volume-weighted Average Price (VWAP): The volume-weighted average price is also known as volume weighted moving average (VWMA) which weights the price of each stocks by the volume. Therefore, when stocks are at a higher volume, they will be more weighted during the computation. 13.
Bollinger Bands (BBands): BBands have a Mid Band with two outer bands: Upper and Lower Band. The Mid Band is a simple moving average of the typical high, low and close price. BBands is designed to locate situations when the price goes too high or too low. If the price is higher than the Upper Band, it means the price is too high. Otherwise, when the price is lower than the Lower Band, it means the price is too low. 14.
Parabolic Stop-and-Reverse (SAR): The parabolic SAR indicator is used by traders to determine trend direction and potential reversals in price. The indicator uses a trailing stop and reverse method called "SAR" or stop and reverse to identify suitable exit and entry points. A dot below the price means the price is moving up, and a dot above the price bar means the price is moving down overall.  .., P low M−(n−1) )} cm = P close − 1 2 · c cm 1 = cm · n 1 · EMA n 1 , n 1 : number of periods for initial smoothing cm 2 = cm 1 · n 1 · EMA n 1 hl = max{P high M , ..., P high M−(n−1) } − min{P low M , ..., P low M−(n−1) )} hl 1 = hl · n 2 · EMA n 2 , n 2 : number of periods for double smoothing hl 2 = hl 1 · n 2 · EMA n 2 SMI = 100 × cm 2