TomSym Mean Variance Portfolio Selection: Difference between revisions

From TomWiki
Jump to navigationJump to search
(Created page with "{{Part Of Manual|title=the TomSym Manual|link=TomSym Manual}} ==Problem description== An investor wishes to invest a certain amount of money. He is evaluating four d...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 7: Line 7:
Estimated returns and variance/covariance matrix
Estimated returns and variance/covariance matrix


<pre>
+----------------+--------+--------+--------+-------+
+----------------+--------+--------+--------+-------+
|                |Hardware|Software|Show-biz|T-bills|
|                |Hardware|Software|Show-biz|T-bills|
Line 17: Line 18:
|T-bills        |  0    |  0    |    0  |  0  |
|T-bills        |  0    |  0    |    0  |  0  |
+----------------+--------+--------+--------+-------+
+----------------+--------+--------+--------+-------+
</pre>


Question 1: Which investment strategy should the investor adopt to minimize the variance subject to getting some specified minimum target yield?
Question 1: Which investment strategy should the investor adopt to minimize the variance subject to getting some specified minimum target yield?
Line 24: Line 26:
==Variables==
==Variables==


<pre>
estreturn                  Estimated return of securities
estreturn                  Estimated return of securities
covmat                    The variance/covariance matrix
covmat                    The variance/covariance matrix
target                    Minimum target yield
target                    Minimum target yield
maxassets                  Number of securities
maxassets                  Number of securities
</pre>


==Reference==
==Reference==
Line 110: Line 114:
<pre>
<pre>
Problem type appears to be: qp
Problem type appears to be: qp
Time for symbolic processing: 0.023581 seconds
Time for symbolic processing: 0.019133 seconds
Starting numeric solver
Starting numeric solver
===== * * * =================================================================== * * *
===== * * * =================================================================== * * *
Line 125: Line 129:
Elapsed time: 0.002000 sec.  
Elapsed time: 0.002000 sec.  
Problem type appears to be: miqp
Problem type appears to be: miqp
Time for symbolic processing: 0.038629 seconds
Time for symbolic processing: 0.03553 seconds
Starting numeric solver
Starting numeric solver
===== * * * =================================================================== * * *
===== * * * =================================================================== * * *
Line 138: Line 142:


FuncEv  21 GradEv  21  
FuncEv  21 GradEv  21  
Elapsed time: 0.006000 sec.  
CPU time: 0.015600 sec. Elapsed time: 0.004000 sec.  
Answer to Question 1:
Answer to Question 1:
   invest 15.1442% of the capital in Hardware
   invest 15.1442% of the capital in Hardware

Latest revision as of 09:33, 8 November 2011

Notice.png

This page is part of the TomSym Manual. See TomSym Manual.

Problem description

An investor wishes to invest a certain amount of money. He is evaluating four different securities (assets) for his investment. The securities are US Treasury Bills (‘T-bills’), a computer hardware company, a computer software company, and a high-risk investment in a theater production. He estimates the mean yield on each dollar he invests in each of the securities, and also adopts the Markowitz idea of getting estimates of the variance/covariance matrix of estimated returns on the securities. (For example, hardware and software company worths tend to move together, but are oppositely correlated with the success of theatrical production, as people go to the theater more when they have become bored with playing with their new computers and computer games.) The return on theatrical productions are highly variable, whereas the T-bill yield is certain. The estimated returns and the variance/covariance matrix are given in the table below.

Estimated returns and variance/covariance matrix

+----------------+--------+--------+--------+-------+
|                |Hardware|Software|Show-biz|T-bills|
+----------------+--------+--------+--------+-------+
|Estimated return|   8    |   9    |    12  |   7   |
+----------------+--------+--------+--------+-------+
|Hardware        |   4    |   3    |    -1  |   0   |
|Software        |   3    |   6    |     1  |   0   |
|Show-biz        |  -1    |   1    |    10  |   0   |
|T-bills         |   0    |   0    |     0  |   0   |
+----------------+--------+--------+--------+-------+

Question 1: Which investment strategy should the investor adopt to minimize the variance subject to getting some specified minimum target yield?

Question 2: Which is the least variance investment strategy if the investor wants to choose at most two different securities (again subject to getting some specified minimum target yield)?

Variables

estreturn                  Estimated return of securities
covmat                     The variance/covariance matrix
target                     Minimum target yield
maxassets                  Number of securities

Reference

Applications of optimization... Gueret, Prins, Seveaux

% Marcus Edvall, Tomlab Optimization Inc, E-mail: tomlab@tomopt.com
% Copyright (c) 2005-2009 by Tomlab Optimization Inc., $Release: 7.2.0$
% Written Oct 7, 2005.   Last modified Apr 8, 2009.

Problem setup

estreturn = [8 9 12 7]';
covmat    = [ 4  3 -1  0;...
    3  6  1  0;...
    -1  1 10  0;...
    0  0  0  0];
target    = 8.5;

n = length(estreturn);
buy = tom('buy',n,1);

% Bounds
bnds = {0 <= buy <= 1};

% Cost constraints
con1 = {estreturn'*buy >= target};
con2 = {sum(buy) == 1};

% Objective
objective = 0.5*buy'*covmat*buy;

constraints = {bnds, con1, con2};
options = struct;
options.solver = 'cplex';
options.name   = 'Mean Variance Portfolio Selection';
sol1 = ezsolve(objective,constraints,[],options);

buybin = tom('buybin',n,1,'int');
bnds2 = {0 <= buybin <= 1};

maxassets = 2;
con3 = {sum(buybin) <= maxassets};
con4 = {buy - buybin <= 0};

constraints = {bnds, con1, con2, con3, con4};
sol2 = ezsolve(objective,constraints,[],options);

PriLev = 1;
if PriLev > 0
    names  = ['Hardware';
        'Software';
        'Show-biz';
        'T-bills '];
    disp('Answer to Question 1:')
    for i = 1:length(sol1.buy),
        disp(['   invest ' num2str(sol1.buy(i)*100) ...
            '% of the capital in ' names(i,:) ])
    end
    disp('Answer to Question 2 (limited number of securities):')
    x = sol2.buy;
    x(find(x < 1e-6)) = 0;
    for i = 1:length(x),
        if x(i) ~= 0,
            disp(['   invest ' num2str(x(i)*100) ...
                '% of the capital in ' names(i,:)  ])
        end
    end
end

% MODIFICATION LOG
%
% 051202 med   Created.
% 060117 per   Added documentation.
% 060125 per   Moved disp to end
% 090308 med   Converted to tomSym
Problem type appears to be: qp
Time for symbolic processing: 0.019133 seconds
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB - TOMLAB Development license  999007. Valid to 2011-12-31
=====================================================================================
Problem:  1: Mean Variance Portfolio Selection  f_k       0.362379808516660680
                                              f(x_0)      0.000000000000000000

Solver: CPLEX.  EXIT=0.  INFORM=1.
CPLEX Barrier QP solver
Optimal solution found

FuncEv   12 GradEv   12 ConstrEv   12 Iter   12 
Elapsed time: 0.002000 sec. 
Problem type appears to be: miqp
Time for symbolic processing: 0.03553 seconds
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB - TOMLAB Development license  999007. Valid to 2011-12-31
=====================================================================================
Problem: ---  1: Mean Variance Portfolio Selection  f_k       0.450000000000000070
                                                  f(x_0)      0.000000000000000000

Solver: CPLEX.  EXIT=0.  INFORM=101.
CPLEX Branch-and-Cut MIQP solver
Optimal integer solution found

FuncEv   21 GradEv   21 
CPU time: 0.015600 sec. Elapsed time: 0.004000 sec. 
Answer to Question 1:
   invest 15.1442% of the capital in Hardware
   invest 4.3269% of the capital in Software
   invest 25.2404% of the capital in Show-biz
   invest 55.2885% of the capital in T-bills 
Answer to Question 2 (limited number of securities):
   invest 30% of the capital in Show-biz
   invest 70% of the capital in T-bills