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.

setScenarios

Set asset returns scenarios by direct matrix

Use the setScenarios function with a PortfolioCVaR or PortfolioMAD objects to set asset returns scenarios by direct matrix.

For details on the workflows, see PortfolioCVaR Object Workflow, and PortfolioMAD Object Workflow.

Syntax

obj = setScenarios(obj,AssetScenarios)
obj = setScenarios(obj,AssetScenarios,Name,Value)

Description

example

obj = setScenarios(obj,AssetScenarios) sets asset returns scenarios by direct matrix for PortfolioCVaR or PortfolioMAD objects.

example

obj = setScenarios(obj,AssetScenarios,Name,Value) set asset returns scenarios by direct matrix for PortfolioCVaR or PortfolioMAD objects using additional options specified by one or more Name,Value pair arguments.

Examples

collapse all

Given a PortfolioCVaR object p, use the setScenarios function to set asset return scenarios.

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 = PortfolioCVaR;
p = setScenarios(p, AssetScenarios);
p = setDefaultConstraints(p);
p = setProbabilityLevel(p, 0.95);
disp(p)
  PortfolioCVaR with properties:

             BuyCost: []
            SellCost: []
        RiskFreeRate: []
    ProbabilityLevel: 0.9500
            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: []

Given PortfolioMAD object p, use the setScenarios function to set asset return scenarios.

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 = setDefaultConstraints(p);
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: []

Input Arguments

collapse all

Object for portfolio, specified using a PortfolioCVaR or PortfolioMAD object.

For more information on creating a PortfolioCVaR or PortfolioMAD object, see

Scenarios for asset returns or prices, specified as a matrix. If the input data are prices, they can be converted into returns with the 'DataFormat' name-value argument, where the default format is assumed to be 'Returns'. Be careful using price data because portfolio optimization usually requires total returns and not simply price returns.

This function sets up a function handle to indirectly access input AssetScenarios without needing to make a copy of the data.

Data Types: double

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 = setScenarios(p, AssetScenarios,'DataFormat','Returns','GetAssetList',false);

collapse all

Flag to convert input data as prices into returns, specified using a character vector with the values:

  • 'Returns' — Data in AssetReturns contains asset total returns.

  • 'Prices' — Data in AssetReturns contains asset total return prices.

Data Types: char

Flag indicating which asset names to use for the asset list, specified as a logical with a value of true or false. Acceptable values for GetAssetList are:

  • false — Do not extract or create asset names.

  • true — Extract or create asset names from fints object.

If a fints object is passed into this function and the GetAssetList flag is true, the series names from the fints object are used as asset names in obj.AssetList.

If a matrix is passed and the GetAssetList flag is true, default asset names are created based on the AbstractPortfolio property defaultforAssetList, which is currently 'Asset'.

If the GetAssetList flag is false, no action occurs, which is the default behavior.

Data Types: logical

Output Arguments

collapse all

Updated portfolio object, returned as a PortfolioCVaR or PortfolioMAD object. For more information on creating a portfolio object, see

Tips

You can also use dot notation to set asset return scenarios.

obj = obj.setScenarios(AssetScenarios);

Introduced in R2012b

Was this topic helpful?