Portfolio Optimization
Kenny Darrell
Abstract
A Markowitz portfolio was examined using fifty S&P 500 stocks, with three years of return data. The portfolio minimizes variance for floor returns. This model was compared with two others; one minimized variance subject to a maximum allowable number of assets and one that minimized the number of assets used.
A portfolio is a collection of assets grouped together. An optimal portfolio is one that has characteristics that are no worse and generally better than all other combinations of assets with the exception of alternative optimal solutions. A nonlinear Markowitz portfolio will be examined using fifty stocks from the S&P 500, where their returns are ascertained from Yahoo Finance over the past three years. The analysis will use the adjusted close to calculate the return from month to month. A base model, a NonLinear Program (NLP), Optimized Portfolio Model will calculate an efficient frontier of portfolios. It will take floor values of return and find the percent allocations to each stock that will give the minimum variance, risk, and at least the floor return, for a range of returns. Two other models will be constructed from this data and compared with the base model. A Mixed Integer NonLinear Programming (MINLP) model that minimizes the variance subject to varying maximum allowable numbers of assets to be included with constraints bounding the return to that of the base model. A second MINLP model that minimizes the number of assets used for varying allowable percent deviations from the base return. Data collected from the base model will be compared with the results from the second two models. All of the optimized models are looped on varying parameters and constraints. These will be plotted in order to see trends. They should only get worse for the first model because additional constraints cannot create a better solution. The second model is a different problem with a linear objective; its goal of minimizing number of stocks in a portfolio is different from minimizing the variance. These could show any number of differences.
The stock data is all collected from Yahoo Finance. A query from the historical prices is used to collect the raw data. The above mentioned query for symbol ANF is http://finance.yahoo.com/q/hp?s=ANF&a=11&b=10&c=2007&d=10&e=10&f=2010&g=m.
This query results with dates and their associated adjusted close monthly from 10122007 to 1112010. All other output is parsed out. The exact dates and stock used can be seen in the appendix. The adjusted close is subtracted from its prior months adjusted close to obtain a return over that month. This is done over all months and stocks and then used to calculate their average returns over the three year period. This average is then subtracted from every return giving a deviation matrix. You then take the dot product of every column with every column in the matrix, and take the sample average to obtain the Covariance Matrix. This is the covariance of every stock with every stock, the key to the applicability of the model. This allows for a higher average return while hedging against risk utilizing less than perfect correlation amongst assets to reduce its overall variance.
There are assumptions that come with the Markowitz Portfolio Model and the Optimization model. Those like will the past returns be a good indicator of the future that are only associated with the Markowitz model only effect its applicability to real situations. The assumptions made in the optimization model will affect the output and its validity. One major assumption of this is that we cannot guarantee a global optimal solution. This is due to the nonlinearity of the problem. This problem is large enough to make it infeasible to exhaust all possibilities and obtain a global maximum. The local optimal value, if feasible, will be used in further analysis knowing that is better than any other nonexhaustive method would provide. Another assumption stemming from nonlinearity in the objective functions and constraints is that we don’t have stationary points. The solver could get stuck here and state the objective and constraint are infeasible. Some solutions discussed later were deemed infeasible and could be locations of stationary points, multiple starting points were used and they are heavily constrained so I believe they are infeasible. There are also assumptions stemming from the models containing binary variables. We are assuming that an optimal solution can be found, given its feasible. Having integer variables the process to reach the solution could take an unrealistic amount of time, so there is an optimum we just can’t attain it.
The above problems seemed to be occurring while modeling the NLP in Excel. Output from solver would say infeasible while AMPL would give solutions. Placing the solutions from AMPL into Excel as the starting location would find a nearly identical solution. From experience in Case Study 2 with Excel, having binary or integer decision variables seem to be very slow. For these two reasons the AMPL environment was selected. The Base Model contains two sets, or indexes, one for each stock, 1 to 50, and one for each month period, 1 to 35. These indexes are used for parameters such as the input data; it’s the return of all stocks from the stock set for each month in the month set. The columns of this return data were averaged to get the average return for all stocks. From this, as described above, the covariance matrix is constructed. A decision variable is created that will be the percent allocation to each stock. This is a value that can range from 0 to 1 for every stock. Constraints are placed on each to guarantee they do not exceed these bounds. An additional constraint is used that requires the sum of the percent allocation to be exactly one. From the percent allocations a variable is calculated called the scenario return. This is a value for every month period that is the sum of all returns in that month multiplied by the percent allocation for that stock. The portfolio return is calculated from the scenario return by summing them over all months and taking their average, the return of the portfolio for that given set of allocations. Then the optimization has all parameters and variables needed to optimize the objective function. The objective is to minimize the portfolio variance. The variance is calculated by summing all combinations of the stocks, percent allocation of stock i multiplied by percent allocation of stock j multiplied by the associated covariance of these two stocks, variance if i = j. This objective is nonlinear as it contains the product of two decision variables, the percent allocations. Then an additional constraint is added to force the return to be greater than or equal to a floor value of return.
The model for part 2 is a modification of the base model. The data is all equivalent. A new decision variable, stock allowed, is added, a binary variable that is used to represent if the stock is allowed to be contained in the portfolio or not. A value of 1 means that it can be used and a value of zero means it cannot be included in the optimized portfolio solution. The objective is the same as the base model as well. This results in a model that is nonlinear as well and having integer/binary restrictions on the decision variables. A new constraint is added that restricts the sum of all stocks allowed to be less than a value. This value is the maximum number of stock that can be included in the portfolio. Another new constraint is that the percent allocation must be less than or equal to stock allowed for a given stock. This will force it to have zero contribution if it is not allowed. One trial of model 2 ran the same return constraint as the base model. A second trial changed this constraint to not be greater than or equal to the base models return, but to be within .05 from it. This is a much more restrictive constraint.
The model for part 3 had additional input data, an added set and vector parameter. The set was integers for floor returns from the base model, its feasible solutions for floor return values from 0 to 3.6. This leads to the set having integers 1 to 36. A parameter was added that contains the variance from the base model for that floor return, the 17^{th} element is the variance of the base model for a floor return of 1.7. This model moved the variance to be a calculated variable instead of the objective. The objective function was to minimize the sum of stocks allowed, to have as few stocks in the portfolio as possible. This objective function is linear. A constraint was added that required the variance to be less than 1.1 the variance of the base model. This meant that you could have a 10 percent worse variance. The return has a constraint where it must be within a given percent deviation from that of the base model.
The base model, being an NLP, used the MINOS solver’s reduced gradient approach with a quasiNewton algorithm to obtain its solution. The optimization problem was solved over a range of floor returns until solutions were no longer feasible. This will happen at anything higher than the highest average return. The data set caused this to occur slightly before a return of 3.7, so the efficient frontier uses floor return values from 0 to 3.6.
The solution approach for model 2, being an MINLP, used the BONMIN solver’s BHyb, Hybrid outerapproximation/nonlinear programming based branchandcut, algorithm. There were required libraries and executables needed for the use of this solver as well; Cbc (Coinor branch and cut), Ipopt (Interior Point Optimizer), Lapack (Linear Algebra Package), Blas (Basic Linear Algebra Subroutines), and MUMPS (Multifrontal Massively Parallel direct Solver). This model had the same construct of solving an optimal portfolio for a floor return over a range of returns. There is an outer layer to this that will find this efficient frontier for a range of values for the constraint of stock allowed. The solver will find an optimal portfolio over the range of returns for a range of stocks allowed form 1 to 5. This leads to 5 efficient frontiers.
The solution for model 3 had a linear objective function but a nonlinear constraint in the variance, so the same BONMIN solver was used. The approach here was very similar to that of model 2, having multiple for loops. The objective, to minimize stocks used to achieve results similar to the base model, would iterate over values of return from 0 to 3.6 by .2. This set was then iterated over varying the percent deviation variable from 5% to 20% calculating the minimum number of assets used for each case. Values were recorded to log files for all cases for further analysis.
Results from the base model came in two forms; there are minimum variances for each floor return as well as a vector of percent allocations to each stock for all return values. The percent allocations would be the usable output for applications purposes but for this analysis only the return and variances will be used. The efficient frontier can be seen in Figure 1, Minimized Variance for Return Floor. It is very clear from this that as you raise your expected return your variance increases in a polynomial manner.
Figure 1, Minimized Variance for Floor Return of Base Model
The results from model 2 were of the same form. The results can be seen in Figures 2, 3, 4, 5. Figures 2 and 3 show the efficient frontiers for a constraint on the return that they must that they are simply the same floor return of the base model. The base model frontier is plotted with the frontiers that only allow 1 to 5 stocks to be included. Figure 2 shows the entire range of returns as well as the frontier for 1 stock allowable. Figure 3 removes the 1 stock allowed case and only shows a range of returns from 0 to 1. This allows for easier visualization of the trend, only allowing 1 stock gives rise to much higher variance and above a return of 1.25 all solutions are the same return of 3.6. Without this case you can see a cleaner trend, the variance is converging to the original model as the number of stocks is increased. Figure 4 and 5 are the same as 2 and 3 except for they have tighter restrictions on the return, they must be in the range of .05 from the base model. Figure 4 shows that only allowing one stock gives infeasible solutions to most points, only if there is stock that has an average return in that range. Figure 5 shows the same trend as the previous case, it will converge to the base model frontier as the number of stocks is increased.
Figure 2, Efficient Frontier for Model 2, Constraint 1 Range 03.6
Figure 3, Efficient Frontier for Model 2, Constraint 1 Range 01
Figure 4, Efficient Frontier for Model 2, Constraint 2 Range 03.6
Figure 5, Efficient Frontier for Model 2, Constraint 2 Range 01
The results from model 3 are shown in Figures 6 and 7. Figure 6 shows the number of stocks used in each portfolio of the efficient frontier of the base model as well as the minimized number of stocks to fall within a certain percentage of the base models return. You can see that every case used fewer numbers of assets than the base model. This amount also decreases as the percent in deviation is increased because you are placing smaller restrictions on the performance. This shows that it is possible to construct similar portfolios that are much simpler in their contents. This does have its drawbacks as can be seen in Figure 8 as the variance is always higher.
Figure 6, Number of Stocks used for Varying Percent Deviations from the Base Model
Figure 7, Variance and Return for Model 3
From all of this analysis the minimal variances will always increase as more constraints are placed on the solution. The minimal variance obtained with bounds on used stocks showed much worse variance than that of the corresponding base case returns. The solutions were always worse for a greater than base case return. The constraint of being in the range of the base caused most returns to be infeasible with only 1 stock, but converged as they increased. The minimal stock usage was feasible to use fewer stocks and still fall in the range of the percent deviations allowed. There were always fewer stocks used than the base model. For smaller returns fewer stocks used as the percent deviation grew, this leveled off as the returns reached and exceeded one. From all of this it is a clear that any additional restrictions will lead to higher variances and/or lower returns. These results could lead to further study of the outcome effects of additional requirements and improved with changing the size, type, and timeframe of additional assets.
*AMPL source code, raw data, reduced raw data, and output data available upon request in soft format.
Appendix A, Stock and Date info
MMM

3M Co

AZO

AutoZone Inc

ACE

ACE Limited

AVB

AvalonBay Communities Inc

ARG

Airgas Inc

BLL

Ball Corp

AKAM

Akamai Tech Inc

BAX

Baxter International Inc.

AA

Alcoa Inc

BBT

BB&T Corporation

AYE

Allegheny Energy Inc

BDX

Becton Dickinson

AGN

Allergan Inc

BBBY

Bed Bath & Beyond

ALL

Allstate Corp

BMS

Bemis Company

ALTR

Altera Corp

BRKb

Berkshire Hathaway

MO

Altria Group Inc

BBY

Best Buy Co. Inc.

AMZN

Amazon.com Inc

BIG

Big Lots Inc.

AXP

American Express Co

BIIB

BIOGEN IDEC Inc.

AMT

American Tower Corp A

HRB

Block H&R

AMP

Ameriprise Financial

SCHW

Charles Schwab

ABC

Amerisource Bergen Corp

CCE

CocaCola Enterprises

AMGN

Amgen Inc

KO

Coca Cola Co.

APH

Amphenol Corp A

COST

Costco Co.

APC

Anadarko Petroleum Corp

DTV

DIRECTV Group Inc.

ADI

Analog Devices Inc

DUK

Duke Energy

AON

Aon Corporation

F

Ford Motor

APA

Apache Corporation

GPS

Gap (The)

AIV

Apartment Inv & Mgmt

K

Kellogg Co.

AAPL

Apple Inc.

MCD

McDonald's Corp.

ADP

Automatic Data Processing

JWN

Nordstrom

AN

AutoNation Inc

ORCL

Oracle Corp.

1Nov10

1Jul10

1Mar10

2Nov09

1Jul09

2Mar09

3Nov08

1Jul08

3Mar08

1Oct10

1Jun10

1Feb10

1Oct09

1Jun09

2Feb09

1Oct08

2Jun08

1Feb08

1Sep10

3May10

4Jan10

1Sep09

1May09

2Jan09

2Sep08

1May08

2Jan08

2Aug10

1Apr10

1Dec09

3Aug09

1Apr09

1Dec08

1Aug08

1Apr08

10Dec07

Dostları ilə paylaş: 