A Mathematical Approach To A Stocks Portfolio Sele PDF
A Mathematical Approach To A Stocks Portfolio Sele PDF
Received August 23, 2013; revised October 23, 2013; accepted November 6, 2013
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 Securi-
ties Exchange (USE) stocks returns. Secondly, we develop unrestricted portfolio optimization model based on the clas-
sical Modern Portfolio Optimization (MPT) model, and then we incorporate certain restrictions typical of the USE trad-
ing 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 de-
velopment 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 nor-
mally 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 cum-
bersome.
Keywords: Portfolio Optimisation; Uganda Securities Exchange (USE); Stocks; Modern Portfolio Theory (MPT);
Markowitz; Portfolio Diversification; Frontier; Efficient Frontier; Constraints
basic requirements: 1) adequate modeling of utility func- These investment managers or brokers use the qualitative
tions, risks, and constraints; 2) efficiency, i.e., ability to analysis approach of market surveillance intelligence and
handle large numbers of instruments and scenarios [7]. speculation. This is mainly because the models available
All models directly or indirectly emerged from the Mo- for optimization of portfolios have not been customized
dern Portfolio Theory model, as most research tried to to the Uganda Securities Market and cannot be applied in
make the assumptions more realistic to real life; some the market. The need to adapt the models arises from the
have incorporated transaction costs in the model [8]. fact that different assets behave differently in different
Others proposed alternative ways of measuring risk as investment environment [10]. However, the Uganda
opposed to use standard deviation of the stock returns. Securities Market has developed over time and is still
Many practitioners were not fully convinced of the growing as more companies become listed at the USE;
validity of the standard deviation as a measure of risk [9]. this has made the market analysis more complex. There-
They are certainly unhappy to have small or negative fore, there is need for a mathematical approach of using
profit, but they usually feel happy to have larger profit. optimization models to analyze and manage the invest-
This means that the investors’ perception against risk is ment portfolios so as to complement the conservative
not symmetric around the mean [10]. Unfortunately, methods currently used. To appreciate the importance of
however, some studies of stock prices in Tokyo Stock adaptation rather than adoption of investment models to
Market [11] revealed that most of asset returns are not various trading environments, let us briefly list down
normally nor even symmetrically distributed. some of the characteristics of one of the developed se-
Also, much has been done in developing algorithms curities exchanges-the New York Securities Exchange
for portfolio optimization using various approaches. This (NYSE) so as to have a clear comparison with the USE:
is because to carry out portfolio optimization one needs The NYSE was started way back in 1792, with its first
some form of software, which must have in built algo- constitution adopted in 1817. NYSE is the world's largest
rithms. There are software companies dedicated to deve- cash equities market. It is the world's largest stock ex-
loping software for portfolio optimization, and these change by market capitalization of its listed companies at
software are either spreadsheets applications and/pro- US 11.92 trillion, with an average trading value of
grams. Most commonly used software is Solver or Opti- approximately US 153 billion, as of August, 2008. It
mizers; these are software tools that help users to find the provides a means for buyers and sellers to trade shares of
stock in companies registered for public trading. It opens
“best” way to allocate resources. To carry out portfolio
for trading Monday - Friday between 9:30 am - 4:00 pm.
optimization there must be portfolios in existence, such
All NYSE stocks can be traded via its electronic Hybrid
that one seeks only to find the optimal set of weights for
Market, and customers do send orders for immediate elec-
this portfolio. These portfolios are investment portfolios
tronic execution. In 2007, NYSE joined a merger with
held and traded in Stock (Securities) Exchanges. Stock
some other stock exchanges to form; NYSE Euronext,
exchanges are markets where government and industry
and as of March, 31, 2011, NYSE Euronext has approxi-
can raise long-term capital and investors can buy and sell
mately 7950 listed issues, a total global market capitali-
securities [12]. It is an organized market where buyers
zation of US 26.4 trillion and it’s equity exchanges
and sellers of securities meet as dealers/brokers represent
transact an average daily trading value of approximately
them and acquire or sell securities. The Uganda Se-
US 83.6 billion www.nyse.org, 09th.06.2011 . Clear-
curities Exchange (USE) is one such market; it was
ly, when we compare the two securities exchanges it
established in 1998 as a result of a Government Policy of
would be wrong to assume that since a model is app-
transforming the economy of the country from a public
licable to the NYSE then, it will also be applicable to the
sector to the private sector basis [13].
USE without any changes. And therefore this justifies the
The USE represents a vital link between companies
focus of our study on examining and testing the appli-
with capital needs and the public with savings to invest.
cability of the classical mean—variance model to the
The Uganda Clays was the first company to be listed in
USE.
1999, and by 2004 there were 5 companies trading. To-
day USE has 13 companies listed and trading in the va-
rious securities available [14]. Securities that are current-
2. Testing Whether Log Returns Are
ly traded at the Exchange include Government Bonds,
Normally Distributed
Corporate Bonds and Ordinary Shares. There are a num- Six Stocks namely, British American Tobacco Uganda
ber of individual investors, financial institutions and (BATU), Bank Of Baroda Uganda (BOBU), Develop-
companies that currently hold investment portfolios ment Finance Company of Uganda (DFCU), Stanbic
among these listed companies at USE. These investors, Bank Uganda (SBU), East African Breweries Limited
financial institutions and companies use brokers and (EABL) and Uganda Clays Limited (UCL) were ran-
investment managers to trade and manage their portfolios. domly selected from the 13 stocks available at the USE.
Their daily trading data was down-loaded from the USE different sample sizes results in to totally different para-
website; www.use.org as per the 18t h.01.2011. The meter values for both kurtosis and skewness, [17].
data we down-loaded was for four years 2007 - 2010 ,
The spreadsheets used were the excel 2007 spread- 3. Model Parameters and Model
sheets, this is where the stocks returns were calculated Development
using the data. When calculating the stocks returns we
The correlation of the stocks and hence correlation ma-
used the formula;
trix was determined using the excel’s function “CORREL”
Closing Price for determining the correlation, this function uses the for-
Ri ,
Previous Closing Price mula;
n n n
we determined the frequencies of the log returns using nxi yi xi yi
the “FREQUENCY” excel in built function. Using these r i 1 i 1 i 1
frequencies we calculated the cumulative frequencies n 2 n 2 n 2 n 2
using the formula; nxi xi n yi yi
i 1 i 1 i 1
And, this gave us the actual stocks cfi ’s for the his- i 1
torical data. Then we simulated the cumulative frequen- For more details about the setup of the model para-
cies for a normally distributed data set with the same meters in the excel spreadsheet and explicit results you
mean and standard deviation as each of our stocks. Here may refer to page 45 of [1]. Note that this formula is
we used the excel’s “NORMDIST” function which pro- based on a sample of historical returns of any two assets,
duces cumulative frequencies that are normally distri- this means that the formula provides sample correlation
buted given the mean and standard deviation of any data coefficient (r) of the two assets rather than the population
set. We then plotted the actual cumulative frequencies of or “true” correlation coefficient , That is, it might
the historical data and the simulated normal distribution not be a true representation of the “true” correlation coe-
frequencies on the same graph, for each stock. The re- fficient. Despite the problems of using a sample of histo-
sulting graphs are as shown in Figures 1-4. rical returns to estimate the correlation coefficient be-
From the graphs, as analyzed for each stock we see tween two assets [18]. It remains a very popular techni-
that there are some small deviations from normal dis- que among investors and investment analysts because the
tribution for the actual data but, the deviations are not formula for this approach has already been pro- grammed
significant enough for us to reject normal distribution of in most calculators and spreadsheet programs. However
the log returns. These slight deviations could be because care has to be taken when interpreting the meaning of
of skewness and kurtosis. However, to avoid making sample correlation coefficient:
wrong conclusions about the distribution of our log re-
turns we took a step further the deviations at the extreme Sample Correlation Coefficient Interpretation
ends are due to outliers. To accomplish this task we 0.3 r 1.0 Positive relationship
plotted the stocks log returns for each stock as shown in 0.3 r 0.3 Random relationship
Figures 5-8. 1.0 r 0.3 Negative relationship
From the results we note that these stocks have some
Referring to our correlation matrix on page 45 [1], our
two to three “extreme months”. That is, for each stock
sample correlation coefficient is r ; 0.15 r 0.3
there is a month or two where the monthly log returns are
which according to the interpretation by [18] means that
either extremely high or extremely low as compared to
our stocks returns have a random relationship. It is there-
the average monthly returns, and this adequately explains
fore for this very reason that we did not use Markowitz's
the slight deviations between the cumulative curves.
principle of adding negatively correlated assets to the
Since for real data outliers are certainly expected, we
portfolio to improve it through diversification, simply
therefore comfortably concluded that the log returns of
because not any one of our portfolio stocks have a strong
the stocks at USE are normally distributed, which con-
negative correlation. So we formulated a condition for an
firms to the general findings that log returns are normally
additional stock to improve the frontier of the portfolio as
distributed, [15,16]. Note that instead of analyzing the
we shall show in the next section. For now we try to
stocks log returns by plotting them, we could have used
formulate and solve the MPT-model using USE data.
the method of calculating the kurtosis and skewness
parameter values to determine whether they lie within the
theoretical normal distribution values. But, this method
4. Mathematical Formulation of the Model
was not preferred because the kurtosis and skewness Recall that the MPT model is a theory of investment
values are not conclusive since they are highly dependent which tries to minimize risk (standard deviation of the
on the data size. In fact for the same data set, selecting returns) for a given level of expected return, by carefully
n n
1
Minimize ij X i X j
2 i 1 j 1 Then there exists a portfolio whose return X T p
has zero variance. This implies that p 0 , essentially,
n
that this portfolio is risk less. But, this contradicts the
Subject to X i i p idea that our portfolio consists of only risky assets. At
i 1
this stage, before we attempt to solve our formulated
n
and X i 1 problem there is need to see whether the problem has
i 1 been well formulated. That is whether a unique solution
That is, given the target expected rate of return of the exists.
portfolio p , find the portfolio strategy that minimizes Proposition 1.
the portfolio variance in returns 2p . Model problem (5.1) is a convex quadratic problem
with a unique convex solution.
5. The Solution Method for the n-Asset Proof.
Model The function X T VX defines a quadratic form. The
matrix V is symmetric and positive definite (from
First, we note that it is more convenient and easier to use condition iii ), this means that z is strictly convex.
vector and matrix notation, so we formulate this model in The constraints are linear, which guarantees that S is a
matrix notation; convex solution space. Moreover condition ii implies
1 T that the gradients of the constraints are linearly indepen-
Minimize z X VX , s.t dent, which guarantees a unique solution. Therefore, if
2 (5.1)
conditions i ii and iii hold, the model problem
S X Rn X T p , X T e = 1 (5.1) has a unique solution and hence well formulated.
where X X 1 , X 2 , , X n , is column vector of port-
T
Hence
T
X * X 1* , X 2* , , X n*
X * V 1 1e 2
is the optimal portfolio weights. For n 6 , Equation
can be solved. Where (6.1) becomes;
The variance3 *p
is given by
for the optimal portfolio X
2 *
7. Effect of Incorporating Restrictions to the
Model
2 a 2p 2b p c Imposing the restriction; a X b a, b, X R n , where
*p . in general we assume that
d
i 1ai 1, j 1b j 1
n n
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 hold.
Note that i 1ai 1 is necessary for the portfolio
n
on the frontier4.
optimization problem to have a solution and j 1b j 1
n
However this is ideal as there are restrictions in the
USE market for example no short selling, and there is a assures us that total wealth available will be invested.
specified sum to be invested in a particular stock there- Our optimization problem (5.1) would therefore be:
fore we incorporate restrictions
Minimize Z r
1 T
2
X VX , s.t Sr X R n X T p , X T e 1, a X b a, b, X R n
To be specific we require that the weights are non- we have 0 X b . Our problem therefore is:
negative, X 0 therefore, we shall restrict a 0 , So
Minimize Z r
1 T
2
X VX , s.t Sr X R n X T p , X T e 1, X 0, X b, 0, b, X R n (7.1)
Next, we now seek to write our model as a quadratic The function X T VX defines a quadratic form, the
programming problem. First we recall that a quadratic matrix V is symmetric and positive, the constraints are
programming problem has the general form: linear which guarantees a convex solution space. The
solution to this problem is based on the Karush-Kuhn-
Minimize Maximize Z CX X T DX Tucker (KKT) conditions5. Applying the KKT conditions
to the model problem above for we which we seek a
Subject to AX b, X 0 X x1 , x2 , , xn
T
solution becomes6;
C c1 , c2 , , cn
T
b b1 , b2 , , bm
T
X T V 1e 2 aT bT I 0
a11 a1n d11 d1n IX S b X Te 1 X T p
A D 5
Historically, w. Karush was the first to develop the KKT conditions in
a d
m1 amn n1 d nn 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
3
A reader is advised to refer to pages 29-30 of [1] for the proof. non linear programming problems [19].
4 6
For a detailed proof of how the global minimum variance portfolio is For the explicit mathematical gymnastics please refer to pages 40-42 of
determined please refer to pages 30-32 of [1]. [1].
ce b e a p b
hi
X * V 1
p
will be the only p such that
d
X i gi hi p 0
*
cV 1
e bV 1 p e aV 1 p bV 1
X if hi 0 ; that is, *p will be the only value of p at
d
which the Markowitz hyperbolas p and q intersect.
X *
cV 1
e bV 1 aV 1
p bV 1 p e That is because
d d gi
*p , X i gi hi p 0 .
X *
cV 1
e bV 1 aV 1
bV 1e
p
hi
p q . we have:
V e
b 1 Proof.
1
V (8.2) From Corollary 1 have; gi hi 0 if p q .
i c i
Also, from theorem 2 we have;
and from
a V 1
b V 1 e
gi hi 0 iff V 1e V 1
i
i
0.
i i
Therefore, Corollary 1 and Theorem 2 together im-
we have:
ply;
V e 1
i
a 1
b
V i
(8.3) V V e
1
i
1
i
0 iff p q .
Combining Equations (8.2) and (8.3) we get; And, Corollary 2 s the final result that we have been
seeking to prove. Corollary 2 provides a necessary and
b 2 1
b
a 1
V i
c
b 1
V a V 1
i
i
c
V i
(8.4) sufficient condition for some security, S n 1 , to improve
a Markowitz hyperbola.
In Equation (8.4) above we see that if V 1 i
0, This will be so provided the addition of the Sn 1 to
the existing security set (portfolio) P S1 , S2 , , Sn
then we conclude
is such that the new covariance matrix Vnew , which
b2
a , includes Sn 1 , is invertible and the condition;
V
c 1 1
new Vnew e 0
which implies ac b 2 , and that d ac b 2 0 , which n 1 n 1
is impossible!(refer to the proof of claim 1 , where we does not hold. If one wonders how this is so; when
proved that d ac b 2 > 0 ). So V 1 0 . V1
1
Vnew 0
i
Since c V 1e b V 1 , but V 1 0 which new n 1
e
n 1
i 1 i i
implies that also, c V e 0 . But c > 0 therefore, does not hold, Corollary 2 implies that then p q .
1
V e 0 . Hence
i
i
But, from proof of theorem 1 part iii. we saw that
gi hi 0 if V 1e V 1 i
i
0. when p q , these two have only one tangent point
and therefore one of the two hyperbolas is greater than
Conversely, the other. And in this case it is the hyperbola of the
Assume portfolio to which an extra security has been added that
V e V
1 1 is greater than the original one.
0. However, since the stocks in our portfolio have a
i i
does not hold, if and when this condition does not hold
Also, then the new stock added will improve the frontier. We
started with a portfolio of three stocks namely; DFCU,
1
d
a V 1 b V 1 e
i
0.
i
BOBU and SBU with covariance matrix V , then we
added a new stock UCL and computed the new cova-
1
But recall riance matrix Vnew 4 and Vnew 4 , checked the condition
and found that;
hi
1
d
a V 1 b V 1 e
i
. So,
i
hi 0 .
V 1
new 4 Vnew
1
4e 0 ,
which implies gi hi 0 .
Corollary 2
V 1
new5 Vnew
1
5e 0
V V e
1
i
1
i
0 iff p q
and upon plotting the three frontiers together on the same
graph, we observed that the frontier for the portfolio of
5 stocks was above that of the 4 stocks which in turn was del and tested these arguments against the USE stocks
above that of 3 stocks, as shown in Figure 12. data for which we have found out that the data analysis
Therefore our condition for diversification as derived results agree with the theory. First, we have showed that
in in chapter 3 , Corollary 2 is valid and applicable for the plot of stocks returns against their standard deviation
the USE (restricted) model. Hence, an investor can still (risk) is a hyperbola for both the unrestricted and the
reduce portfolio risk even when his/her portfolio is made restricted optimization model problem. Secondly, we
up of stocks only. Therefore, even for investors who are have also noted that increasing the number of stocks in
less risk averse, it is still possible for them to reduce the portfolio improves the frontier, which is in agreement
portfolio risk by increasing the number of stock in a port- with the MPT-model theory. However, since our port-
folio. folio assets had a random relationship we could not rely
on Markowitz’s idea. So we have provided a condition
9. Conclusions that each extra additional stock should satisfy so as to
improve the frontier. In other words, it is not necessarily
In this study, we have identified that the USE stock
true that every additional stock improves a frontier. It
market as a whole is stochastic, as there are no particular
will only do so as long as Corollary 2 condition is satis-
months where all stocks returns are low or high, and each
fied.
stock behaves randomly. This is seen from the graphs
Finally, we found out that the solution of the unres-
showing individual stocks performance—Figures 5-8, in
tricted model problem is superior (for every level of risk,
which case we concluded that the stocks have a random
the unrestricted frontier gives an equal or higher level of
relationship as their over all correlation coefficient ;
0.15 0.3 returns as compared to the restricted frontier of the same
We have also noted that the "BATU" stock is the most portfolio) to that of the restricted model problem, this as
volatile stock among them all but, still the most profi- seen from Figure 11, in which the two frontiers were
table among a sample of the 6 stocks. plotted together.
We have proved that the log returns of the USE stocks Though the Mathematics involved is tedious and at
are normally distributed, which implies that their returns times complex in general, the users of these models do
have a log normal distribution. not need to worry because with the current computer ad-
We have also discussed in detail the Mathematics and vancements a number of softwares have been developed
theoretical advancements behind the classical MPT-mo- ready to use with out bothering about the Mathematics.