Reference no: EM132833986
Problem 1: Practice with CVX
(a) Suppose we have the following optimization problem:
maximize Σmi=1 -wilog wi
subject to w ≥ 0, Σmi=1 wi = 1, XTw = b
where w ∈ Rm, X ∈ Rmxn and b ∈ Rn. Given that m = 20 and n = 10, we can generate the data for X and b as follows:
m <-20
n <- 10
set . seed (22)
X matrix (rnorm(m*n) ,m, n)
b <- t (X) %*% as. vector ( rep (1 /m, m)) + rnorm(n, 0, 0.005)
Solve this problem, show the code and optimal value of w*.
(b) Solve the following optimization problem
minimizex∈Rm,y∈Rm Σmi=1 yi
subject to x1 = 0, xm, = 1, y1 = 1, ym = 1,
(xi+i - xi)2 + 2(yi+1 - yi)2 ≤ 0.022, i = 1,.....,m - 1
Set m = 101, plot the curve of (x, y), which consists of a series of points (x1, y1), ,(x101, y101).
Problem 2: Portfolio optimization
In this problem, we aim at designing portfolios among following assets:
StocksArray = c('MSFT',' AAPL',' AMZN',' GOOGL',' JNJ',' JPM', 'UNH',' MA',' HD',' INTC','VZ',' K0',' BAC',' X0M',' MRK',' DIS', 'PEP',' CMCSA',' CV X',' ADBE',' CSCO',' NVDA','WMT',' NFLX', 'WFC',' MCD',' ABT',' BMY',' COST' BA',' C',' PM',' NEE',' MDT', 'AMGN','TM0',' LLY',' HON',' ACN',' IBM')
The period we consider is from 01-01-2010 to 31-12-2020. We will use the R package 'portfolioBacktest'. Please check the vignette before answering the questions.
(a) Prepare your data set for backtest. In R, you should create a specified list, resample it into 50 different sub-lists, each of which contains 20 stocks and 252 x 2 days' prices. Hint: use the function 'stockDataDownload' to get the data, then use 'financialDataResample' to resample the data set. (N_sample = 20,T-sample = 252 . 2, num_datasets = 25.)
data <- stockDataDownload ( stock _symbols = StocksArray )
(b) Implement Markowitz portfolio with max position constraint:
minimizew -wTμ + λwTΣw
subject to ||w||∞ ≤ μ, 1Tw = 1, w ≥ 0,
where μ and Σ can be estimated by sample mean and sample covariance matrix. Set λ = 2 and u = 0.04. Do the backtest, show the performance table and compare it with standard Markowitz portfolio (without max position constraint).
(c) Consider a portfolio formualted as
minimizew -μTw - ∈||W||∞
subject to w ≥ 0, 1Tw = 1,
where μ can be estimated by sample means. Try to determine the value of ∈, do the backtest, then show the performance table.
(d) Instead of using sample meanµ and sample covariance matrix Σ to construct the portfolio, here we would use
Σ = ρ1Σ + (1 - ρ1) trace(Σ)IN/N
μ = ρ2μ + (1 - ρ2)1.TNμ/N.1N
where N is the number of asset and IN is the identity matrix of order N. Use all possible pairs for ρ1 and ρ2 in {0, 0.25, 0.5, 0.75, 1), do the backtest for the mean-variance portfolio
minimize -wTμ, + λwTΣw
subject to w ≥ 0, 1Tw = 1,
under all possible combination of ρ1 and ρ2, ( λ= 0.01), show the performance table and tell which pair of (ρ1, ρ2) gives the best Sharpe Ratio performance.
(e) Implement the index tracking portfolio by simply regressing the dense index
minimize 1/T||rb - Xb||22
subject to 1Tb = 1, b ≥ 0.
Do the backtest and show the performance table. (Check the slide for the notations in this sub-problem.)
Problem 3: Gradient descent
Consider an unconstrained optimization problem:
minimize f(x) = ex1+3x2-0.1 + ex1 -3x2 -0.1 + e-x1 -0.1
Design a gradient descent method for solving it. You should clearly define the starting point, step size, and stopping criteria. Check whether your results converge to the optimal using CVX.