Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

PortfolioMAD

Create PortfolioMAD object for mean-absolute deviation portfolio optimization

Use the PortfolioMAD function to create a PortfolioMAD object for mean-absolute deviation portfolio optimization. For more information, see PortfolioMAD.

You can use the PortfolioMAD function in several ways. To set up a portfolio optimization problem in a PortfolioMAD object, the simplest syntax is:

p = PortfolioMAD;
This syntax creates a PortfolioMAD object, p, such that all object properties are empty.

The PortfolioMAD function also accepts collections of argument name-value pair arguments for properties and their values. The PortfolioMAD function accepts inputs for properties with the general syntax:

	p = PortfolioMAD('property1', value1, 'property2', value2, ... );

If a PortfolioMAD object exists, the syntax permits the first (and only the first argument) of the PortfolioMAD function to be an existing object with subsequent argument name-value pair arguments for properties to be added or modified. For example, given an existing PortfolioMAD object in p, the general syntax is:

p = PortfolioMAD(p, 'property1', value1, 'property2', value2, ... );

Input argument names are not case-sensitive, but must be completely specified. In addition, several properties can be specified with alternative argument names (see Shortcuts for Property Names). The PortfolioMAD function tries to detect problem dimensions from the inputs and, once set, subsequent inputs can undergo various scalar or matrix expansion operations that simplify the overall process to formulate a problem. In addition, a PortfolioMAD object is a value object so that, given portfolio p, the following code creates two objects, p and q, that are distinct:

q = PortfolioMAD(p, ...)

After creating a PortfolioMAD object, you can use the associated object functions to set portfolio constraints, analyze the efficient frontier, and validate the portfolio model.

For details on this workflow, seePortfolioMAD Object Workflow and for more detailed information on the theoretical basis for conditional value-at-risk portfolio optimization, see Portfolio Optimization Theory.

Syntax

p = PortfolioMAD
p = PortfolioMAD(Name,Value)
p = PortfolioMAD(p,Name,Value)

Description

example

p = PortfolioMAD constructs an empty PortfolioMAD object for mean-absolute deviation portfolio optimization and analysis. You can then add elements to the PortfolioMAD object using the supported add and set functions. For more information, see Creating the PortfolioMAD Object.

example

p = PortfolioMAD(Name,Value) constructs a PortfolioMAD object for mean-absolute deviation portfolio optimization and analysis with additional options specified by one or more Name,Value arguments.

example

p = PortfolioMAD(p,Name,Value) constructs a PortfolioMAD object for mean-absolute deviation portfolio optimization and analysis using a previously constructed PortfolioMAD object p with additional options specified by one or more Name,Value arguments.

Examples

collapse all

You can create a PortfolioMAD object, p, with no input arguments and display it using disp.

p = PortfolioMAD;
disp(p);
  PortfolioMAD with properties:

         BuyCost: []
        SellCost: []
    RiskFreeRate: []
        Turnover: []
     BuyTurnover: []
    SellTurnover: []
    NumScenarios: []
            Name: []
       NumAssets: []
       AssetList: []
        InitPort: []
     AInequality: []
     bInequality: []
       AEquality: []
       bEquality: []
      LowerBound: []
      UpperBound: []
     LowerBudget: []
     UpperBudget: []
     GroupMatrix: []
      LowerGroup: []
      UpperGroup: []
          GroupA: []
          GroupB: []
      LowerRatio: []
      UpperRatio: []

This approach provides a way to set up a portfolio optimization problem with the PortfolioMAD function. You can then use the associated set functions to set and modify collections of properties in the PortfolioMAD object.

You can use the PortfolioMAD function directly set up a “standard” portfolio optimization problem. Given scenarios of asset returns in the variable AssetScenarios, this problem is completely specified as follows:

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0; 
    0.00408 0.0289 0.0204 0.0119;
    0.00192 0.0204 0.0576 0.0336;
    0 0.0119 0.0336 0.1225 ];
m = m/12;
C = C/12;

AssetScenarios = mvnrnd(m, C, 20000);

p = PortfolioMAD('Scenarios', AssetScenarios, ...
'LowerBound', 0, 'LowerBudget', 1, 'UpperBudget', 1)
p = 
  PortfolioMAD with properties:

         BuyCost: []
        SellCost: []
    RiskFreeRate: []
        Turnover: []
     BuyTurnover: []
    SellTurnover: []
    NumScenarios: 20000
            Name: []
       NumAssets: 4
       AssetList: []
        InitPort: []
     AInequality: []
     bInequality: []
       AEquality: []
       bEquality: []
      LowerBound: [4x1 double]
      UpperBound: []
     LowerBudget: 1
     UpperBudget: 1
     GroupMatrix: []
      LowerGroup: []
      UpperGroup: []
          GroupA: []
          GroupB: []
      LowerRatio: []
      UpperRatio: []

Note that the LowerBound property value undergoes scalar expansion since AssetScenarios provides the dimensions of the problem.

Using a sequence of steps is an alternative way to accomplish the same task of setting up a “standard” MAD portfolio optimization problem, given AssetScenarios variable is:

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0;
0.00408 0.0289 0.0204 0.0119;
0.00192 0.0204 0.0576 0.0336;
0 0.0119 0.0336 0.1225 ];

m = m/12;
C = C/12;

AssetScenarios = mvnrnd(m, C, 20000);

p = PortfolioMAD;
p = setScenarios(p, AssetScenarios);
p = PortfolioMAD(p, 'LowerBound', 0);
p = PortfolioMAD(p, 'LowerBudget', 1, 'UpperBudget', 1);

plotFrontier(p);

This way works because the calls to the PortfolioMAD function are in this particular order. In this case, the call to initialize AssetScenarios provides the dimensions for the problem. If you were to do this step last, you would have to explicitly dimension the LowerBound property as follows:

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0;
0.00408 0.0289 0.0204 0.0119;
0.00192 0.0204 0.0576 0.0336;
0 0.0119 0.0336 0.1225 ];

m = m/12;
C = C/12;

AssetScenarios = mvnrnd(m, C, 20000);

p = PortfolioMAD;
p = PortfolioMAD(p, 'LowerBound', zeros(size(m)));
p = PortfolioMAD(p, 'LowerBudget', 1, 'UpperBudget', 1);
p = setScenarios(p, AssetScenarios);

plotFrontier(p);

If you did not specify the size of LowerBound but, instead, input a scalar argument, the PortfolioMAD function assumes that you are defining a single-asset problem and produces an error at the call to set asset scenarios with four assets.

You can create a PortfolioMAD object, p with the PortfolioMAD function using shortcuts for property names.

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0;
0.00408 0.0289 0.0204 0.0119;
0.00192 0.0204 0.0576 0.0336;
0 0.0119 0.0336 0.1225 ];

m = m/12;
C = C/12;

AssetScenarios = mvnrnd(m, C, 20000);

p = PortfolioMAD('scenario', AssetScenarios, 'lb', 0, 'budget', 1)
p = 
  PortfolioMAD with properties:

         BuyCost: []
        SellCost: []
    RiskFreeRate: []
        Turnover: []
     BuyTurnover: []
    SellTurnover: []
    NumScenarios: 20000
            Name: []
       NumAssets: 4
       AssetList: []
        InitPort: []
     AInequality: []
     bInequality: []
       AEquality: []
       bEquality: []
      LowerBound: [4x1 double]
      UpperBound: []
     LowerBudget: 1
     UpperBudget: 1
     GroupMatrix: []
      LowerGroup: []
      UpperGroup: []
          GroupA: []
          GroupB: []
      LowerRatio: []
      UpperRatio: []

Although not recommended, you can set properties directly, however no error-checking is done on your inputs.

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0; 
    0.00408 0.0289 0.0204 0.0119;
    0.00192 0.0204 0.0576 0.0336;
    0 0.0119 0.0336 0.1225 ];
m = m/12;
C = C/12;

AssetScenarios = mvnrnd(m, C, 20000);

p = PortfolioMAD;

p = setScenarios(p, AssetScenarios);

p.LowerBudget = 1;
p.UpperBudget = 1;
p.LowerBound = zeros(size(m));
disp(p);
  PortfolioMAD with properties:

         BuyCost: []
        SellCost: []
    RiskFreeRate: []
        Turnover: []
     BuyTurnover: []
    SellTurnover: []
    NumScenarios: 20000
            Name: []
       NumAssets: 4
       AssetList: []
        InitPort: []
     AInequality: []
     bInequality: []
       AEquality: []
       bEquality: []
      LowerBound: [4x1 double]
      UpperBound: []
     LowerBudget: 1
     UpperBudget: 1
     GroupMatrix: []
      LowerGroup: []
      UpperGroup: []
          GroupA: []
          GroupB: []
      LowerRatio: []
      UpperRatio: []

Scenarios cannot be assigned directly to a PortfolioMAD object. Scenarios must always be set through either the PortfolioMAD function, the setScenarios function, or any of the scenario simulation functions.

Create efficient portfolios:

load CAPMuniverse

p = PortfolioMAD('AssetList',Assets(1:12));
p = simulateNormalScenariosByData(p, Data(:,1:12), 20000 ,'missingdata',true);
p = setDefaultConstraints(p);

plotFrontier(p);

pwgt = estimateFrontier(p, 5);

pnames = cell(1,5);
for i = 1:5
	pnames{i} = sprintf('Port%d',i);
end

Blotter = dataset([{pwgt},pnames],'obsnames',p.AssetList);

disp(Blotter);
            Port1         Port2         Port3         Port4          Port5     
    AAPL      0.030236      0.075387       0.11278        0.13456    1.5092e-14
    AMZN    1.6541e-21    1.8269e-22    1.1341e-22     1.1658e-33    2.8997e-14
    CSCO    1.5007e-22    3.6088e-23    5.7857e-24    -5.0613e-34    4.1869e-14
    DELL     0.0089659             0             0     3.6065e-18    3.9048e-14
    EBAY    2.0446e-22     3.838e-23    2.5657e-24     6.3019e-17    1.3394e-15
    GOOG       0.16117       0.35201       0.54486        0.74888             1
    HPQ       0.056551      0.024037    4.3354e-24     2.4041e-33    3.8894e-14
    IBM        0.45905       0.37891       0.29383        0.11656    3.7902e-14
    INTC             0    1.0096e-21             0     1.9259e-34    3.8264e-14
    MSFT       0.28403       0.16966      0.048527              0    4.0873e-14
    ORCL    5.3466e-21    9.3937e-23    3.3353e-22    -1.3404e-34    3.7811e-14
    YHOO             0    2.8818e-23    2.8929e-24     1.7548e-34     3.535e-14

Input Arguments

collapse all

Previously constructed PortfolioMAD object, specified using the PortfolioMAD function

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: p = PortfolioMAD('AssetList',Assets(1:12));

collapse all

Linear equality constraint matrix, specified as a matrix.

Data Types: double

Linear inequality constraint matrix, specified as a matrix.

Data Types: double

Names or symbols of assets in the universe, specified as a cell array of character vectors.

Data Types: cell

Linear equality constraint vector, specified as a vector.

Data Types: double

Linear inequality constraint vector, specified as a vector.

Data Types: double

Proportional purchase costs, specified as a vector.

Data Types: double

Turnover constraint on purchases, specified as a scalar.

Data Types: double

Group A weights to be bounded by weights in group B, specified as a matrix.

Data Types: double

Group B weights, specified as a matrix.

Data Types: double

Group membership matrix, specified as a matrix.

Data Types: double

Initial portfolio, specified as a vector.

Data Types: double

Lower-bound constraint, specified as a vector.

Data Types: double

Lower-bound budget constraint, specified as a scalar.

Data Types: double

Lower-bound group constraint, specified as a vector.

Data Types: double

Minimum ratio of allocations between GroupA and GroupB, specified as a vector.

Data Types: double

Name for instance of the Portfolio object, specified as a character vector.

Data Types: char

Number of assets in the universe, specified as an integer scalar.

Data Types: double

Number of scenarios, specified as an integer scalar.

Data Types: double

Risk-free rate, specified as a scalar.

Data Types: double

Proportional sales costs, specified as a vector.

Data Types: double

Turnover constraint on sales, specified as a scalar.

Data Types: double

Turnover constraint, specified as a scalar.

Data Types: double

Upper-bound constraint, specified as a vector.

Data Types: double

Upper-bound budget constraint, specified as a scalar.

Data Types: double

Upper-bound group constraint, specified as a vector.

Data Types: double

Maximum ratio of allocations between GroupA and GroupB, specified as a vector.

Data Types: double

Output Arguments

collapse all

Updated MAD portfolio object, returned as a PortfolioMAD, For more information on using the PortfolioMAD object, see Portfolio.

More About

collapse all

Mean-Absolute Deviation Portfolio Optimization

For more information on the theory and definition of mean-absolute deviation (MAD) optimization supported by portfolio optimization tools in Financial Toolbox™, see Portfolio Optimization Theory.

PortfolioMAD Problem Sufficiency

A MAD portfolio optimization problem is completely specified with the PortfolioMAD object if three conditions are met.

The following are the three conditions that must be met:

  • You must specify a collection of asset returns or prices known as scenarios such that all scenarios are finite asset returns or prices. These scenarios are meant to be samples from the underlying probability distribution of asset returns. This condition can be satisfied by the setScenarios function or with several canned scenario simulation functions.

  • The set of feasible portfolios must be a nonempty compact set, where a compact set is closed and bounded. You can satisfy this condition using an extensive collection of properties that define different types of constraints to form a set of feasible portfolios. Since such sets must be bounded, either explicit or implicit constraints can be imposed and several tools, such as the estimateBounds function, provide ways to ensure that your problem is properly formulated.

    Although the general sufficient conditions for MAD portfolio optimization go beyond these conditions, the PortfolioMAD object handles all these additional conditions.

Shortcuts for Property Names

The PortfolioMAD function has shorter argument names that replace longer argument names associated with specific properties of the PortfolioMAD object.

For example, rather than enter 'AInequality', the PortfolioMAD function. accepts the case-insensitive name 'ai' to set the AInequality property in a PortfolioMAD object. Every shorter argument name corresponds with a single property in the PortfolioMAD function. The one exception is the alternative argument name 'budget', which signifies both the LowerBudget and UpperBudget properties. When 'budget' is used, then the LowerBudget and UpperBudget properties are set to the same value to form an equality budget constraint.

Shortcuts for Property Names

Shortcut Argument Name

Equivalent Argument / Property Name

ae

AEquality

ai

AInequality

assetnames or assets

AssetList

be

bEquality

bi

bInequality

budget

UpperBudget and LowerBudget

group

GroupMatrix

lb

LowerBound

n or num

NumAssets

rfr

RiskFreeRate

scenario or assetscenarios

Scenarios

ub

UpperBound

References

[1] For a complete list of references for the PortfolioMAD object, see Portfolio Optimization.

Introduced in R2013b

Was this topic helpful?