Chapter 5 Portfolio - Amazon Web...
Transcript of Chapter 5 Portfolio - Amazon Web...
Chapter 5Portfolio
O. Afonso, P. B. Vasconcelos
Computational Economics: a concise introduction
O. Afonso, P. B. Vasconcelos Computational Economics 1 / 22
Overview
1 Introduction
2 Economic model
3 Numerical solution
4 Computational implementation
5 Numerical results and simulation
6 Highlights
7 Main references
O. Afonso, P. B. Vasconcelos Computational Economics 2 / 22
Introduction
The portfolio optimisation model, originally proposed by Markowitz (1952),selects proportions of assets to be included in a portfolio.
To have an efficient portfolio:the expected return should be maximised contingent on any given number ofrisks; orthe risk should be minimised for a given expected return.
Thus, investors are confronted with a trade-off between expected returnand risk.The expected return-risk relationship of efficient portfolios is representedby an efficient frontier curve.
Optimisation knowledge is required to solve this problem. Focus is on a MonteCarlo optimisation and on advanced numerical solutions provided byMATLAB/Octave.
O. Afonso, P. B. Vasconcelos Computational Economics 3 / 22
Economic model
The aim is to maximise the expected return constrained to a given risk
maxx
cT x , s.t. xT Hx = σ2,
n∑i=1
xi = 1 and xi ≥ 0 , (1)
wheren is the number of assets,x , n × 1, is the vector of the shares invested in each asset i ,c, n × 1, is the vector of the average benefit per asset,H, n × n, is the covariance matrix, andσ2 is the expected risk goal.
Problem (1) is know as a quadratic programming problem.Alternatively, minimise the risk subject to an expected return, c,
minx
xT Hx , s.t. cT x = c,n∑
i=1
xi = 1 and xi ≥ 0. (2)
O. Afonso, P. B. Vasconcelos Computational Economics 4 / 22
Economic model
The global minimum variance portfolio is the one satisfying
minx
xT Hx , s.t.n∑
i=1
xi = 1 and xi ≥ 0. (3)
The efficient frontier is the set of pairs (risk, return) for which the returnsare greater than the return provided by the minimum variance portfolio.
The aim is to find the values of variables that optimise an objective,conditional or not to constraints.Numerical methods overcome limitations of size, but there is no universalalgorithm to solve optimisation problems.The topic is addressed only in a cursory manner exploiting theMATLAB/Octave optimisation potentialities.
O. Afonso, P. B. Vasconcelos Computational Economics 5 / 22
Numerical solution
Consider the minimisation problem
minx∈Rn
f (x) (4)
s.t. ci(x) = 0, i ∈ Eci(x) ≥ 0, i ∈ I
where f : Rn → R, cE : Rn → RnE and cI : Rn → RnI , respectively, the equalityand inequality constraints.
A feasible region is the set points satisfying the constraintsS = {x : ci(x) = 0, i ∈ I and ci(x) ≥ 0, i ∈ D}.Problems without restrictions I = D = ∅ emerge in many applications andas a recast of constraint problems where restrictions are replaced bypenality terms added to the objective function.
O. Afonso, P. B. Vasconcelos Computational Economics 6 / 22
Numerical solution
Optimisation problems can be classified in various ways, according to, forexample: (i) functions involved; (ii) type of variables used; (iii) type ofrestrictions considered; (iv) type of solution to be obtained; and (v)differentiability of the functions involved.Among the countless optimisation problems, linear, quadratic andnonlinear programming are the most usual.Many algorithms for nonlinear programming problems only seek localsolutions; in particular, for convex linear programming, local solutions areglobal.
O. Afonso, P. B. Vasconcelos Computational Economics 7 / 22
Numerical solution
Unconstrained optimisation in practice
Unconstrained optimisation problemsMethods such as steepest descent, Newton and quasi-Newton are the mostused.MATLAB/Octave:
fminunc(f,x0) attempts to find a local minimum of function f, starting at pointx0;similarly with fminsearch(f,x0) but using a derivative-free method;x0 can be a scalar, vector, or matrix.
O. Afonso, P. B. Vasconcelos Computational Economics 8 / 22
Numerical solution
Constrained optimisation in practice: linearprogramming
Linear programming problem: both the objective and constraints arelinear
minx
cT x
s.t. Ax ≤ b, Aeqx = beq , lb ≤ x ≤ ub
where c and x are vectors.MATLAB/Octave: linprog(c,A,b,Aeq,beq,lb,ub).
O. Afonso, P. B. Vasconcelos Computational Economics 9 / 22
Numerical solution
Constrained optimisation in practice: quadraticprogramming
Quadratic programming problem (portfolio problem): this involves aquadratic objective function and linear constraints
minx
12
xT Hx + xT c
s.t. Ax ≤ b, Aeqx = beq , lb ≤ x ≤ ub
where c, x and ai are vetors, and H is a symmetric (Hessian) matrix.MATLAB: quadprog(H,c,A,b,Aeq,beq,lb,ub)Octave: qp([],H,c,Aeq,beq,lb,ub)
O. Afonso, P. B. Vasconcelos Computational Economics 10 / 22
Numerical solution
Constrained optimisation in practice: nonlinearprogramming
Nonlinear programming: f and/or constraints are nonlinear
minx
f (x)
s.t. c(x) ≤ 0, ceq(x) = 0,Ax ≤ b, Aeqx = beq , lb ≤ x ≤ ub .
MATLAB: fmincon(f,x0,A,b,Aeq,beq,lb,ub,nonlcon)Octave: minimize(f,args) (where args is a list or arguments to f)
O. Afonso, P. B. Vasconcelos Computational Economics 11 / 22
Numerical solution
Monte Carlo approach
Monte Carlo: experiments anchored on repeated random sampling toobtain numerical approximations of the solution.A Monte Carlo procedure can be schematised as follows.
1 Set a possible solution, and consider it to be the best for the moment2 For a certain number of times, do:
1 generate (randomly) a set of feasable solutions from the best one available;2 select (possibilly) a better one;3 repeat the process.
O. Afonso, P. B. Vasconcelos Computational Economics 12 / 22
Computational implementation
Consider the following data, respectively, for the returns vector andcovariance matrix
c =
0.1000.2000.150
and H =
0.005 −0.010 0.004−0.010 0.040 −0.002
0.004 −0.002 0.023
.
O. Afonso, P. B. Vasconcelos Computational Economics 13 / 22
Computational implementation
Monte Carlo approach: portfolio with minimumvariance
function [ x , x _ h i s t ] = p o r t f o l i o _ m c a r l o _ f u n (H, nruns , const )% Monte Carlo s o l u t i o n approach% Implemented by : P .B . Vasconcelos and O. Afonso% based on : Computat ional Economics ,% D. A . Kendrick , P . R. Mercado and H. M. Amman% Pr inceton U n i v e r s i t y Press , 2006% inpu t :% H, covar iance mat r i x% nruns , number o f Monte Car lo runs% const , constant to increase / reduce the magnitude of the random% numbers generated% output :% x , best found p o r t f o l i o% x_h is t , search h i s t o r y f o r best p o r t f o l i o
O. Afonso, P. B. Vasconcelos Computational Economics 14 / 22
Computational implementation
% i n i t i a l i z a t i o n parameters and weights ;popsize = 10;n = size (H, 1 ) ;pwm = ( 1 / n ) ∗ones ( n , popsize ) ;c r i t = zeros (1 , popsize ) ;x _ h i s t = zeros ( n , 1 ) ;
% compute nruns x popsize p o r t f o l i o sfor k = 1: nruns
for j = 1 : popsize ;c r i t ( j ) = pwm( : , j ) ’∗H∗pwm( : , j ) ;
end
% s e l e c t i o n o f the best p o r t f o l i o[ ~ , top_index ] = min ( c r i t ) ;x = pwm( : , top_index ) ;
% sto re the best p o r t f o l i ox _ h i s t ( : , k ) = x ;
O. Afonso, P. B. Vasconcelos Computational Economics 15 / 22
Computational implementation
i f k == nruns , break , endpwm( : , 1 ) = x ;for i = 2 : popsize ;
x = x+randn ( n , 1 ) ∗const ;pwm( : , i ) = abs ( x /sum( abs ( x ) ) ) ;
endend
To solve the problem just do:nruns = 40;const = 0.1;[x,x_hist] = portfolio_mcarlo_fun(H,nruns,const);disp(’best portfolio:’);for i=1:length(x)
fprintf(’Asset %d \t %5.4f \n’,i,x(i));endfprintf(’expected return: %g \n’,c’*x);fprintf(’risk : %g \n’,sqrt(x’*H*x));
O. Afonso, P. B. Vasconcelos Computational Economics 16 / 22
Numerical results and simulation
---------------------------------------------------------Portfolio optimization: global minimum variance
Monte Carlo solution approach---------------------------------------------------------best portfolio:Asset 1 0.7649Asset 2 0.2355Asset 3 0.0004expected return: 0.123644risk : 0.0392812
O. Afonso, P. B. Vasconcelos Computational Economics 17 / 22
Numerical results and simulation
0 5 10 15 20 25 30 35 400
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
share
of each a
sset
number of Monte Carlo runs
Asset 1
Asset 2
Asset 3
Monte Carlo convergence path for the portfolio with minimum variance
O. Afonso, P. B. Vasconcelos Computational Economics 18 / 22
Numerical results and simulation
Quadratic programming approach: portfolio withminimum variance
Aeq = ones(1,length(c)); beq = 1; lb = zeros(1,length(c));x = quadprog(2*H,[],[],[],Aeq,beq,lb);disp(’best portfolio:’);for i=1:length(x)fprintf(’Asset %d \t %5.4f \n’,i,x(i));
endfprintf(’expected return: %g \n’,c’*x);fprintf(’risk : %g \n’,sqrt(x’*H*x));
O. Afonso, P. B. Vasconcelos Computational Economics 19 / 22
Numerical results and simulation
---------------------------------------------------------Portfolio optimization: global minimum variance
quadratic programming approach---------------------------------------------------------best portfolio:Asset 1 0.7692Asset 2 0.2308Asset 3 0.0000expected return: 0.123077risk : 0.0392232
O. Afonso, P. B. Vasconcelos Computational Economics 20 / 22
Highlights
The portfolio optimisation model selects the optimal proportions ofvarious assets to be included in a portfolio, according to certain criteria.A rational investor aims at choosing a set of assets (diversification)delivering collectively the lowest risk for a target expected return.A portfolio is considered efficient if it is not possible to obtain a higherreturn without increasing the risk.The expected return-risk relationship of efficient portfolios is representedby an efficient frontier curve.The model is a quadratic programming problem. It is solved by using asimple Monte Carlo approach that only requires the notion of a minimumconditioned to a set of restrictions, and by a more sophisticated methoddeployed by MATLAB/Octave.
O. Afonso, P. B. Vasconcelos Computational Economics 21 / 22
Main references
References
R. A. Haugen and N. L. BakerThe efficient market inefficiency of capitalization-weighted stock portfoliosThe Journal of Portfolio Management, 17(3): 35–40, 1991
H. MarkowitzPortfolio selectionThe Journal of Finance, 7(1): 77–91, 1952
R. C. MertonAn analytic derivation of the efficient portfolio frontierThe Journal of Financial and Quantitative Analysis, 7(4): 1851–1872, 1972
J. Nocedal and S. J. WrightNumerical OptimizationSpringer (2006)
D. Pachamanova and F. J. FabozziSimulation and optimization in finance: modeling with MATLAB, @RISK, or VBAvol. 173, John Wiley & Sons (2010)
O. Afonso, P. B. Vasconcelos Computational Economics 22 / 22