A Mathematical Approach to a Stocks Portfolio Selection: the Case of Uganda Securities Exchange (use)

Copyright © 2013 Fredrick Mayanja et al. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited. ABSTRACT In this paper, we present the problem of portfolio optimization under investment. This area of investment is traced with works of Professor Markowitz way back in 1952. First, we determine the probability distribution of the Uganda Securities Exchange (USE) stocks returns. Secondly, we develop unrestricted portfolio optimization model based on the classical Modern Portfolio Optimization (MPT) model, and then we incorporate certain restrictions typical of the USE trading or investment environment and hence, develop the modified restricted model. Thirdly, we explore the possibility of diversification under a portfolio of averagely correlated assets. Determination of the model parameters and model development is all done using Excel spreadsheets. We explicitly go through the mathematics of the solution methods for both models. Validation of the models is done using the USE stocks daily trading data, in which case we use a random sample of 6 stocks out of the 13 stocks listed at the USE. To start with, we prove that USE stocks log returns are normally distributed. Data analysis results and the frontier curves show that our modified (restricted) model is valid as the solutions are all consistent with the theoretical foundations of the classical MPT-model but inferior to the unrestricted model. To make the model more useful, accurate and easy to apply and robust, we programme the model using Visual Basic for Applications (VBA). We therefore recommend that before applying investment models such as the MPT, model modifications must be made so as to adapt them to particular investment environments. Moreover, to make them useful so as to serve the intended purpose, the models should be programmed so as to make implementation less cumbersome .


Introduction
Portfolio Optimization also commonly referred to as Portfolio selection is the problem of allocating capital over a number of available assets in order to maximize the "return" on the investment while minimizing the "risk" [1].Research into the development of models for portfolio selection under uncertainty dates back to the fifties with Markowitz's (1959) pioneering work on meanvariance efficient (MV) portfolios [2].
Although the benefits of diversification in reducing risk have been appreciated since the inception of financial markets, the first mathematical model for portfolio selection was formulated by Markowitz [3,4].In the Markowitz portfolio selection model, the "return" on a portfolio is measured by the expected value of the ran-dom portfolio return, and the associated "risk" is quantified by the variance of the portfolio return.Markowitz showed that, given either an upper bound on the risk that the investor is willing to take or a lower bound on the return the investor is willing to accept, the optimal portfolio can be obtained by solving a convex quadratic programming problem.This mean-variance model has had a profound impact on the economic modeling of financial markets and the pricing of assets: The Capital Asset Pricing Model (CAPM) developed primarily by [5,6] was an immediate logical consequence of the Markowitz theory.Work on models for portfolio optimization continued, with much of it concentrated on improving the mean-variance (Modern Portfolio Theory) model.Developments in portfolio optimization are stimulated by two basic requirements: 1) adequate modeling of utility functions, risks, and constraints; 2) efficiency, i.e., ability to handle large numbers of instruments and scenarios [7].All models directly or indirectly emerged from the Modern Portfolio Theory model, as most research tried to make the assumptions more realistic to real life; some have incorporated transaction costs in the model [8].Others proposed alternative ways of measuring risk as opposed to use standard deviation of the stock returns.Many practitioners were not fully convinced of the validity of the standard deviation as a measure of risk [9].They are certainly unhappy to have small or negative profit, but they usually feel happy to have larger profit.This means that the investors' perception against risk is not symmetric around the mean [10].Unfortunately, however, some studies of stock prices in Tokyo Stock Market [11] revealed that most of asset returns are not normally nor even symmetrically distributed.
Also, much has been done in developing algorithms for portfolio optimization using various approaches.This is because to carry out portfolio optimization one needs some form of software, which must have in built algorithms.There are software companies dedicated to developing software for portfolio optimization, and these software are either spreadsheets applications and/programs.Most commonly used software is Solver or Optimizers; these are software tools that help users to find the "best" way to allocate resources.To carry out portfolio optimization there must be portfolios in existence, such that one seeks only to find the optimal set of weights for this portfolio.These portfolios are investment portfolios held and traded in Stock (Securities) Exchanges.Stock exchanges are markets where government and industry can raise long-term capital and investors can buy and sell securities [12].It is an organized market where buyers and sellers of securities meet as dealers/brokers represent them and acquire or sell securities.The Uganda Securities Exchange (USE) is one such market; it was established in 1998 as a result of a Government Policy of transforming the economy of the country from a public sector to the private sector basis [13].
The USE represents a vital link between companies with capital needs and the public with savings to invest.The Uganda Clays was the first company to be listed in 1999, and by 2004 there were 5 companies trading.Today USE has 13 companies listed and trading in the various securities available [14].Securities that are currently traded at the Exchange include Government Bonds, Corporate Bonds and Ordinary Shares.There are a number of individual investors, financial institutions and companies that currently hold investment portfolios among these listed companies at USE.These investors, financial institutions and companies use brokers and investment managers to trade and manage their portfolios.
These investment managers or brokers use the qualitative analysis approach of market surveillance intelligence and speculation.This is mainly because the models available for optimization of portfolios have not been customized to the Uganda Securities Market and cannot be applied in the market.The need to adapt the models arises from the fact that different assets behave differently in different investment environment [10].However, the Uganda Securities Market has developed over time and is still growing as more companies become listed at the USE; this has made the market analysis more complex.Therefore, there is need for a mathematical approach of using optimization models to analyze and manage the investment portfolios so as to complement the conservative methods currently used.To appreciate the importance of adaptation rather than adoption of investment models to various trading environments, let us briefly list down some of the characteristics of one of the developed securities exchanges-the New York Securities Exchange (NYSE) so as to have a clear comparison with the USE: The NYSE was started way back in 1792, with its first constitution adopted in 1817.NYSE is the world's largest cash equities market.Clearly, when we compare the two securities exchanges it would be wrong to assume that since a model is applicable to the NYSE then, it will also be applicable to the USE without any changes.And therefore this justifies the focus of our study on examining and testing the applicability of the classical mean-variance model to the USE.

Testing Whether Log Returns Are Normally Distributed
Six Stocks namely, British American Tobacco Uganda (BATU), Bank Of Baroda Uganda (BOBU), Development Finance Company of Uganda (DFCU), Stanbic Bank Uganda (SBU), East African Breweries Limited (EABL) and Uganda Clays Limited (UCL) were randomly selected from the 13 stocks available at the USE.
Their daily trading data was down-loaded from the USE website; www.use.org as per the The data we down-loaded was for four years , The spreadsheets used were the excel spreadsheets, this is where the stocks returns were calculated using the data.When calculating the stocks returns we used the formula; . 01 we determined the frequencies of the log returns using the "FREQUENCY" excel in built function.Using these frequencies we calculated the cumulative frequencies using the formula; And, this gave us the actual stocks i 's for the historical data.Then we simulated the cumulative frequencies for a normally distributed data set with the same mean and standard deviation as each of our stocks.Here we used the excel's "NORMDIST" function which produces cumulative frequencies that are normally distributed given the mean and standard deviation of any data set.We then plotted the actual cumulative frequencies of the historical data and the simulated normal distribution frequencies on the same graph, for each stock.The resulting graphs are as shown in Figures 1-4.

cf
From the graphs, as analyzed for each stock we see that there are some small deviations from normal distribution for the actual data but, the deviations are not significant enough for us to reject normal distribution of the log returns.These slight deviations could be because of skewness and kurtosis.However, to avoid making wrong conclusions about the distribution of our log returns we took a step further the deviations at the extreme ends are due to outliers.To accomplish this task we plotted the stocks log returns for each stock as shown in Figures 5-8.
From the results we note that these stocks have some two to three "extreme months".That is, for each stock there is a month or two where the monthly log returns are either extremely high or extremely low as compared to the average monthly returns, and this adequately explains the slight deviations between the cumulative curves.Since for real data outliers are certainly expected, we therefore comfortably concluded that the log returns of the stocks at USE are normally distributed, which confirms to the general findings that log returns are normally distributed, [15,16].Note that instead of analyzing the stocks log returns by plotting them, we could have used the method of calculating the kurtosis and skewness parameter values to determine whether they lie within the theoretical normal distribution values.But, this method was not preferred because the kurtosis and skewness values are not conclusive since they are highly dependent on the data size.In fact for the same data set, selecting different sample sizes results in to totally different parameter values for both kurtosis and skewness, [17].

Model Parameters and Model Development
The correlation of the stocks and hence correlation matrix was determined using the excel's function "CORREL" for determining the correlation, this function uses the formula; For more details about the setup of the model parameters in the excel spreadsheet and explicit results you may refer to page 45 of [1].Note that this formula is based on a sample of historical returns of any two assets, this means that the formula provides sample correlation coefficient (r) of the two assets rather than the population or "true" correlation coefficient    , That is, it might not be a true representation of the "true" correlation coefficient.Despite the problems of using a sample of historical returns to estimate the correlation coefficient between two assets [18].It remains a very popular technique among investors and investment analysts because the formula for this approach has already been pro-grammed in most calculators and spreadsheet programs.However care has to be taken when interpreting the meaning of sample correlation coefficient: Referring to our correlation matrix on page 45 [1], our sample correlation coefficient is   r ; which according to the interpretation by [18] means that our stocks returns have a random relationship.It is therefore for this very reason that we did not use Markowitz's principle of adding negatively correlated assets to the portfolio to improve it through diversification, simply because not any one of our portfolio stocks have a strong negative correlation.So we formulated a condition for an additional stock to improve the frontier of the portfolio as we shall show in the next section.For now we try to formulate and solve the MPT-model using USE data.

Mathematical Formulation of the Model
Recall that the MPT  model is a theory of investment which tries to minimize risk (standard deviation of the returns) for a given level of expected return, by carefully       choosing the proportions (weights) of various assets available.Therefore the model can be written as: That is, given the target expected rate of return of the portfolio p  , find the portfolio strategy that minimizes the portfolio variance in returns 2 p  .

The Solution Method for the n-Asset Model
First, we note that it is more convenient and easier to use vector and matrix notation, so we formulate this model in matrix notation; where , is column vector of portfolio weights for each security.Note that in this model formulation; 1) The admissible set includes short selling, i.e. portfolio positions with negative weights are allowed.

 
2) The parameter p  is exogenously given.
3) The model (5.1) is a convex quadratic programming problem (i.e., the objective function is quadratic, with linear constraints and the feasibility set S is convex).
4) The solution(s) of the program depend(s) on the parameter p  .
To avoid degeneracies we impose the following technical conditions:   .i All first and second moments of the random variables exist.
ii The vectors , e  are linearly independent.That is, no two securities can have the same expected return .We note that this is typically the case when using real data.
The covariance matrix is strictly positive definite.The positivity of the covariance matrix means that all the assets are indeed risky, and this is the case of our portfolio since we considering stocks only.

n
To illustrate why we require to be strictly positive definite, suppose; Then there exists a portfolio whose return iii hold, the model problem (5.1) has a unique solution and hence well formulated.

Solution to the Formulated Model
We therefore can proceed to determine the solution, first we note that model problem (5.1) is a constrained classical optimization problem, with equality constraints.It can therefore be solved by the Lagrangian method.The La-grangean function 1 for the model is hold, the solution to the above problem is 2 ; , with and , , , .
 and 2  depend on p  , which is the target portfolio mean prescribed in the variance minimization problem.The variables can be determined since and , a a b nd c V  are known.
1 Definition 6.1 The function L is called the Lagrangian function and the parameters  are the Lagrange multipliers, where the functions     and f X g X are twice continuously differentiable. 2For a thorough and detailed proof refer to pages 26-28 [1]. Hence is the optimal portfolio weights.For , Equation (6.1) becomes; The variance 3for the optimal portfolio The resulting frontiers of the un constrained problem above for the Lagrange method is as shown in Figure 9 with the global minimum variance portfolio marked red on the frontier 4 .However this is ideal as there are restrictions in the USE market for example no short selling, and there is a specified sum to be invested in a particular stock therefore we incorporate restrictions

Effect of Incorporating Restrictions to the Model
Imposing the restriction; , , where in general we assume that is necessary for the portfolio optimization problem to have a solution and 1 assures us that total wealth available will be invested.Our optimization problem (5.1) would therefore be: To be specific we require that the weights are nonnegative, therefore, we shall restrict Next, we now seek to write our model as a quadratic programming problem.First we recall that a quadratic programming problem has the general form: The function T X VX defines a quadratic form, the matrix is symmetric and positive, the constraints are linear which guarantees a convex solution space.The solution to this problem is based on the Karush-Kuhn-Tucker (KKT) conditions 5 .Applying the KKT conditions to the model problem above for we which we seek a solution becomes 6 ; 5 Historically, w.Karush was the first to develop the KKT conditions in 1939 as part of his M.S. thesis at the University of Chicago.The same conditions were developed independently in 1951 by W Kuhn and A. Tucker.The KKT conditions provide the most unifying theory for all non linear programming problems [19]. 6For the explicit mathematical gymnastics please refer to pages 40-42 of [1].And according to the theorem we must consider at most different cases to find the optimal solution.It is therefore very evident at this stage, what impact the weight restrictions have had on the solution procedure.This system unlike the unrestricted model we had before, cannot be solved analytically for assets.Therefore we have to seek numerical algorithms to determine the optimal solution.However, the good news is that with the current computer advancements we do not have to struggle with the algorithms.Powerful algorithms for numerical methods have been developed in various softwares.For this particular problem we shall use the excel solver , which uses the Newton Raphson algorithm to find the optimal solutions numerically.These optimal portfolio returns were plotted against the optimal standard deviation and the resulting frontier is as shown in Figure 10.

2007
In an attempt to make a comparative analysis of the effect of restriction on the level of returns we plotted both frontiers on the same graph as shown in Figure 11.
From the graph notice that the unconstrained frontier is superior to the constrained frontier.That is, for every risk level, the unconstrained frontier gives a higher or equal return as compared to the constrained frontier.Which is as expected, since constraints or restrictions on investment have a negative affect on the level of returns.This is in line with the theoretical findings [20].

Diversification under a Portfolio with Averagely Correlated Assets
In consideration of diversification constraint 4., we try to explore Mathematically the effect of increasing or reducing the number of stocks held in a portfolio on the frontier.That is, we shall examine the necessary and su-fficient conditions for a security to improve the Markowitz hyperbola (frontier).Let , , , n P S S S   be a set of n securities among which we may choose for our portfolio.Additionally, let

P P S S S S S S
Also, let p  and q  be the Markowitz hyperbolas for security sets and respectively. 0 Unique portfolio weights can be determined for securities that lie on the hyperbola as a linear function of the portfolio expected return, p , where g and h are known constants for a particular portfolio. Proof.
Recall that we have Hence, the security has a zero weight for every point on th i p  , an s ut, up ft wi d so it may be disregarded from portfolio c ideration as it does not improve the hyperbola.
on removing the security from , we are le th .That is, the set of securities that ize on B such that will be the only p  Therefore, 0 i X  , so the security is not involved. But, bo Therefore, the intersection of o Mark las must be a tangent po since the tw int.Also, owitz hyper p  and q  only intersect at one point, it is clear

Theorem
, then from Equation (8.1) we have; and we have: and from we have: Combining Equations (8.2) and ( 8.3) we get; In Equation (8.4) above we see that if ).So Since Conversely Assume Also, But recall orem we hav lso, from the 2 e;    re, Corollary 1 and Theorem together imply; Therefo 2 And, Corollary 2 s the final result t we have been seeking to prove.Corollary 2 provides a necessary and n for some security, , to improve a Markowitz hyperbola.
This will be so provided the add hat sufficient conditio do when es not hold.If one wonders how this is so; does not hold, Corollary 2 im ies that then pl p q    .saw that But, from proo when f of we  

9.
study, we have identified that the USE stock market as a whole is stochastic, as there are no particular months where all stocks returns are low or high, and each st s ha r all correlation coefficient

Conclusions
In this ock behaves randomly.This is seen from the graphs showing individual stocks performance-Figures 5-8, in which case we concluded that the stock ve a random relationship as their ove We have also noted that the "BATU volatile stock among them all but, still the st profitable amo sample of the 6 stocks.
" stock is the mo ng a We have proved that the log returns of e USE stocks are normally distributed, which implies th eir returns We have also discussed in detail the M thematics and theoretical advancements behind the classical MPT-mo-agai USE the data analysis results agree with the theory.First, we ve showed that the plot of stocks returns against their s dard deviation h g m agreement w d Finally, we found out that the solution of the unresm is superior (for every level of risk, ot ne wor va del and tested these arguments nst the stocks data for which we have found out that ha tan (risk) is a hyperbola for both the unrestricted and the restricted optimization model problem.Secondly, we ave also noted that increasin the number of stocks in the portfolio i proves the frontier, which is in ith the MPT-model theory.However, since our portfolio assets ha a random relationship we could not rely on Markowitz's idea.So we have provided a condition that each extra additional stock should satisfy so as to improve the frontier.In other words, it is not necessarily true that every additional stock improves a frontier.It will only do so as long as Corollary 2 condition is satisfied.
tricted model proble the unrestricted frontier gives an equal or higher level of returns as compared to the restricted frontier of the same portfolio) to that of the restricted model problem, this as seen from Figure 11, in which the two frontiers were plotted together.
Though the Mathematics involved is tedious and at times complex in general, the users of these models do n ed to ry because with the current computer ad-

Recommendations
We recommend the use of computer programmes as they help to enhance the performance of the optimization software and also automate the various calculations that ould other wise be performed manually in spreadsheets.w We also, recommend financial institutions and any other investors who use investment models to always examine, test and adapt these models to their investment environment before applying or using them to make investment decisions, since most of these models have underlying assumptions which have diverse implications mathematically, financially and economically for different investment environment.
In the study of the effect of imposing certain restrictions we focused mainly on the mathematical implications.We therefore, recommend that further research should be done on the economic and financial implications of the modifications or restrictions like restricting the weights with in particular bounds, number of stocks held in a portfolio, cost constraints, administrative and policy restrictions on the MPT-model in the context of the USE investment environment.A more realistic model that incorporates such factors as: brokerage costs (commissions), the Uganda Capital Markets Authority (CMA) regulatory constraints, taxes, inflationary rates, central depository costs and foreign exchange movements (as there are cross listings in the USE market) needs to be developed so as to reflect the true picture of the USE trading environment.
Finally, there is need to revisit the lassical MPTenvironment.Such modi-CAPM (which was model), so as a direct consequence of the c to modify it to suite the USE fications can start from the most obvious issues like correcting the beta ) ( estimations of the various companies in the USE (as there is a common mistake of assuming 1 =


) for most companies, to more in depth mathematical analysis behind the CAPM so as to adapt it to the USE environment.This is very important since the CAPM is used in the valuation of capital assets in the investment sector in Uganda to date.


the covariance matrix of the returns.is the desired level of expected return for the portfolio.
risk averse, it is still possib hem e portfolio risk by incr sing the numb

.Figure 12 .
normal distribution.ncements a number of softwares have been developed ready to use with out bothering about the Mathematics.a Diversification based on corollary 2 be the only value of p