This action might not be possible to undo. Are you sure you want to continue?

ALEX FURGER AND DANIEL JIANG Abstract. Given a set of assets, Markowitz Portfolio Theory [5] develops the idea of a minimum variance portfolio, also called the “Markowitz” portolio. We consider the point of view of a retail, individual investor who wishes to hold a low-risk portfolio, rebalanced weekly. Such an investor suﬀers from certain limitations that large companies (banks, hedge funds, etc.) do not have. These limitations include small initial capital and limited computing resources. Consequently, sparsity of the portfolio and limited trading during each rebalance become attractive features. We formulate an optimization model for this problem using quadratic and mixed-integer programming, We then demonstrate, using a simulation, that trading strategies, realizable under our investor’s limitations attain near minimal risk.

1. Introduction 1.1. The Markowitz Portfolio. Markowitz Portfolio Theory [5] uses meanvariance analysis on the return vector of a set of assets to construct a portfolio that achieves a given expected return while minimizing the variance, or risk, of the portfolio. As in [3], due to the diﬃculty of correctly estimating the expected return, we consider the overall minimal risk portfolio with no expected return constraints. We represent a portfolio by identifying the weight, or fraction, of each asset contained in the portfolio. Denote w ∈ Rn (a vector of n asset weights) as the Markowitz Portfolio if it satisﬁes the following minimization: minimize (1.1)

w

w Cw

subject to w 1 = 1

where C = Var(r) denotes the covariance matrix of the asset returns vector r. Hence, the variance of the portfolio can be written as Var(w r) = w Cw. 1.2. Limitations of a Retail Investor. We consider the point of view of a retail, or individual, investor who wishes to hold a low risk portfolio, rebalanced weekly. We assume that the investor is subject to a ﬁxed trading cost per transaction, regardless of the number of shares traded. A retail investor using one of several popular online brokers, such as E*TRADE® or Ameritrade® , would likely be subjected to a similar ﬁxed trading cost regime rather than be charged per share of stock traded.

1

Because a retail investor trades on a relatively small scale (compared to larger companies like banks or hedge funds), there are several limitations that we need to consider in the formulation of our problem. They are as follows: – Small initial capital. This implies, in particular, that trading costs cannot be considered negligible for a retail trader. In fact, we must pay particular attention to the number of trades that are made during the weekly rebalance and reﬂect it in our model. For example, consider a retail investor who wishes to hold the weeklyrebalanced Markowitz Portfolio wM K for a set of 50 stocks. Assuming wW K has all non-zero components and each rebalance requires a change in position for 20% of the stocks (a conservative assumption), then for a ﬁxed trading cost of $15 per trade over 52 weeks, $15 · 50 · 0.2 · 52 = $7800 needs to be allotted for trading costs alone. For a retail investor with under $100,000, this is a signiﬁcant amount of money. Therefore, we must penalize the number of trades made while controlling the risk. – Requirement for a sparse portfolio. From the standpoint of portfolio management, a sparse portfolio is clearly desirable for any investor. More importantly, however, a sparse portfolio is more likely to be realizable for a retail investor with limited capital. For an investor M holding initial capital X, we need to invest Xwi K into stock i. But, M K is small, and maybe so small that for a non-sparse portfolio, wi M Xwi K is less than the cost of one share of stock i. – Limited computing resources. Our model must be eﬃciently solvable without the need for high computing power. 2. Model 2.1. Overview. Let wt ∈ Rn be the portfolio (of n assets) to be held at time t, rebalanced from wt−1 . Note that in the problem formulated above, t ˆ is measured in weeks. Let Ct,m be the estimated covariance matrix at time t using the last m available data points (daily data is used in this example). The l0 -norm of a vector v, denoted by v 0 , is deﬁned as the number of non-zero components of v. We use the l0 -norm to model both sparsity and the number of trades made at each rebalance. Therefore, when rebalancing at time t and using a constant m data points for covariance estimation, we wish to minimize the following, subject to wt 1 = 1: ˆ — Variance: wt Ct,m wt — Number of stocks held: wt 0 — Number of trades made: wt − wt−1 0 We could formulate an optimization problem by minimizing the weighted sum of these terms subject to the constraint wt 1 = 1. Because the l0 -norm can be modeled using binary variables, the following mixed-integer-quadratic

2

When taking into account the need for an investor to perform parameter calibration (for λ1 and λ2 ) computation times of this magnitude are unacceptable. We apply this technique using FamaFrench Three Factor Model. The sample covariance estimator requires a large sample size to produce a good estimator. However. We can think of such an estimator as being a good “local” approximation. The Stage 1 optimization is exactly (1. Covariance Estimation using a Factor Model. which models the excess returns of an asset 3 . we propose a method that solves two separate optimization problems instead. Let wM K be the optimal solution t to the following QP: minimize (2. a QP with continuous variables. Therefore. we apply factor models as in [2] to estimate C. while also controlling the sparsity and number-of-trades terms. quadratic programs (QP) and a mixed-integer programs (MIP) can be much more eﬃciently solved. For user-speciﬁed weights λ1 and λ2 : minimize (2. Now.2.program (MIQP) would solve our problem. In order to use a small but recent set of samples. and call it our “target” portfolio.3. to address eﬃciency. we compute the Markowitz ˆ Portfolio for the estimated Ct.1) wt ˆ wt Ct.2) wt ˆ wt Ct. We hypothesize that the covariance matrix estimated using more recent data will more closely represent the actual covariance for the next week. we can apply a technique used in [1] to construct a portfolio using limited number of assets to mimic the behavior of a target portfolio. First. separately.1) using ˆ the covariance matrix estimation Ct.m wt + λ1 wt 0 + λ2 wt − wt−1 0 subject to wt 1 = 1 2. This two-stage problem is much more eﬃciently solved than the combined MIQP represented by (2.m wt subject to wt 1 = 1 The Stage 2 optimization problem uses wM K as its target portfolio and t can be written as: minimize (2.m . We solve a MIP (only linear constraints) that returns a portfolio that most closely “matches” the target portfolio. in the sense that l1 -norm of the diﬀerence is small. based on the assumption that recent data will more strongly capture the current events impacting the market.1).3) wt wt − wM K t 1 + λ1 wt 0 + λ2 wt − wt−1 0 subject to wt 1 = 1 2. Unfortunately. Alternative Two-Stage Optimization.m . a high dimensional MIQP program is not easy to solve.

and asset’s book-to-market ratios [4]. Note that this estimator can be applied to cases even when the number of data points is less than or on the order of the number of assets. We note that this constraint is realistic in the setting of our problem because a retail investor is unlikely to take any extreme long or short positions in any one asset. Thus. Let wc be the t optimal solution to (2.6) can be formulated explicitly as a QP and MIP. the estimator is: (2. where ft are the Fama-French factors at time t. The excess return y of stock i at time t is modeled by yit = bi ft +uit .5) wt 1=1. the accumulation of errors can be avoided. t 4 . asset’s market capitalizations. ˆ 2. bi are factor loadings determined by linear regression.5.5): minimize (2.6. in the form of w 1 ≤ c. Regardless of how C is ˆ is a noisy estimate of C.7). which means the portfolio will be near 130% long and 30% short. Adding a Gross Exposure Constraint. (2. cov(ft ) is the sample covariance estimator and cov(ut ) is a thresholded sample covariance estimator whose formula we will omit. A typical value of c is 1. (2. w 1 ≤c w Cw ˆ w Cw 1 ≤c ˆ wt Ct.6) wt ≤c wt − wc t 1 + λ1 wt 0 + λ2 wt − wt−1 0 subject to wt 1 = 1 2.4. Formulation for Optimization Software. and uit is an error term.2) and (2. Suppose that: w∗ = argminw ˆ w∗ = argminw Then: ˆ ˆˆ |w∗ Cw∗ − w∗ Cw∗ | ≤ am c2 where am is the maximum component wise estimation error.4) ˆ C = cov(yt ) = Bcov(ft )B + cov(ut ). It was shown in [3] that by adding a gross exposure constraint.3) can be updated as follows. Then.5) and (2. we expect estimated.using common factors: the market’s return. it remains true that C ˆ w Cw to be extremely noisy due to the accumulation of errors. We use a nonnegative vector x to represent the l1 constraint and binary vectors y and z along with a large constant M to approximately represent the l0 constraint linearly in the binary vectors y and z. our estimated portfolio is the solution to: minimize (2. wt Then.m wt 1 subject to wt 1 = 1. Let wc be the optimal solution to (2. As in [2]. w 1=1.

8) To see why M is needed.minimize wt ˆ wt Ct.7) minimize wt x 1 + λ1 y 1 + λ2 z 1 − x ≤ wt − wc ≤ x t − M y ≤ wt ≤ M y − M z ≤ wt − wt−1 ≤ M z x≥0 y ∈ {0. then the components of v are forced between −1 and 1 when allowed to be nonzero. consider v 0 and a binary vector b. Introducing the constant M will thus remedy this problem. However. 1}n subject to wt 1 = 1 (2. Then. if we simply use −b ≤ v ≤ b. We can consider the components of b to be indicators for the nonzero components of v. 5 . 1}n z ∈ {0. minimizing v 0 is equivalent to minimizing b 1.m wt x 1≤c − x ≤ wt ≤ x x≥0 subject to wt 1 = 1 (2.

We ﬁrst examine simulated data. ft ) from 2011 and a variable “warm-up” period of m days. ΣB ). The model has the form ft = µ+Φft−1 + t . With these components and assuming Gaussian distributions for bi and ut . A summary of the process is described below. . 3. . we have all of the necessary information to generate simulated returns using the factor model. positive deﬁnite estimate of Σu is created. Next. (1) Generate {bi }50 independently from N3 (µB .2. generated as in Section 5 of [2] using T data points of daily returns and factor data (yt . b50 ) . Disc. i=1 6 . Stock Selection. see [2].2. ˆ 3. .1. Cons. which has the form of a diagonal matrix plus a rank 1 matrix. Then. Energy Financials Health Care Industrials IT Materials Telecom Utilities MCD WMT XOM WFC JNJ GE AAPL DD T SO AMZN PG CVX JPM PFE UTX MSFT MON VX D DIS KO SLB C MRK CAT IBM FCX CTL DUK HD PM COP BRK. the least squares estimator of the factor loadings B is determined according to yt = Bft + ut .3. We use the model described above to examine the problem where the retail investor is interested in building a portfolio out of these 50 stocks for the year 2011.2. Data 3. The following method is used to sample (note that a single “sample” consists of an entire sample path for each of the 50 stocks). Set B = (b1 . First. Cons.A ABT MMM GOOG DOW CCI EXC CMCSA PEP OXY BAC UNH BA ORCL PX S NEE Figure 1. There are two steps to this process: Calibration and Sample Generation. a sparse. Stap. the top 5 companies of each sector by market capitalization.2. Top 5 companies in the S&P500 of each sector by market capitalization 3. Sample Generation. . To attain empirical results. Simulated Stock Data.1. Calibration. A VAR(1) model is also ﬁtted according to historical factors ft . as shown in Figure 1. we considered a representative subset of the S&P500. for the full technical details. µB and ΣB are estimated ˆ to create a 3-dimensional normal distribution from the rows of B.

. Single sample of 50 simulated stocks Figure 3. Σu ). T . .(2) Generate {ut }T independently from N50 (0. t. . t=1 (3) Generate {ft }T from the VAR(1) model ft = µ + Φft−1 + t=1 (4) Calculate yt = Bft + ut for t = 1. Actual returns of the 50 stocks 7 . . Figure 2.

We found that in general.2. We considered intervals of the form [0. if λM AX is too large. Procedure Summary.1. Simulation 4. we consider λ ∈ λ2 1 [0. From the point of view of a retail investor beginning to trade in January 2011 who wishes to hold a weekly-rebalanced. wlast ← 0 while t < end do returns ← getPreviousReturns(m) f actors ← getPreviousFactors(m) ˆ Ct. λ1 and λ2 values beyond λM AX = 0. 0. we investigate the performance of our optimization model. Ranges for the two parameters λ1 and λ2 of (2. 2011.15] and λ2 ∈ [0. In general. See the Appendix for source code. We simulate the trading strategy using these assumptions from the ﬁrst trading day of 2011 until the last trading day of 2011. In addition. yet are realizable under the constraints of a retail investor. factors) c ˆ wt ← optimizeStageOne(Ct. Parameter Selection. The following summarizes our highest level function.8) need to be found so that the resulting portfolios exhibit low volatility. Hence. end ← Dec 30.05 exhibit these undesired behaviors.4.05].m ) c wt ← optimizeStageTwo(wt . then no trades 2 will occur after the ﬁrst week because trading becomes too heavily penalized. On the other hand. these ranges need to be user-calibrated and one should not expect these ranges to be appropriate for any trading period. MATLAB and Gurobi were used to implement and run the simulation. If λM AX is too 1 2 1 large: as λ1 increases toward λM AX the optimal portfolios tend toward a 1 portfolio that is 100% invested in a single stock because sparsity becomes heavily rewarded. 2011 m ← number of previous data points to use for covariance estimation t ← start.7) and (2. start ← Jan 3. λM AX ] and [0.15 and 1 M AX = 0.m ← estimateCov(returns. which simulates weekly rebalancing over a year. 8 . which we cannot have because positive deﬁniteness implies convexity in the QP (Gurobi will not optimize otherwise) and we expect the true covariance matrix to be positive deﬁnite (all covariance matrices are positive semi-deﬁnite). wlast ) t ← computeWeekLastTradingDay(t) wlast ← wt end while 4. λM AX ]. we must choose the number of data points to use for covariance matrix estimation. Using fewer than m = 100 points produces covariance matrices that are not positive deﬁnite. low variance portfolio. 0.

with the horizontal grid being measured in weeks. Results 5. we show an example that visualizes the evolution of a portfolio as it is rebalanced weekly throughout a year. 5. Example of Optimal Portfolios. m = 100 is used for the simulation. In this subsection. we can see that often. Trades (a change in the weight of a particular stock from one week to the next) are illustrated by color changes. The vertical axis represents stocks and the horizontal axis represents time. positions are held constant for weeks at a time.Since we are aiming to use data for covariance matrix estimation that is as recent as possible. these portfolios rarely consist of more than 15 stocks and hold from 10-15 the large majority of the time.03 9 . Moreover. Weekly optimal portfolios for λ1 = 0. At least qualitatively.03 and λ2 = 0. Figure 4 shows a sequence of portfolios generated by the optimization model using moderate levels of both λ1 and λ2 . due to the penalized trading term of the objective function. we can see that the portfolios represented in this ﬁgure constitute a realizable strategy under the limitations of a retail investor. We note that out of 50 stocks. Figure 4.1.

12 0.57) 11.55) 10.75 ± (1.05 ± (1.87 ± (1.54) 10.96 ± (1.10) 10.02) 10.98 ± (1.00 0. λ2 ) in the ranges speciﬁed above on both real data and 50 samples of simulated data for the year 2011.53) 10.77 ± (1.00 8.45 ± (1.01 8.94 ± (1.21) 10.66 ± (1. 5.01 ± (0.77 ± (1.04 ± (0.58) 0.87 ± (1.20) 10.55) 11.03) 9.15 0.1.66 ± (1.50) 11.99) 9. and the starting portfolio size for each trading strategy (i.58) 0.59) 10.04) 8. each parameter pair).e.07 ± (1.97) 8. Tables and Plots.5.2. Detailed Simulation Results..62) 0.19 ± (1.94 ± (1.97) 8.56) 11.09 0.97) 8.59) 0.77 ± (1.05 8.23) 10.03 8.94 ± (1.01 ± (1.08 ± (1.90 ± (1.00 ± (1.01 ± (0.04 8.08) 8.78 ± (1.76 ± (1. A simulation was ran for 36 pairs of (λ1 .09 ± (1.51) 0.77 ± (1.93 ± (1. λ1 .56) 11.04) 9.2.06 ± (1.20) 10.21) 10.11 ± (1.02 8.67) Table 1.03 0.53) 11.54 ± (0.22) 10.52) 10.57) 10. Mean Annualized Volatility ± (Standard Deviation) for 50 samples of Simulated Data with m = 100 Figure 5.06 0.04) 10.04 ± (1.02 ± (0. λ2 0. the total number of trades in 2011.98) 8.76 ± (1. The following tables and plots summarize the results of the simulation by examining annualized volatility of the returns for 2011. Mean Annualized Volatility for 50 Samples of Simulated Data with m = 100 10 .05 ± (1.

Annualized Volatility for Real Data with m = 100 11 .12 0.88 11.94 Table 2.06 0.05 10.11 0.λ1 .78 10.15 0.00 10.51 11.08 9.75 11.69 9.84 10.32 9.82 9.69 9.09 0.30 11.76 9.28 0.31 11.29 11.19 11.35 0.00 9.31 11. λ2 0.04 10.43 11.70 9.30 9.48 9.77 11. Annualized Volatility for Real Data with m = 100 Figure 6.50 11.59 0.56 0.00 0.81 11.03 10.12 9.01 10.85 10.02 10.28 11.75 11.11 10.24 11.03 0.

16 ± (16.04 97 87 60 39 39 33 0.86) 12.12 ± (38.00 562.36 ± (7.33) 6.16) 75.80 ± (2.60 ± (1.00 0.35) 37.83) 48.98) 169.09 0.54 ± (1.42 ± (1.λ1 .33) 6.42 ± (1.02 19.93) 24.18 ± (39.60 ± (1.94 ± (17.33) 6.03 19.62 ± (2. λ2 0.12 0.68) 7.54 ± (1.91) 243. Mean Starting Portfolio Size ± (Standard Deviation) for 50 Samples of Simulated Data for m = 100 12 .28) 70.03) 77.24) 35.03 162 136 92 71 60 41 0.93) 496.03) 9.28) 18.18) 0.00 ± (1.80 ± (2.68) 7.18) 0.86) 12.64) 269.18) Table 5.60 ± (1.06 0.18) 0.68) 7.60 ± (1.02 314 230 172 119 93 79 0.35) 0.90 ± (61.98) 32.25) 23.42 ± (1.60 ± (1.60 ± (46.15 0.47) 345. λ2 0.54 ± (1.02 287.36) 236.62 ± (2.00 ± (1.62 ± (2.06 0.00 ± (1.24 ± (65.62 ± (2.68 ± (12.42 ± (1. Mean Total Trades ± (Standard Deviation) for 50 Samples of Simulated Data for m = 100 λ1 .12 0.05 19.15 0.80 ± (2.01 19.02 ± (20.80 ± (2.54 ± (1.00 ± (1.59) 206.42 ± (1.03 0.37) 371.17) 112.44 ± (28.55) 99.18 ± (42. Total Trades for Real Data for m = 100 λ1 .56 ± (9.24 ± (48.03) 9.22 ± (24.05 47.40 ± (8.71) 0.78 ± (20.24 ± (13.60 ± (20.46 ± (28.03 144.04) 45.15 0.06) 56.94 ± (31.38) 92.60 ± (1.04 81.22) 127.68) 7.68) 7.18) 0.52 ± (9.03 0.80 ± (2. λ2 0.73) 0.00 ± (1.03) 9.64) 33.88 ± (23.00 560 503 393 288 236 234 0.03 0.54 ± (1.42) 213.08 ± (6.84 ± (34.00 19.86 ± (9.03) 9.46 ± (13.04 19.12 0.54) Table 3.09 0.68) 7.64) 59.33) 6.43) 26.54 ± (1.86) 12.88 ± (28.33) 6.28 ± (9.32 ± (46.42 ± (1.40) 5.01 577.08 ± (10.00 ± (1.03) 9.22 ± (13.00 0.40) 5.33) 6.40) 5.28) 135.80 ± (2.14 ± (13.03) 0.40) 5.09 0.03) 9.86) 12.36 ± (9.40) 5.86) 12.01 564 385 279 191 155 121 0.06 0.63) 46.18) 0.62 ± (2.92 ± (31.62 ± (2.05 58 54 35 28 20 16 Table 4.32 ± (10.40) 5.86) 12.00) 0.00 0.

we see that the overall trend for λ2 still holds. Tables 3 and 4 show the same trend in number of trades. the volatilities of our strategy’s returns are in line with annualized volatilities presented in [3]. the retail investor can heavily penalize trading without suﬀering a signiﬁcant increase in risk.λ1 . the overall shape of Figure 6 still follows that of Figure 5. Second.12 0. there is a trade-oﬀ between a realizable (sparse enough) portfolio vs.06 0. but λ1 diﬀers slightly from the simulated data results in that the volatilities decrease slightly before increasing. Based on the real data. volatility. increasing λ1 (restricting total number of assets) increases volatility. As expected. From the volatility results for real data (Table 2 and Figure 6). In the case of increasing λ1 . increasing λ2 (restricting the number to trades) has little eﬀect on volatility. Tables 5 and 6 also exhibit the expected trend. This is because λ2 has no eﬀect on the starting portfolio size (the term is ignored in the simulation for the ﬁrst week). Therefore.03 0. Conclusions. However. the annualized volatility for the S&P500 during 2011 was calculated to be 21.15 0. number of trades decreases with both increasing λ1 and increasing λ2 . As one would expect.04 16 10 8 6 6 6 0. we can see two general trends.09 0. 13 . this means that when selecting λ1 . Based on the volatility results for simulated data (Table 1 and Figure 5). In addition.3.00 0. unless a signiﬁcant event occurs. we see from these results that one valid strategy is selecting a low-risk and sparse (realizable) portfolio at the beginning of the year and holding it for the entire year. In both tables.03 16 10 8 6 6 6 0.01 16 10 8 6 6 6 0.8%. this is expected because more sparsity means fewer possibilities of trading. increasing λ1 corresponds to a sparser portfolio. For the retail investor. First. In particular.05 16 10 8 6 6 6 Table 6. λ2 0. Starting Portfolio Size for Real Data for m = 100 5.00 16 10 8 6 6 6 0. The volatilities of our strategy’s returns using both simulated and real data were signiﬁcantly lower than that of the S&P500. no changes occur as λ2 increases.02 16 10 8 6 6 6 0.

J. E. 14 . R. H. and Soucy. 39. [4] Fama. 3320-3356. (2012). Zhang. Common risk factors in the returns on stocks and bonds. Van Otterloo and Company. 7 77-91. J. Y. M. (1952). Portfolio selection. 49-66). R. F. Journal of Econometrics.References [1] Bertsimas. Mayo... Portfolio Construction Through Mixed Integer Programming at Grantham. K. (2011). (1993). and Yu. Journal of Financial Economics. M. J. Asset Allocation and Risk Assessment with Gross Exposure Constraints for Vast Portfolios. 147. 186197. (1999). and French. High Dimensional Covariance Matrix estimation in Approximate Factor Models. Darnell. Liao. 33 (1993) 3-56. D. K. [2] Fan. Journal of Finance. [3] Fan.. [5] Markowitz. C. The Annals of Statistics. and Mincheva. Interfaces 29: 1 January-February 1999 (pp.

6.num days:curr ind−1. FAMA=1.. ret] = unpack stocks(obj. sd. curr port = zeros(size(obj. last returns. obj.stocks.trade cost = trade cost.. timestamps). cov = calc cov(args.. obj. num days.num days = num days. last rf = .. %find the array locations for total sim period curr ind = sd. args) [timestamps. obj. :).. results = [].stocks = stocks. obj.last factors. last returns = ..1). rf. Appendix: MATLAB Source Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 classdef Simulator properties(Constant) REG=0. obj. last factors = obj.... ed. ret(curr ind−obj..num days:curr ind−1. last rf).2).:). end function [results opt ports] = simulate(obj. first week = 1. ..factors = factors...factors(.rf = rf. curr ind−obj.('cov type'). end properties stocks % array of stocks (all data) num days % # of days on which to build the cov matrix factors rf trade cost end methods function obj = Simulator(stocks. trade cost) obj.stocks).:). factors. . %cycle through sim period while(curr ind < ed) %find last trading day of week ntd = next trade date(curr ind.num days:curr ind−1. opt ports = []. 15 . cash.rf(curr ind−obj.

curr port]. 'day').. period returns norm = .[trade ret. 'yyyymmdd'). return. cash. cash. %minus trading costs num trades = size(find(abs(curr port − past port)>0. simulate period(cov. tmmrw = addtodate(today.. args). past port. first week = 0.. args.num trades] = .. past port. cash.... trade cost. 1. period returns.. trade ret.trade cost.1). period returns+ones(size(period returns)). curr port. 1. simulate period(cov. end ntd = sd + i.1). i=i+1. results = [results. tmmrw = addtodate(today. 'day'). then prod period returns = ret(curr ind:ntd. trade ret. args) %find portfolio curr port = optimize(cov.. normalize by adding one to each . returns over %period. opt ports = [opt ports.('first week') = first week. %calculate returns for this period trade ret = (period returns)*curr port.... cash = trade ret*cash − trade cost*num trades.. prod(period returns norm. args). end 16 .. cash. curr ind = ntd + 1.cash.46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 %simulate period only cares about the total .:).01). timestamps) today = datenum(int2str(timestamps(sd)). .num trades]]. period returns norm = . end end end end function [curr port.. i = 0.num trades] = . obj. [curr port.. period returns norm. . while isbusday(tmmrw) today = tmmrw. end function ntd = next trade date(sd.

'file') = 3 error('please compile gurobi mex. generate gurobi qp markowitz(cov.c first. w target = x(1:size(x.b.output.objtype.1)/2).1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 function [ w ] = optimize(cov..OptimalityTol = 1e−8. end cov = cov(1:m. % 0 − primal. QP. % −1 − auto.Presolve = −1. clear opts opts.val. 2 − aggressive opts. qval ] = . opts. generate gurobi qp lambda(cov.ub. generate gurobi lp( w target. opts.'). opts. opts.. QP.lb. 0 − no.IntFeasTol = 1e−5.FeasibilityTol = 1e−8.exitflag. % assign QP constraints %%%% Solve markowitz [x. 17 .Display = 0. c... % no Gurobi Mex display opts.qcol = qcol. %%%%%% clear opts [ c objtype A b lb ub contypes vtypes ] = . args). past port. cov = cov/(sum(sum(cov))).IntFeasTol = 1e−5. opts.opts). if exist('gurobi mex'. past port.lambda] = gurobi mex(. args). opts. 1).. past port.('mode') == 2 [ c objtype A b lb ub contypes vtypes qrow qcol .OutputFlag = 0.('mode') == 1 [ c objtype A b lb ub contypes vtypes qrow qcol .FeasibilityTol = 1e−6. conserv..qval = qval. 1 − .. args) M = size(cov..vtypes. QP. 1 − dual opts.DisplayInterval = 0.IterationLimit = 2000000.. qval ] = .contypes.. if args.IterationLimit = 2000000. elseif args..QP = QP. args ). % no Gurobi display opts... opts.. opts.A.qrow = qrow.1:m).Method = 1.

1)/4 ].exitflag. conserv. 0 − no. if ¬args.001 error('Something Wrong!'). % no Gurobi display opts. c.:)==0) = .vtypes. % no Gurobi Mex display opts. opts. w(x(m+1:m*2.A.output.OutputFlag =0 .lb. end end end 18 . w(x(m+1:m*2.Method = 1.b.('first week') w =[ x(1:size(x. 1 − dual opts.opts). 2 − aggressive opts. past port(x(m*2+1:m*3. w(x(m*2+1:m*3. end if abs((sum(w)−1))> . else w =[ x(1:size(x... % −1 − auto..:)==0).:)==0) = 0.ub. [x.DisplayInterval = 0.50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 opts..1)/3) ].objtype.OptimalityTol = 1e−6..:)==0) = 0. 1 − .val.Presolve = −1.contypes.. % 0 − primal.Display = 0.lambda] = gurobi mex(.

Theta hat = 1/T*(U. K).i)−period Rf). return.REG C = cov(period returns).:) = transpose(u). C = B* C f *B' + C thresh.\n'). % # of factors p = n. if ¬C PD fprintf('C not positive definite. % # of stocks if cov type == Simulator.1*K*sqrt(log(p)/T). period factors.. end T = m. if (m = r | | m = l | | r =l) error('Period length mismatch. U = zeros(p. (2/T*(U*transpose(U))).* C u hat+C u hat. [r q] = size(period factors).. l = length(period Rf).. al. % # of times K = q. C PD = min( eig( C ) ) > 0.ˆ2)−.. % beta least squares soln u = y−period factors*beta.ˆ2*(transpose(U)).ˆ2. end end 19 . end % Covariance matrix estimation as described in Fan et . T). omega = .p). period returns.. U(i.').:) = transpose(beta). end % cov type is FAMA % Regress B = zeros(p. for i = 1:p y = 100*(period returns(:..1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 function C = calc cov(cov type. C u hat(C u hat ≥ omega*sqrt(Theta hat)). period Rf) [m n] = size(period returns). 2011 C u hat = cov(U').. into percentages beta = period factors\y.. C f = cov(period factors)... C thresh(C u hat ≥ omega*sqrt(Theta hat)) =. C thresh = zeros(p. .. % turn . B(i..

'C'*ones(1.m) zeros(1. −1. rest nonneg ub = [].... end A(4*m+1.. %applied uniformly to all constraints lb = [−inf*ones(1.m)]). args ) % Stage 2 Optimization % Corresponds to equation (2. A(4*i+3.m) 'B'*ones(1. = −1*M. = −1*M...m) zeros(1.. b(4*i+4) = −w target(i+1). ones(1.:) = [−1*ones(1.i+1) = A(4*i+1. i+1+2*m) = −1. %no upper bound for any variables vtypes = char(['C'*ones(1. i+1+2*m) = −1. 3*m). else 20 . i+1) = 1.m)].. lambda 1 = args.m)]. A(4*i+3. first week = args. .1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 function [ c objtype A b lb ub contypes vtypes ] = .m) zeros(1.m)].i+1+m) A(4*i+2. generate gurobi lp( w target. lambda 2 = args. % A = zeros(4*m+2. A(4*i+4. m) zeros(1. A(4*m+2.i+1+m) 1..('lambda 2').m) zeros(1. 1).('lambda 1'). %sum(w) ≤ 1 b(4*m+1) = 1..('lambda 1 first week'). %−sum(w) ≤ −1 b(4*m+2) = −1. %w i . have no lower bound. for i = 0:m−1 A(4*i+1.. contypes = '<'. w last.m)]. A = sparse(A).m) . A(4*i+4.:) = [ones(1.m) zeros(1. m = size(w target. lambda 1 first week = args.i+1) = A(4*i+2.('first week'). %objtype (minimization) objtype = 1. if first week == 1 c = [zeros(1. b(4*i+3) = w target(i+1).m) . i+1) = −1.1).8) M = 100.m) lambda 1 first week *ones(1.. %4m+2 constraints. 3m variables b = zeros(4*m+2. .

−1.m)]..i+1+m) A(6*i+2..i+1) = 1. A(6*i+5.. A = sparse(A). end end 21 . %−sum(w) ≤ −1 b(6*m+2) = −1.m)].m) 'C'*ones(1. A(6*i+6. zeros(1.i+1+m) 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 1. contypes = '<'..z . A(6*i+3..m) .m) . m) zeros(1.m) zeros(1.m) ones(1.m) .m) zeros(1.. %6m+2 constraints. A(6*i+5. i+1) = 1.. = −1*M.i+1) = −1. i+1) = −1.:) = [ones(1. %w cont. y.m)].:) = [−1*ones(1.m) lambda 1*ones(1. b(6*i+5) = w target(i+1). x i nonneg ub = [].i+1+2*m) = −1*M. i+1+3*m) = −1. %no upper bound for any variables vtypes = char(['C'*ones(1.m)]). i+1+3*m) = −1.48 49 50 51 52 53 c = [zeros(1. = −1*M.. 4m variables b = zeros(6*m+2..i+1) = A(6*i+1.m) zeros(1. x cont A = zeros(6*m+2.. %applied uniformly to all constraints lb = [−inf*ones(1. b(6*i+6) = −w target(i+1).m)]. %sum(w) ≤ 1 b(6*m+1) = 1. A(6*i+6. A(6*i+3. 'B'*ones(1.m) zeros(1. A(6*i+4.m) 'B'*ones(1.. A(6*m+2. 4*m). zeros(1.m) zeros(1. end A(6*m+1.i+1+2*m) = −1*M. %w i have no lower bound. A(6*i+4. binary.i+1) = A(6*i+2. b(6*i+4) = −w last(i+1). b(6*i+3) = w last(i+1).m) . for i = 0:m−1 A(6*i+1..m) . zeros(1. lambda 2*ones(1. 1).

and qval (w'Cw... qcol.1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 function [ c objtype A b lb ub contypes vtypes qrow qcol . sum(x) ≤ d. end %objtype (minimization) objtype = 1. mˆ2). %2m+3 constraints. vtypes = 'C'. %c (no linear terms in objective) c = 0. m). b.. bound. 1). 2*m). qcol = repmat(temp col.. 1.. m)... %2m+3 constraints. qrow = zeros(1. m). qval([m*i+1:m*(i+1)]) = C(i+1. x i nonneg ub = []. vtypes) %variables are (w 0. contypes. [m n] = size(C). args ) %Stage 1 Optimization %Corresponds to equation (2. 2*m). contypes = '<'.'). 2m variables b = zeros(2*m+3. w m−1. lb. sum(w) = 1 will be represented as % −x i ≤ w i ≤ x i. %qrow.. %i*ones(1. w are variables 0 thru m−1) temp col = [0:m−1].7) %QP Example: % if w is 3−dim: qrow = 0 0 0 1 1 1 2 2 2 % qcol = 0 1 2 0 1 2 0 1 2 d = args. 2m variables b = zeros(2*m+3. %no upper bound for any variables %constraint: L1(w) ≤ d.. for i = 0:m−1 temp row = repmat(i. 1.. %all variables continuous A = zeros(2*m+3. for i = 0:m−1 22 . x 0.('d'). if m = n error('C not a square matrix. m) zeros(1.. sum(w) = 1 % x i ≥ 0 M = 1.. 1).m)]. qval ] = generate gurobi qp markowitz( C. end %CONSTRAINTS (A.:). qrow([m*i+1:m*(i+1)]) = temp row. %applied uniformly to all constraints lb = [−inf*ones(1. x m−1) %so variables m thru 2m−1 represent x A = zeros(2*m+3. ub. %w i have no lower .

m) zeros(1.:) = [ones(1.i+1+m) 1.i+1+m) A(2*i+2. A(2*m+2. qcol = int32(qcol).:) = [zeros(1. %sum(w) b(2*m+1) = 1.m) zeros(1. end ≤ d 23 .51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 A(2*i+1. %w i − x i %−w i − x i ≤ 0 0 ≤ end A(2*m+1.m)]. qrow = int32(qrow). b(2*m+2) = −1.m)].:) = [−1*ones(1. ≤ 1 %−sum(w) ≤ −1 A(2*m+3. = −1. = −1.i+1) = A(2*i+2. %sum(x) b(2*m+3) = d. −1. A = sparse(A).m) ones(1.i+1) = A(2*i+1.m)].

InitialGuess = [1. %step 1 % indust returns must be 30xT. while numAccepted < p %loop until we have p values that are in the .1). sigma u = diag(sigma p) + s*s' − diag(s. sigma sigma = std(sigma). s = randn(p. 1).. done = 0. x = fsolve(F.setGlobalStream(s). %Px3 sigma B = cov(B). factors must be 3xT B = (100*returns')/factors'. %generate p volatility draws for our p assets %find alpha and beta %define in−line function to solve F = @(x) [x(1)*x(2)−mean sigma. beta. 24 . mean sigma = mean(sigma). RandStream. sim factors] = simulate stocks(.ˆ2). returns. p. factors. . end end mask = binornd(1. seed) %Set random seed s = RandStream('mt19937ar'. % x(1) = alpha. % find standard deviation along the .. 1). numAccepted = 0....seed). sqrt(x(1))*x(2)−sigma sigma]. sigma = std(U.0.. sigma p(numAccepted) = drawˆ2. s(mask == 0) = 0. columns large = max(sigma).'Seed'. % mean treating rows as samples %step 2 U = returns − factors*B'. T.. % covariance treating rows as samples mu B = mean(B). beta = x(2). if draw ≥ small && draw ≤ large numAccepted = numAccepted + 1.2/(sqrt(p)*log(p)).1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 function [sim stocks. x(2) = beta alpha = x(1).. p.1]. InitialGuess).p). accepted range draw = gamrnd(alpha. while ¬done % loop until simga u is PD sigma p = zeros(1.. small = min(sigma).1).

% rows are draws. 1. 1]). end end Operations Research and Financial Engineering. %calculate the stocks returns sim stocks = (sim factors*B' + U)/100. Phi. %generate T factors according to the fitted model sim factors = arsim(mu f. if min(eigs) > 0 is=1.edu Operations Research and Financial Engineering. sigma B. T). %step 4 %simulate the p assets for T time points %generate p factor loading draws B = mvnrnd(mu B.edu 25 . p rows %generate T noise terms U = mvnrnd(zeros(p. else is=0.50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 if isPD(sigma u) done = 1. sigma error] = arfit(factors.1). [T. Princeton University E-mail address: afurger@princeton. Phi. Princeton University E-mail address: drjiang@princeton. end end %step 3 % fit a VAR(1) model to the 3x1 vectors of factors [mu f. end function is = isPD(A) eigs = eig(A). 1). sigma u. sigma error. p).

Sign up to vote on this title

UsefulNot usefulGiven a set of assets, Markowitz Portfolio Theory [5] devel- ops the idea of a minimum variance portfolio, also called the “Markowitz” portolio. We consider the point of view of a retail, individua...

Given a set of assets, Markowitz Portfolio Theory [5] devel- ops the idea of a minimum variance portfolio, also called the “Markowitz” portolio. We consider the point of view of a retail, individual investor who wishes to hold a low-risk portfolio, rebalanced weekly. Such an investor suffers from certain limitations that large companies (banks, hedge funds, etc.) do not have. These limitations include small initial capital and limited computing resources. Consequently, sparsity of the portfolio and limited trading during each rebalance become attractive features. We formulate an optimization model for this problem using quadratic and mixed-integer programming, We then demonstrate, us- ing a simulation, that trading strategies, realizable under our investor’s limitations attain near minimal risk.

- Investment Analysis and Portfolio Management
- Investments and Portfolio Management
- jesr.horasanli
- Tema6_2p.pdf
- Chapter 7
- Lecture 5
- Optimal Risky Portfolio (Bodie).pdf
- Single Index Slides
- Efficient Frontier Curve
- Chap 11(pt 1)BB(1).pptx
- Market Risk VaR
- FINC415_Notes2
- SSRN-id1023791
- Optimal Risky Portfolios
- CTF Chapter 2
- Boc Theory
- portfolio evaluation
- Online Quiz 5 Optimal Portfolio Q&A
- Synopsis
- Case Analysis_Beta Management
- SSRN-id1117574
- porfilio allocation aug25,2015.pdf
- Erc Slides
- 7_3-Measurement%20of%20Market%20Risk.pdf
- An Institutional Theory of Momentum and Revealsal Rev. Financ. Stud.-2013-Vayanos-1087-145
- EC3333 Midterm Fall 2014.Questions
- capm_2up
- Defining the Diversification Benefit GMc 003
- capm ppt
- Chapter 3 Economic and Econometric Models
- SPARSE, MINIMAL VARIANCE PORTFOLIO REBALANCED WITH AN L0-TRADING CONSTRAINT