A superior active portfolio optimization model for stock exchange

Due to the vast number of stocks and the multiple appearances of developing investment portfolios, investors in the financial market face multiple investment opportunities. In this regard, the investor task becomes extremely difficult as investors define their preferences for expected return and the amount to which they want to avoid potential investment risks. This research attempts to design active portfolios that outperform the performance of the appropriate market index. To achieve this aim, technical analysis and optimization procedures were used based on a hybrid model. It combines the strong features of the Markowitz model with the General Reduced Gradient (GRG) algorithm to maintain a good compromise between diversification and exploitation. The proposed model is used to construct an active portfolio optimization model for the Iraq Stock Exchange (ISX) for the period from January 2010 to February 2020. This is applied to all 132 companies registered on the exchange. In addition to the market portfolio, two methods, namely, Equal Weight (EW) and Markowitz were used to generate active portfolios to compare the research findings. After a thorough review based on the Sharpe ratio criterion, the suggested model demonstrated its robustness, resulting in maximizing earnings with low risks.


Introduction
The difficulty of developing and managing an effective investment portfolio is one of the most pressing issues confronting the financial sector today, especially in light of increased competition and global economic changes at both the national and international levels [1]. Portfolio management and optimization are important parts of the trading system. An investment portfolio is a collection of financial and non-financial assets held by an investor. It can also be defined as a collection of securities designed to meet one or more investment objectives [2]. Although many elements, such as preferences, money, and experience can influence the investment portfolio, it can be built on familiar circumstances, starting from the process of selecting stocks, establishing the portfolio, maintaining the portfolio and its style, and finally evaluating it [3]. Portfolio management is the process of making investment decisions based on tactical investment strategies that are geared to maximize return over a specific time horizon. Portfolio optimization seeks to find the best asset allocation within a portfolio to maximize returns while minimizing risks [4].
Portfolio optimization was revolutionized by Markowitz's development of the mean-variance method (MVO) [5]. For a portfolio to be optimally allocated, the return and risk characteristics must be taken into consideration. In these kinds of circumstances, there is no one-size-fits-all answer. The efficient frontier identifies a set of effective answers to the problem at hand. As each point on the efficient frontier shows, investors may make choices based on their own risk and reward preferences, which are reflected in each point.
Diversification is the principle of work. The key concept of this principle is that the investor eliminates or at least limits excessive levels of risk in the assets which represents the shared concern of all types of investors. And, although the risk is distinct from uncertainty, the financial literature uses the terms interchangeably. Thus, the risk is defined for the majority of investors as the condition of uncertainty about future returns, or the chance of earning returns that are less than anticipated and undesired [6].
There are two parts to investment risks. The first is the systemic risk. It is also known as non-diversifying or market risk. This type represents the amount of risk that all assets in the market face at the same time, but at different rates in which it cannot be eliminated through diversification such as global financial crises and wars [7]. The second is an unsystematic risk which is also called private, unique, or diversified risk. It affects the assets of certain organizations in the market as a result of emergency conditions such as worker strikes, technical failures, and other uncontrollable events. This type of risk can be avoided by diversifying across a group of assets within the portfolio. In such a case, the total risk will be the sum of the two risks as shown in Fig. 1 [7]. The General Reduced Gradient (GRG) algorithm is a resilient local search technique that uses the Taylor expansion equation and linear optimization methods to linearize the nonlinear objective function and constraints at a local solution [8]. All constraints in the sub-problem can be treated as equality constraints using the prospective constraint technique [9]. According to this technique, a search direction is discovered such that the current active constraints remain exactly active for any little movement. If certain active constraints are not exactly met owing to the nonlinearity of the constraint functions, the Newton Raphson algorithm is used to draw back into the constraint boundary. Hence, the GRG approach is similar to the gradient projection algorithm [10].
This research aims at understanding whether technical analysis and related methods can be used to create active portfolios that can outperform their market index. Based on this dilemma, a hybrid strategy for creating an active portfolio has been developed. It combines the diversification advantages of the Markowitz model with the exploration and exploitation advantages of the GRG method. The suggested methodology comprises two key stages. The first is selecting stocks and the second is allocating weights to stocks within the portfolio to maximize returns while minimizing risks and this, in turn, can lead to maximizing the Sharpe ratio. Accordingly, this research adds several contributions to this area based on the significance of its variables. First, the optimized model is used to apply a worldwide and important deliberative approach to the Iraq Stock Exchange (ISX) market. This is characterized by turbulence as a result of the fluctuating economic reality in general. Moreover, the importance of active portfolios as an investment approach is confirmed as it simplifies and limits the complexities and constraints of modern portfolio design while allowing for unusual (active) profits. Finally, due to the shortage of research on establishing active investment portfolios, the current study fills the research gap in previous literature by considering this issue in the Iraqi and Arab investment companies.
The rest of this paper is structured as follows. The second section discusses related work on different stock market portfolio optimization approaches. The third section discusses the theoretical background. Section four shows the proposed optimization portfolio model. Section five summarizes and examines the results of the study. Finally, section six highlights the research's key findings.

Related work
Several academic papers have been written on the subject of portfolio optimization. To his credit, Harry Markowitz was the first to put out a research-based strategy for optimizing a portfolio of assets. With his Modern Portfolio Theory (MPT), he is widely regarded as a forerunner in the field of portfolio theory [5]. The Markowitz model, also known as Mean-variance models (MVO) aims either to maximize portfolio returns while imposing a linear constraint on acceptable risk or to minimize portfolio risks while imposing a linear constraint on acceptable return. As a result, portfolio optimization using this paradigm may be thought of as a quadratic programming problem (QPP). Later, a second model for portfolio optimization was suggested by Sharpe [11]. As a result of his study, Sharpe developed the so-called Sharpe model, a more streamlined version of the meanvariance model that makes use of fewer data.
To accomplish the efficient frontier, the problem of portfolio optimization based on the classical model requires solving the quadratic programming problem for return and risk trade-offs. To tackle the portfolio optimization problem, several heuristics and precise methods have been offered. However, finding an optimal solution using these methods takes a lot of CPU time [12]. The problem is phrased as a mixed-integer quadratic problem (MIQP) with real-life constraints. As such, it belongs to the NP-Complete class of problems.
In [13], different techniques were investigated to overcome the computational difficulty of the above-mentioned issue. This includes recommending multi-objective heuristic and hybrid local search methods. Heuristic techniques have risen to prominence as a viable option. heuristics are becoming increasingly popular and are being used successfully in a variety of study domains [14]. heuristic techniques for NP-Complete issues strive for suboptimal solutions in a fair amount of time rather than an ideal answer in an excessive amount of time. In [15] the authors developed an ensemble technique to identify optimum portfolios based on a Genetic Algorithm (GA). This approach is unique in that it employs several models, including MVO, Capital Asset Pricing Model (CAPM), and Momentum Strategy, all of which are optimized using a GA. The ensemble approach was examined using the Return on Investment over 5 years, and the findings were positive. This research [16] looks at how the Multi-Objective Evolutionary Algorithm based on Decomposition (MOEA/D) and the GA might be used to optimize portfolios. MOEA/D and GA have both been successful in locating portfolios. The suggested framework is capable of successfully producing weighted portfolios. The simulation was compared to other market benchmarks and well-known portfolios in the same market (Security Market Line and Market Portfolio). New hybridization strategies of metaheuristic algorithms have been proposed in the literature to handle the portfolio optimization problem. In [17] the authors proposed a novel hybrid metaheuristic algorithm based on important components from GAs, continuous Ant Colony Optimization (CACO), and Artificial Bee Colony (ABC), with computational results demonstrating the hybrid algorithm's efficacy when compared to state-ofthe-art algorithms. In [18] the researchers developed a Genetically Inspired ABC (GI-ABC) algorithm by combining ABC with genetic features of GA. To tackle the optimization portfolio problem. In [19], the authors developed a unique hybrid strategy combining parallel Variable Neighborhood Search (VNS) with Quadratic Programming (VNS + QP). The portfolio optimization issue based on the extended MVO model was handled in [20] utilizing a new multi-objective algorithm based on Particle Swarm Optimization (PSO) and a suggested adaptive ranking mechanism. The suggested technique, dubbed Adaptive Ranking Multi-Objective PSO (ARMOPSO), is compared to many metaheuristic algorithms. The ARMOPSO's competitiveness in finding quality outcomes in the challenges studied was shown by comparative findings.

Portfolio theory
The investment portfolio and its technical procedures did not appear overnight but rather developed over time in tandem with the formation of financial markets and the development of investing strategies [21]. But Markowitz's suggestions in 1952, which are credited with building the foundations of Modern Portfolio Theory (MPT) [22], were the most significant turning point. And the period before it was known as the period of Traditional Portfolio Theory dominance; here's more information about them:

Traditional portfolio theory
The traditional Portfolio Theory is a descriptive technique that relies on balancing the portfolio by acquiring a diverse range of equities or bonds for various industries and sectors. Its emphasis is on adding large and well-known firms' shares because they perform well and so reduce the risk. Moreover, because their securities are highly liquid, the transaction costs can be lowered as well. It is worth noting that this is also due to huge investors buying these shares, which are then sought by small investors in the same way due to the herd effect. This technique is naive because it follows the adage principle "don't put all your eggs in one basket". It also does not place as much emphasis on the link between stocks [23].

Modern portfolio theory
The Modern Portfolio Theory (MPT) is a quantitative and scholarly approach developed by Markowitz [22], who is considered the originator and forefather of this theory, even though Roy is the owner of the entry (Safety first). Roy provided recommendations that were comparable to his first work, did not continue to submit his study, unlike Markowitz, who went on to earn the Nobel Prize in Economics in 1991 [22]. Markowitz invented the Mean-Variance Optimization (MVO) Portfolio [24]. The theory clarified the way of measuring risk through the use of variance returns. It is a moral and appropriate method and this, in turn, leads to its use not only to demonstrate portfolio diversification efficiency but also to diversify the portfolio efficiently in the first place. According to Markowitz's suggestions, the strategy (return-risk) or (mean-variance) is based on "appropriate diversification," which is the practice of investing in stocks or assets with low joint variance (correlation) [24]. The model is predicated on a set of assumptions that account for investor behavior: a) Investors evaluate each investment option based on the probability distribution of its returns over a certain holding time. b) Over time, investors maximize their utility, and their utility curves show a declining marginal utility of wealth. c) Investors calculate portfolio risk based on changes in projected returns. d) The investor makes decisions based only on the expected return and the expected risk (standard deviation) of returns. e) At a given level of risk, the investor chooses the greatest return over the lowest, and at a given level of return, the investor prefers the lowest risk over the highest.

Risk and return in MPT
The process of assessing the portfolio's return and risk begins with an examination of the return and risk of individual securities and concludes with the portfolio as a whole. As a result, after fulfilling the criteria for the portfolio model's inputs, we will refer to how to calculate the return and risk of individual assets before moving on to the computation of the return and risk of the portfolio [25].

Asset return
The return is defined as the amount received by the investor during the period in which the asset is held, and it is the sum of the capital and periodic returns. As a result, it is computed based on a single holding period, and this form of return is known as the realized return [26], and it is calculated using Eq. 1: Where 0 is the share's previous price when purchased, 1 is the current price or liquidation price, and 1 is the dividend profit at the end of the term. The return utilized in portfolio accounts is the expected return and indicates the expected return to be achieved from the asset based on current knowledge of the asset's price behavior. The expected return is computed in two ways: the first is by analyzing historical data for the asset's returns, in which the arithmetic mean of the asset's previous returns is calculated, Eq. 2, which reflects the value of the expected return [27]: Where is the return on the retention period, and is the number of holding periods used to calculate the expected return. The second technique [28] use discrete probability distributions based on expectations or predictive information about the occurrence of the return, with the expected return being the weighted rate of the likelihood of obtaining returns, as indicated in Eq. 3: Where is the possible return, represents the probability that the return will occur i, and is the expected number of outputs.

Asset risk
As previously stated, the risk is the degree of uncertainty about the expected output of the investment, and so its metrics vary, with some measuring the magnitude of the return and others measuring the possibility of dropping below the projected value. The standard deviation measure, on the other hand, is the most prominent and extensively used metric in the portfolio and the rest of the asset pricing models [29]. It is one of the measures of statistical dispersion since it reflects the level of dispersion of results from the anticipated value. The standard deviation of expected returns is obtained in two methods, as in computing the return (the first technique for historical data), and it is calculated using Eq. 4 [30]: Where 2 is portfolio variance (square of the standard deviation of returns), is historical returns of the asset, ̅ is Historical average returns, and is the number of historical outputs measured by year, month, or day.
In the second technique, the inputs are based on the probability distribution of returns skew, as shown in Eq. 5 [30]: (

5)
Where 2 is portfolio variance (square of the standard deviation of returns), is historical returns of the asset, ̅ is Historical average returns, and is the probability of each output outcome.

Portfolio risk and return
The portfolio's return is determined using the weighted rate of expected returns for its various assets or investments, as shown in Eq. 6 [31]: Where is the return asset i in the portfolio, is the weight of asset i in the portfolio. We should mention that while constructing the portfolio, each asset is assigned a certain weight, and the weight symbolizes the value of the invested portion, for example, concerning the entire value of the portfolio. As a result, as demonstrated in Eq. 7, the total weights of the assets = 1. The weight of each asset is calculated by the ratio of the value of the asset to the total value of the portfolio [32].
In contrast to the method of calculating portfolio return, the total risk of the portfolio varies greatly because it includes not only the weighted rate of risk (variance) of the assets, but also the common variance (Covariance) between assets, which plays a significant role in reducing risk and making it much less than the risk of the same assets if combined directly together, and this method of calculating risk is the most important product of M. The portfolio risk is computed by determining the variance of a portfolio of n assets, as shown in Eq. 8 [32]: Where 2 is the portfolio variance, is the weight of asset i in the portfolio. 2 variance of asset i, and is the covariance between returns. The significance of Markowitz's propositions in calculating risk based on variance is that he clarified the role of the most important component, which is (the covariance), which indicates the degree to which two variables move together relative to the single values of their averages over time and is calculated in two ways, the first is through the use of historical data, and then it is extracted by Eq.9 [32]: The covariance is also calculated using Eq. 10:

= (10)
Where is The standard deviation of asset i and j respectively, and is the correlation coefficient of the assets i and j. As a result, we conclude that the correlation (the correlation coefficient) is the most essential component in the covariance combination since it measures the degree of a link between two things. The correlation coefficient plays a role in the variance law of the portfolio by lowering the covariance limit (it affects the effectiveness of diversification in the portfolio and the correlation ranges between (+1 and -1)). When its value is (+1), indicating perfect correlation, both assets or assets are travelling in the same direction in terms of return movement, rendering diversification ineffective and wasteful because it will not help to risk reduction. When it is (-1), the returns are inversely proportional, and diversification appears in its most efficient form. In principle, the portfolio's risk is (zero), as illustrated in Fig. 2 [33].

Efficient frontier and optimal portfolio
In its final stages, the efficient portfolio theory is embodied by selecting the efficient portfolio in light of the investor's preferences represented by the curves of indifference and benefits functions, and determining the efficient portfolio, which can be represented in the space (return -risk) by drawing the horizontal axis representing risk and the vertical axis representing expected return. In this case, we used several assets, and it is clear from Fig. 3 that the curve (BYOZC) represents the Efficient Frontier, which contains efficient portfolios and various asset combinations, all of which provide the highest possible return at a certain level of return or the lowest risk at a certain level of risk [34].

Generalized reduced gradient (GRG)
The GRG algorithm is a deterministic optimization approach initially devised by Abadie and Carpentier in 1969 to address nonlinear constraints problems. It is based mostly on the reduced gradient method. This gradientbased technique constantly seeks the nearest to the initial point, whether global or local [35]. GRG avoids the use of penalty parameters by searching along curves that are near the potential set. It removes a subset of variables using non-linear programming syntax and equality constraints, reducing the original issue to a spaceconstrained problem for the remaining variables. Essentially, this strategy employs slack variables to convert inequality constraints into equality constraints [35].
Considering a general issue in nonlinear programming with constraints (P), it may be identified as [35]: 0 , j= p+1,…, q  ak ≤ xk ≤ bk , k=1,…, n Where = [ 1 , … , ] represents an n-variable vector, f(x) represents the objective function, ( ) = 0, = 1, … , is the ℎ equality constraint, and ( ) ≤ 0 , = + 1, … , is the ℎ inequality constraint. S represents the whole search space, whereas F represents the feasible search space. The variables and denote the lower and upper boundaries of the variable x. As a result, GRG assumes that all constraints on (P) are equal and may be expressed as follows: Where x contains all of the variables (original and slacks) and is then separated into two classes: dependent XD variables and independent XI variables.

X= [… .]
In the same way, the boundaries, the objective function gradient, and the Jacobite matrix can be divided as follows: Let x 0 be a feasible initial solution, which satisfies bound and equality constraints. The variables should be selected for this reason JD (x 0 ) is non-singular. The vector of the reduced gradient is defined as Eq. 13: The search directions for the dependent and the independent variables are given by:

Subject to: ≤ ≤
Where: The optimal solution * to the problem gives the next solution:  The ISX now has 132 stocks, each with five technical features from 2004 through 2022, which is accessible on the Website (http://www.isx-iq.net). The values of the daily closing prices for the stocks of the study sample companies, as well as the corresponding daily closing values for the ISX index, were chosen for the period January 2010 to February 2020. The beginning of the sample was chosen because the ISX was in a transitional phase towards electronic trading before 2010, and the conclusion of the sample was the consequence of the market temporarily shutting down because of the Corona epidemic [36].

The proposed methodology
The research population consists of all (132) equities on the ISX. The first step (stock selection) begins with the identification of assets that fulfil the three parameters listed below: 1. Historical data for the company's stocks is available. 2. From the start of the research period until the end, the companies must be publicly traded and listed. 3. The stocks listed throughout the sample period should have at least 998 trading days (Average trading days for all businesses during the study period). Following the application of the first and second conditions, the stocks were filtered to 89 stocks, and with approval of 998 trading as a minimum, we can accept 43 stocks, giving us greater flexibility in building portfolios with different stocks and approaching the characteristics of the general market, as the general index of the market relied on 60 stocks. So, the general market index is known as the ISX60, as seen in fig. 5. Table  1 lists the names of the firms included in the study sample, as well as their symbol, sector, and the number of trading days.  The purpose of the second stage is to allocate weight to each stock in the portfolio. A hybrid optimization model was proposed which combines the principle of diversification from the Markowitz model. It is based on calculating the correlation coefficient to find the relationship between stocks, and the principle of local search (exploitation) from the GRG method. This is used to update weights and maximize the objective function represented by the Sharpe ratio. The key actions of this stage are outlined in the following steps: The GRG method converts the constrained problem to an unconstrained optimization problem. It takes the partial derivative of the objective function and reaches the optimum solution when the partial derivatives are equal to zero. As expressed in the gradient method, this method determines a starting point and a search direction until solving by maintaining the suitability of nonlinear equation systems at each step in each major iteration.

Results and discussion
The active portfolio's success cannot be judged just based on its outcomes. A peer reference is required in which the most essential forms are market indexes. Indices have been used in financial markets for almost a century. They differ in terms of their building method and attributes. Some of them reflect the whole market, while others represent certain company shares or investment philosophies. An active portfolio manager or active investor can pick what he/she considers appropriate based on the nature of his/her portfolio's structure. According to Fabozzi [37], the finest and most often utilized indicators are the broad market.
The Sharpe ratio, a risk-return evaluation metric, was utilized in this work to provide a unified measure based on a risk rate. In certain circumstances, it is also known as the reward-volatility measure since its composition is based on calculating the excess return compared to the total risk unit. Eq. 15 [38] is used to determine the Sharpe ratio: where is the return on the portfolio under consideration and is the risk-free rate of return. The standard deviation of the portfolio to be assessed is denoted by . Three models were used to construct an active portfolio for the ISX namely, MVO, EW, and the suggested model in this research. The Sharpe ratio was determined for the three models as well as the general market index 1-Assigning an initial equal weight to the weights matrix with size n 2-Calculating the expected return for each stock according to Eq. 2 or 3.

3-
Calculating the variance for each stock according to Eq. 4 or 5.
4-Calculation of stock covariance according to Eq. 8.

5-
Updating weights using the GRG according to these steps: Step 1: Specifying the design variables Step 2: Calculating objective function and reduced gradient Step 3: If converged occurs go to the end.
Step 4: Determining search direction (forward or backwards) Step 5: Choosing a step size for each iteration Step 6: updating design variables using Newton's Method (NM) Step 7: If NM is not converged then back to step 5 to Reduce step size.
Step 8: If State variables are out of range then iterate to determine variables within the range Step 9: If not find the minimum value in the range then back to step 5 to increase step size.

End.
6-Evaluation portfolio using Sharp Ratio according to Eq. 15.
for comparison. The results of this analysis are displayed in Table 2. Table 3 shows the preferences and weights of each portfolio generated using the three models. It can be deduced that the MOV and the MVO-GRG models used the same seven businesses (AISP, IITC, IMAP, IMOS, INCP, IRMC, and HBAY), but with different weights to construct their portfolios. The EW model, on the other hand, picked all of the equal assets with equal weight.  According to the results presented in Tables 2 and 3, the portfolio consisting of the MVO-GRG model has the best Sharpe ratio in comparison to other models and the general market index. This model selects seven assets out of forty-three to form the portfolio. Table 3 shows that these companies are profitable and have the lowest risk rate in comparison to other companies. The observed results, on the other hand, suggest that the EW model produced the worst outcomes. This may be because the Sharpe ratio was negative. The rationale reason for this is that out of a total of 43 companies, 36 were losing and had a substantial influence on the portfolio's performance. As a result of the existence of these companies in the market portfolio, it was concluded that the market index was also a factor in its bad performance.

Conclusions
With so many investment opportunities available in the business and financial markets, different sophisticated methods were suggested previously to choose stocks and develop investment portfolios. This study created an active portfolio for the ISX market using a combination of the diversification principle from the Markowitz model. This was based on calculating the correlation coefficient to find the relationship between stocks and the principle of local search (exploitation) from the GRG method. This was, therefore, used to update weights and maximize the objective function represented by the Sharpe ratio. The research demonstrated that all active portfolios constructed using the two models (MVO, and MVO-GRG) had a Sharpe ratio greater than the Sharpe ratio of the market index. This indicates that the active return was accomplished by the use of information that leads to real results. This research attempts to employ the concept of technical analysis to develop active portfolios in the ISX, so it was not open to technical analysis as it is in regional and worldwide markets. Furthermore, the study confirmed that it is feasible to construct an active portfolio that outperforms the relevant market index over the same period, resulting in an active return.