large scale portfolio - stanford university · ms&e 348 project 5 the other way to introduce...

27
MS&E 348 Project 1 Large Scale Portfolio Optimization ________________ Alex Bezjian, Andrei Pugachev, and Siu Taur Pang

Upload: others

Post on 29-May-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 1

Large Scale Portfolio

Optimization

________________ Alex Bezjian, Andrei Pugachev,

and Siu Taur Pang

Page 2: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 2

Introduction There exist two approaches to portfolio management: the first one is passive and

the second one active. In the first approach, an investor is putting all his or her money

into an index fund in which all stocks are weighted in proportion to their market

capitalization. Thus, he or she is assuming the market to be efficient. In the second

approach, the investor is performing an analysis of the performance and prospects of

different stocks and, based on this analysis, determines the portfolio that meets his or her

needs. With dramatic advances in the computational power available, the quantitative

approach to active portfolio management becomes more and more popular. However, the

brute computational power in itself can only help the investor to calculate his profits (or

losses, if he is less lucky) faster. In order to perform the portfolio selection using

quantitative approach, we not only need a computing device (e.g. calculator, PC,

mainframe) but also a model that is capable of reflecting each individual’s preferences

and expressing them in a strict mathematical way. Generally, there are always some

characteristics of a portfolio that the investor wants to maximize (for example, it can be

yearly return or it can be the probability of getting $1M several years earlier when

becoming terminally ill, in order to have some time to enjoy the money). At the same

time, there are quantities the investor wants to minimize, such as volatility or the

probability of going bankrupt right before becoming informed that his or her decease, that

was considered to be terminal, now can be cured for that $1M that was lost month

earlier… As we can easily see from these examples, a portfolio selection problem can be

always interpreted as an optimization problem.

In this paper, we investigate several different models that can be used for portfolio

optimization. The rest of the paper is organized as follows. In the next section, Models

and Methods, we will describe the models we have studied as well as the data and

methodology we have used. The section Implementation will explain how these models

were implemented. Finally, the sections Results and Conclusions will provide analysis of

the results and a conclusion.

Page 3: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 3

Models and Methods Throughout this section, we are going to use following notations:

i asset (stock of a company i)

t time period tiR~ historical return of asset i in time period t

jiQ , covariance matrix )~,~cov( tj

ti RR

ix fraction of money invested in asset i

ρ desired expected return

Markowitz model The model we are going to present first is the classical Mean Variance Model

(Markowitz, 1959).

∑ji

jjii xQxT ,

,1min

∑ ≥ti

iti xR

T ,

1s/t ρ

∑ =i

ix 1, max0 xxi ≤≤

Here tiR and t

iR are defined as follows:

∑=

=T

t

tii R

TR

1

~1

RRR ti

ti −= ~

As can be seen from the problem definition above, the historical returns were used as

predictors of future ones. We also imposed the requirement maxxxi ≤ to ensure that the

optimal portfolio is diversified. In this study, we used diversification limit 06.0max =x .

The detailed reasoning behind this particular selection of maxx value is given in the

Appendix.

(P-1)

Page 4: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 4

The problem (P-1) is a convex quadratic problem that can be easily solved.

However, if the number of assets to be considered is large, the time required for

optimization can grow drastically. To resolve this complication, we should recall that a

covariance matrix jiQ , was calculated from the historical returns. Therefore, covariance

matrix Q can be decomposed as RRQ T= . Using this decomposition, the Markowitz

model can be rewritten as:

∑t

tt vvT1min

∑ ≥ti

iti xR

T ,

1s/t ρ

0=+−∑ t

ii

ti vxR

∑ =i

ix 1, max0 xxi ≤≤

Here the variable tv is introduced. As can be easily seen, the problem (P-2) has the same

solution as (P-1). However, considering the fact that the number of time periods, T, is

significantly smaller than the number of stocks, N, the introduction of tv allows for a

significant reduction of the size of the problem.

Markowitz model, active risk The performance of the portfolio can be judged against a chosen benchmark

portfolio, whose role is frequently played by an index fund. This allows one to compare

the returns and risks of the selected portfolio to those of the market. In our study, stocks

of the S&P 500 universe were analyzed, thus the S&P 500 index was used as the

benchmark portfolio.

The most obvious way to introduce benchmarking to the problem (P-2) is to

adjust all returns, substituting tiR by )()~~(ˆ

500&500& PSit

PSti

ti RRRRR −−−= . Here, t

PSR 500&~

is the historical return and 500&PSR is the mean return of the S&P 500 portfolio.

(P-2)

Page 5: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 5

The other way to introduce benchmarking is to substitute holdings ix with the

active holdings ii wx − , where iw is the weight of an asset in the benchmark portfolio.

We have chosen the second approach, as being more elegant. Thus, problem (P-2) was

transformed into the following one:

∑t

tt vvT1min

∑ ≥−ti

iiti wxR

T ,

)(1s/t ρ

0)( =+−−∑ t

iii

ti vwxR

∑ =i

ix 1, max0 xxi ≤≤

From now on, ρ represents the desired excess return on the benchmark. The active risk,

which is going to be used instead of the variance for analysis of the results, is defined as

∑∑ =−−=t

tt

jiijjiii vvwxQwxRisk

,, )()(

and represents the risk as the deviation from the benchmark portfolio.

Half Markowitz model

The classical Mean Variance Model can be slightly modified:

∑ −−t

tt vvT1min

∑ ≥−ti

iiti wxR

T ,

)(1s/t ρ

0)( =+−−∑ t

iii

ti vwxR

∑ =i

ix 1, ttt vvv −+ −=

max0 xxi ≤≤ , 0 ,0 >> −+tt vv

(P-3)

(P-4)

Page 6: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 6

In this formulation, by including only the negative part of tv into the objective function

only underperforming stocks are penalized.

Mean Absolute Deviation (MAD) model

This model is identical to the Markowitz model except for the objective function

expression.

∑ −+ +t

tt vvT1min

∑ ≥−ti

iiti wxR

T ,

)(1s/t ρ

0)( =+−−∑ t

iii

ti vwxR

∑ =i

ix 1, ttt vvv −+ −=

max0 xxi ≤≤ , 0 ,0 >> −+tt vv

As can be seen, this is a linear programming problem. Therefore, it can be solved faster

than quadratic Markowitz model.

Half MAD mode

As in the case of Markowitz model, the corresponding half model can be defined

for the Mean Absolute Deviation model as well. It differs from the original MAD model

by the form of the objective function:

∑ −t

tvT1min

∑ ≥−ti

iiti wxR

T ,

)(1s/t ρ

0)( =+−−∑ t

iii

ti vwxR

(P-5)

(P-6)

Page 7: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 7

∑ =i

ix 1, ttt vvv −+ −=

max0 xxi ≤≤ , 0 ,0 >> −+tt vv

Again, by including only the negative part of tv into the objective function only

underperforming stocks are penalized.

Factor Model

Historical returns R can be decomposed using principal component analysis:

εε +=+= FRUFR .

Here, the first twenty principal components are used as factors F. The matrix U

represented the corresponding factor loadings, FR is the factor-explained returns and ε

is the “unexplained” part of returns. The covariance matrix has the following form:

DRRT

Qt

tjF

tiFi,j +≈ ∑1 ,

where D is a diagonal matrix. The corresponding programming problem can be written

as:

∑∑ +−−t

tt

iiiiiii vv

TwxDwx 1)()(min ,

∑ ≥−ti

iitiF wxR

T ,

)(1s/t ρ

0)( =+−−∑ ti

ii

tiF vwxR

∑ =i

ix 1, max0 xxi ≤≤

As can be seen, the size of the problem (P-7) is bigger than the size of any of the

previously considered models due to the term where summation over all the stocks is

performed. As the result of this size increase, a much longer time was required to find an

optimal solution of this problem.

(P-7)

Page 8: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 8

Data and Methodology

In this study, the S&P 500 universe of stocks was used. Some stocks were

excluded from the allowed set due to their “abnormal” behavior, such as splitting, going

bankrupt, etc. Two data sets of historical returns were used. The in-sample set consisted

of historical returns for years 1997 through 1999. The out-of-sample data set consisted of

returns for the year 2000. As will become evident later, these two sets are completely

different in terms of the market performance.

To compare the performance of different models, the following approach was

used. First, for each model an efficient frontier was obtained using the in-sample data.

Second, for each portfolio belonging to the efficient frontier, return and active risk were

calculated using out-of-sample data. Third, predicted (calculated for the in sample data)

returns and risks were compared to the corresponding parameters calculated for the out-

of-sample data. Based on this comparison we drew a conclusion on the robustness of

each model.

Implementation

Markowitz Model The five models were implemented in GAMS. The code for the Markowitz model

can be found in Appendix 2. The program starts with declaring and setting the

independent variables that will be used. These include the excess return over the S&P500

that we wish to achieve, σ, and the diversification limit of 6%.

We also define the index weight in our model differently from the parameter

definitions. Since not all of the S&P 500 stocks are included in our universe, we have to

adjust the weight of each stock so that our benchmark portfolio is also fully invested.

The actual Markowitz model is implemented via 5 equations. We define the

objective function (which is the in-sample active risk), make sure that we achieve the

Page 9: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 9

excess returns, ensure that we are fully invested, calculate our artificial variable as well as

keep each stock under the diversification limit.

We then declare the dependent variables, which are contingent upon the results of

our optimization. These include the in sample and out of sample active risks as well as

the out of sample returns of our portfolio.

We then ran the model by varying σ from 0% to 4%, in increments of 0.04. Note

that these are monthly returns, and any portfolio that aims to out-perform the S&P500 by

48% annually is indeed remarkable. For each value of σ, we obtained an optimal

portfolio by minimizing the objective function (in-sample active risk) and then calculated

the corresponding out of sample statistics for that portfolio. These results were written

into text files, which were then visualized in MATLAB to give us our graphs.

In practice, the program ran quickly for each value of σ (not more than 10

seconds most of the time) and we were able to do 100 iterations in about 5-10 minutes.

Half-Markowitz, MAD and Half-MAD models

For these models, the code is exactly the same as for the Markowitz model except

for the model definition. Appendix 3 contains the corresponding code for each of these

models. They are similar to the Markowitz model, except that we partition the artificial

variable v(t) into v+(t) and v-(t), both of which are non-negative. (ie v= v+ - v-)

For the Markowitz model, we took the sum of v2 as the objective function. This

changed to v-2 for the half-Markowitz. The MAD model uses the sum of v+ and v- while

the half-MAD model uses the only the sum of the v-. The rest of the code is similar.

The run-time for these models was approximately equal to that of the Markowitz

model. They are slightly slower (because we have to partition the artificial variable v) but

not appreciably so.

Page 10: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 10

Factor Model

For the factor model, an additional variable called the “deviation” is introduced.

While v(t) measures the under- or over-performance of the portfolio with respect to the

S&P 500 index, the deviation measures the amount by which each stock is “wrongly

predicted” by our factors.

The objective function consists of two terms. The first one, which sums over the

427 stocks, minimizes the deviations from the predicted returns. The second one is just

the active risk which sums over the 36 time periods. Thus, this objective function

includes more variables and the actual run-time is much slower than that of the preceding

models. Each run of 100 iterations took about an hour to complete. This is because our

reason for creating an artificial variable was to speed the program up by reducing the size

of the Hessian matrix. The deviation term defeats that because it re-introduces all 427

weights back into the objective function.

Results and Conclusions Results The results for each of the five models are organized as follows: For each of the

five models we analyze four separate aspects of the data. The first part is how our out of

sample return changes as we increase σ. The second graph checks to see if out of sample

risk is always greater than the in sample risk for all values of σ, as it should be. The third

graph takes a look at how the in sample risk relates to the out of sample risk. Finally, we

compare the performance of the portfolio in-sample versus the portfolio out-of-sample.

Once we are finished analyzing the models one by one, we study the performance

of all five models together with respect to return and then variance.

One can see that for each model the out of sample return tends to decrease as σ is

increased. This is the opposite effect that one would expect since σ is our desired return

given the in sample data. One plausible explanation for this is that larger values of σ

Page 11: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 11

cause the model to choose higher variance stocks which did well in the in sample period.

However, these same high variance stocks performed quite poorly in the out of sample

period. The net result is that if you wanted a lower return on your portfolio you ended up

outperforming those who preferred a higher return. This effect dominates the results and

is attributed to the fact that stock performance for the in sample period is nearly opposite

of that in the out of sample period.1 You would be hard pressed to find two more

conflicting consecutive periods of stock performance in American history.

Also, the out of sample risk is always greater than or equal to the in sample risk

across the model. In fact the only instance where it hold with equality is for very tiny

values of σ in the factor model. Otherwise, the out of sample risk is always greater than

in sample and significantly so in most cases.

The reason why this is true is because our portfolio minimizes the in-sample risk,

while the out-of-sample risks result from our choice of portfolio. Hence, it is necessarily

true that the out-of-sample risk will be higher.

We calculated the correlation coefficient between the in sample and out of sample

risks for each of the models.

Model Correlation Coefficient

Markowitz 0.5233

Half-Markowitz 0.8681

MAD 0.9842

Half-MAD 0.9782

Factor 0.9932

Table 1

As we can see in Figure 1, the out-of-sample risk for the Markowitz model tends

to be more arbitrary. However, for the other models, the in sample risk is quite a good

predictor of the out of sample risks.

When it comes to portfolio performance it is difficult to come to any conclusions

for the Markowitz model. It seems that in sample performance is a poor predictor of how

the out of sample portfolio will do. This seems to be true for the other models as well,

1 Our adjusted S&P 500 grew by about 3.8% monthly in sample but fell by 0.8% monthly out of sample.

Page 12: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 12

however we do start to notice an interesting pattern as we run through the models. The

messiness of the Markowitz model (Figure 1) begins to smooth out. This progression

continues until we arrive at the factor model (Figure 5), which has the smoothest looking

out of sample performance of all the models. What these curves more or less resemble is

an inverted efficient frontier. Again, this makes perfect sense given the out of sample

behavior of the data. Riskier portfolios yielded a worse return than those that were more

conservative. Once more, although the results at first seem counterintuitive, they are

clearly understood once one considers the out of sample stock performance.

Finally we compare each of the models together on the basis of out of sample

return and then risk. Surprisingly, the Half-Markowitz model performs the best in terms

of return with the Half-MAD model not far behind. As the “Half’ models only penalize

returns below the mean, it is only expected that they would perform better in an

anomalous situation like this. Figure 6 demonstrates that for all the models there is a

discernible downward trend. This could distort the return data, and make any conclusions

on return less reliable.

Figure 7 shows us a comparison of the out-of-sample risks. The risks of the

different models don’t seem to demonstrate and discernible patterns in comparison to one

another save one. The risk of the factor model is quite lower for smaller values of σ (σ ≤

2) than the other models. Therefore, this is the model I would choose if I want to

outperform the S&P 500 by a little bit and, at the same time, keep my active risk low.

It is also possible to see from these 2 graphs that for high values of σ, the MAD

and Half-MAD models tend to converge. This is reflected in the portfolios that were

being generated by our optimizer as well.

Conclusion The fact that the out of sample period is so markedly different from the in sample

period means that the data set in our project provides an excellent “stress-testing” tool.

By this, we mean that even when our predicted return is not accurate at all, our portfolio

optimizers can still be used to estimate the risk of our portfolio in the out-of-sample

period.

Page 13: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 13

In that respect, other than the Markowitz model, all of the rest perform very well.

As we see from the correlation coefficients, we are able to explain over 97% of the out of

sample risk just by using the in sample risk (in the MAD, Half-MAD and factor models).

Thus, as a risk management tool, our optimizers do a reasonably good job.

We would like to include that caveat that our return predictors are based on

historical data. Of course, one can use other predictors in our model to get better return

figures, especially in cases where there is such a great difference in stock performance.

So, depending on what our objectives are, we should use different models.

Appendix IV shows a sample output of our optimizers, using the Markowitz model to

generate a portfolio which simulates the S&P 500. This portfolio had near-zero active

risk (i.e. it was similar to the S&P 500 in terms of risk) but out-performed it out of

sample by about 0.38% monthly. Thus, our optimizers can give us low-risk portfolios that

are better than the benchmark. (This is only true because the S&P 500 is an arbitrary

portfolio based on market capitalization instead of any optimization procedure)

On the other hand, we can use the optimizers to create high risk portfolios whose

out of sample risks can be predicted quite accurately. With our data set, these portfolios

would have crashed but given more prosperous times would result in much higher

returns.

To conclude, we remark that we were unable to predict the returns with any

acceptable accuracy but there was a remarkably strong correlation between the in sample

and out of sample risks for the MAD, Half-MAD and factor models. Thus, we would

definitely use those models to control for risks. And depending on whether we expect a

bear or bull market in our out of sample period, we would use either the Half-MAD (in a

bear) or the Factor Model (in a bull) to maximize our returns.

Page 14: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 14

Appendix 1: Derivation of 6% limit

At first, we chose a limit of 5% for the diversification limit. This was due to two

reasons. Firstly, the highest weight of any stock in the S&P 500 was 5% (Microsoft).

Secondly, we can derive the variance of a portfolio by summing the variance-covariance

matrix.

If we have N stocks, then the variance of the portfolio would be equal to

(1/N) (avg variance of each stock) +(1 – 1/N) (avg covariance of pairs of stocks)

As N increases, the first term drops to zero so the performance of each individual stock

matters less while the covariances become more important. At the limit as N tends to

infinity, the second term becomes the market alpha.

Once N increases beyond 20, any potential decrease in portfolio variance would

be below less than 1/20 of the current variance and hence any further increase in N would

not significantly reduce the variance. A diversification limit of 5% ensures that we would

at least have 20 stocks.

However, as we are limited to the 427 stocks in our universe, we had to adjust the

S&P weights in our portfolio. This meant that we ended up with Microsoft’s weight

being more than 5%. In our adjusted S&P 500 portfolio (i.e. our benchmark), Microsoft’s

weight was about 5.6%. This meant that we had to increase our diversification limit or

our benchmark portfolio would violate our parameters. We then chose to increase our

limit to 6%.

Even with our limit of 6%, the portfolios chosen by our optimizers typically

included more than 30 stocks. See Appendix 4 for a sample portfolio which illustrates

this.

Page 15: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 15

Appendix 2: GAMS Code for Markowitz Model * MSandE348 Prof. Gerd Infanger * model portf -- portfolio optimization $onempty; $offlisting; $offsymxref; $offuellist; * including data files * --------------------------------------------------------- $include "/afs/ir/class/msande348/portf.inc" $include "/afs/ir/class/msande348/portft.inc" * --------------------------------------------------------- * Documentation of sets available: * * set j assets * set yj(j) allowed * set w periods in sample * set t periods out of sample * * Documentation of parameters available * * parameter rbar(j) mean returns * parameter r(w, j) returns * parameter rf(w, j) factor explained returns * parameter rt(w, j) out-of-sample returns * * parameter wu(j) index weights of assets * ----------------------------------------------------------------------------- option limrow = 0, limcol =0; option reslim = 10000; option iterlim = 10000; option solprint = off; option lp = minos5; option nlp = minos5; file rhos /rhosp.dat/, invars /invarsp.dat/, orets /oretsp.dat/, ovars /ovarsp.dat/ ; Scalar rho minimum return we wish to achieve ; Scalar maxl maximum amount you can put into one stock /0.06/ ; Scalar intime number of insample periods ;

Page 16: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 16

intime = sum(w, 1) ; Scalar tot sum of the SP500 stocks in our universe; tot = sum (yj, wu(yj)) ; Parameter wx(yj) adjusted SP weight of stock yj ; wx(yj) = wu(yj)/tot ; variables x(yj) weight of stock j v(w) artificial variable objf the objective function ; Positive variable x ; Equations objective sumisone Ereturn whatisv(w) maxlimit(yj) ; sumisone .. sum(yj, x(yj)) =e= 1 ; Ereturn .. sum(yj, rbar(yj)*(x(yj)-wx(yj))) =g= rho ; whatisv(w) .. cv(w) =e= sum(yj, (r(w,yj)-rbar(yj))*(x(yj)-wx(yj))) ; objective .. objf =e= sum(w, v(w)*v(w)) ; maxlimit(yj) .. x(yj) =l= maxl ; Scalar SPret SP500 return out-of-sample; Scalar Oreturn portfolio out-of-sample return ; Scalar Ovar portfolio out-of-sample active risk ; Scalar Otime number of out-of-sample periods ; Scalar Invar portfolio in-sample active risk ; Parameter Orbar(yj) this is the mean outofsample return ; Otime = sum(t, 1) ; Orbar(yj) = sum(t, rt(t,yj))/Otime ; SPret = sum(yj, wx(yj)*Orbar(yj)) ; model var /all/ ; for (rho = 0 to 4 by .01, solve var using nlp minimizing obj ;

Page 17: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 17

Oreturn = sum(yj, x.l(yj)*Orbar(yj) ) ; Ovar = sum(t , sqr( sum(yj, (x.l(yj)-wx(yj))*(rt(t,yj) - Orbar(yj)) ) ) )/Otime ; Invar = sum(w, sqr( sum(yj,(x.l(yj)-wx(yj))*(r(w,yj) - rbar(yj)))))/intime ; rhos.ap = 1 ; invars.ap = 1 ; orets.ap = 1 ; ovars.ap = 1 ; put rhos rho ; put / ; put invars Invar ; put / ; put orets Oreturn ; put / ; put ovars Ovar ; put / ; display rho, obj.l, Oreturn, Ovar, SPret; ) ;

Page 18: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 18

Appendix 3: Alternative model definitions Half-Markowitz Model Variables

x(yj) weight of stock j v(w) artificial variable objf the objective function vm(w) vminus vp(w) vplus ;

Positive variable x, vp, vm ; Equations

objective sumisone Ereturn whatisv(w) absv(w) maxlimit(yj) ;

sumisone .. sum(yj, x(yj)) =e= 1 ; Ereturn .. sum(yj, rbar(yj)*(x(yj)-wx(yj))) =g= rho ; whatisv(w) .. v(w) =e= sum(yj, r(w,yj)-rbar(yj))*(x(yj)-wx(yj)) ; absv(w) .. v(w) =e= vp(w) - vm(w) ; objective .. objf =e= sum(w, vm(w)*vm(w)) / intime ; maxlimit(yj) .. x(yj) =l= maxl ; MAD (Mean Absolute Deviation) Model variables

x(yj) weight of stock j v(w) artificial variable objf the objective function vp(w) vplus vm(w) vminus ;

Positive variable x, vp, vm ; Equations

objective sumisone Ereturn whatisv(w) absv(w)

Page 19: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 19

maxlimit(yj) ; sumisone .. sum(yj, x(yj)) =e= 1 ; Ereturn .. sum(yj, rbar(yj)*(x(yj)-wx(yj))) =g= rho ; whatisv(w) .. v(w) =e= sum(yj,(r(w,yj)-rbar(yj))*(x(yj)-wx(yj))) ; absv(w) .. v(w) =e= vp(w)-vm(w) ; objective .. objf =e= sum(w, vp(w) + vm(w)) ; maxlimit(yj) .. x(yj) =l= maxl ; Half-MAD Model variables

x(yj) weight of stock j v(w) artificial variable objf the objective function vp(w) vplus vm(w) vminus ;

Positive variable x, vp, vm ; Equations

objective sumisone Ereturn whatisv(w) absv(w) maxlimit(yj) ;

sumisone .. sum(yj, x(yj)) =e= 1 ; Ereturn .. sum(yj, rbar(yj)*(x(yj)-wx(yj))) =g= rho ; whatisv(w) .. v(w) =e= sum(yj,(r(w,yj)-rbar(yj))*(x(yj)-wx(yj))) ; absv(w) .. v(w) =e= vp(w)-vm(w) ; objective .. objf =e= sum(w, vm(w)) ; maxlimit(yj) .. x(yj) =l= maxl ; Factor Model variables

x(yj) weight of stock j v(w) artificial variable objf the objective function dv(yj) deviation of stock j ;

Positive variable x ; Equations

Page 20: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 20

objective sumisone Ereturn deviatn(yj) whatisv(w) maxlimit(yj) ;

sumisone .. sum(yj, x(yj)) =e= 1 ; Ereturn .. sum(yj, rbar(yj)*(x(yj)-wx(yj))) =g= rho ; whatisv(w) .. v(w) =e= sum(yj, (rf(w,yj)-rbar(yj))*(x(yj)-wx(yj))) ; objective .. objf =e= sum(w,v(w)*v(w))/intime+sum(yj,sqr(x(yj)-wx(yj))*dv(yj) deviatn(yj) .. dv(yj) =e= sum(w,sqr(rf(w,yj)-r(w,yj)))/intime ; maxlimit(yj) .. x(yj) =e= maxl ;

Page 21: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi

MS&E 348 Project 21

Appendix 4: Sample Output

GAMS 2.25.087 SUN/SPARC 03/14/01 23:12:11 PAGE 5G e n e r a l A l g e b r a i c M o d e l i n g S y s t e mE x e c u t i o n

---- 47818 PARAMETER RHO = 0.000 minimum return wewish to achieve

VARIABLE OBJ.L = 0.000 the objectivefunction

PARAMETER ORETURN = 0.262 this is theoutofsample return

PARAMETER OVAR = 5.551 this is theoutofsample risk

PARAMETER SPRET = -0.798 this is the SP500return outofsample

---- 47818 VARIABLE X.L weight of stock j

BAC 0.028, BAX 0.060, BBBY 0.002, BDK 0.017BMY 0.004, CAG 0.036, CC 0.010, CI 0.041CL 0.060, COMS 0.020, CTX 0.021, DNY 0.002EK 0.024, EMC 0.033, ETN 0.004, FRE 0.037HCR 0.046, IKN 2.667246E-4, KMB 0.032, MEA 0.007MSFT 0.060, MWD 0.037, NMK 0.006, NWL 0.009ORCL 0.023, PAYX 0.014, PBI 0.002, PCS 0.060PFE 0.060, QCOM 0.025, QTRN 0.007, RX 0.016SLR 0.024, SMI 0.007, STT 5.348680E-4, TJX 0.038TUP 0.022, UK 0.034, WFC 0.027, WIN 9.782050E-4WMI 0.013, YHOO 0.032

**** REPORT FILE SUMMARY

RHOS /afs/ir.stanford.edu/users/s/t/stpang/mse348/newsp/rhosp.datINVARS /afs/ir.stanford.edu/users/s/t/stpang/mse348/newsp/invarsp.datORETS /afs/ir.stanford.edu/users/s/t/stpang/mse348/newsp/oretsp.datOVARS /afs/ir.stanford.edu/users/s/t/stpang/mse348/newsp/ovarsp.dat

EXECUTION TIME = 0.183 SECONDS VERID SUN-25-087

Page 22: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi
Page 23: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi
Page 24: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi
Page 25: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi
Page 26: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi
Page 27: Large Scale Portfolio - Stanford University · MS&E 348 Project 5 The other way to introduce benchmarking is to substitute holdings xi with the active holdings xi −wi, where wi