Documentation

simulateNormalScenariosByData

Class: PortfolioCVaR

Simulate multivariate normal asset return scenarios from data for PortfolioCVaR object

Syntax

obj = simulateNormalScenariosByData(obj,AssetReturns,
NumScenarios)
obj = simulateNormalScenariosByData(obj,AssetReturns,
NumScenarios,varargin)

Description

obj = simulateNormalScenariosByData(obj,AssetReturns,
NumScenarios)
to simulate multivariate normal asset return scenarios for a CVaR portfolio object from data.

obj = simulateNormalScenariosByData(obj,AssetReturns,
NumScenarios,varargin)
to simulate multivariate normal asset return scenarios for a CVaR portfolio object from data using the optional input varagin with additional options specified by one or more Name,Value pair arguments.

This method estimates the mean and covariance of asset returns from either price or return data and then uses these estimates to generate the specified number of scenarios with the function mvnrnd.

Data can in be either a NumSamples-by-NumAssets matrix of NumSamples prices or returns at a given periodicity for a collection of NumAssets assets or a fints object with NumSamples observations and NumAssets time series.

    Note:   If you want to use the method multiple times and you want to simulate identical scenarios each time the function is called, precede each function call with rng(seed) using a specified integer seed.

Tips

You can also use dot notation to simulate multivariate normal asset return scenarios from data for a CVaR portfolio object.

obj = obj.simulateNormalScenariosByData(AssetReturns, NumScenarios, varargin);

Input Arguments

obj

A CVaR portfolio object [PortfolioCVaR].

AssetReturns

Either a matrix or fints object that contains asset data that can be converted into asset returns [NumSamples-by-NumAssets] matrix.

NumScenarios

Number of scenarios to simulate [positive integer].

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.

DataFormat

DataFormat values are:

  • Returns — Data in AssetReturns are asset total returns.

  • Prices — Data in AssetReturns are asset total return prices.

Default: Returns

MissingData

MissingData values are:

  • false — Do not use ECM algorithm to handle NaN values (just exclude NaN values).

  • true — Use ECM algorithm to handle NaN values.

Default: false

GetAssetList

GetAssetList values 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 method 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, nothing happens, which is the default.

Default: false

Output Arguments

obj

Updated CVaR portfolio object [PortfolioCVaR].

Attributes

Accesspublic
Staticfalse
Hiddenfalse

To learn about attributes of methods, see Method Attributes in the MATLAB® Object-Oriented Programming documentation.

Examples

expand all

Simulate Multivariate Normal Asset Return Scenarios from Data

Given a PortfolioCVaR object p, use the simulateNormalScenariosByData method to simulate multivariate normal asset return scenarios from data.

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;

RawData = mvnrnd(m, C, 240);
NumScenarios = 2000;

p = PortfolioCVaR;
p = simulateNormalScenariosByData(p, RawData, NumScenarios)
p = setDefaultConstraints(p);
p = setProbabilityLevel(p, 0.9);

disp(p);
p = 

  PortfolioCVaR with properties:

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

  PortfolioCVaR with properties:

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

Simulate Multivariate Normal Asset Return Scenarios from Market Data

Create a PortfolioCVaR object p and use the simulateNormalScenariosByData method with market data loaded from CAPMuniverse.mat to simulate multivariate normal asset return scenarios.

load CAPMuniverse

p = PortfolioCVaR('AssetList',Assets(1:12));
disp(p);
  PortfolioCVaR with properties:

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

Simulate the scenarios from the data for each of the 12 assets from CAPMuniverse.mat.

p = simulateNormalScenariosByData(p, Data(:,1:12), 20000 ,'missingdata',true);
Was this topic helpful?