Main Content

append

Add portfolio and value-at-risk (VaR) data to varbacktest object

Since R2023b

    Description

    example

    vbt = append(vbt,newPortfolioData,newVarData) adds portfolio and VaR data to a varbacktest object, where vbt is the output VaR backtest object, newPortfolioData is the new portfolio data, and newVarData is the new VaR data.

    example

    vbt = append(vbt,newPortfolioData,newVarData,Time=newDates) adds the new dates contained in newDates to a VaR backtest object, vbt.

    Examples

    collapse all

    Create a varbacktest object and use the append function to augment the porfolio data vectors by one element.

    load VaRBacktestData
    vbt = varbacktest(EquityIndex,Normal95)
    vbt = 
      varbacktest with properties:
    
        PortfolioData: [1043x1 double]
              VaRData: [1043x1 double]
                 Time: [1043x1 double]
          PortfolioID: "Portfolio"
                VaRID: "VaR"
             VaRLevel: 0.9500
    
    
    vbt = append(vbt, -0.0021, 0.0204)
    vbt = 
      varbacktest with properties:
    
        PortfolioData: [1044x1 double]
              VaRData: [1044x1 double]
                 Time: [1044x1 double]
          PortfolioID: "Portfolio"
                VaRID: "VaR"
             VaRLevel: 0.9500
    
    

    Create a varbacktest object and use the append function to augment the portfolio data vectors with dates by using the name-value argument Time.

    load VaRBacktestData
    vbt = varbacktest(EquityIndex, ...
       [Normal95 Normal99 Historical95 Historical99 EWMA95 EWMA99], ...
       'Time',Date, ...
       'PortfolioID','Equity', ...
       'VaRID',{'Normal95' 'Normal99' 'Historical95' 'Historical99' 'EWMA95' 'EWMA99'}, ...
       'VaRLevel',[0.95 0.99 0.95 0.99 0.95 0.99])
    vbt = 
      varbacktest with properties:
    
        PortfolioData: [1043x1 double]
              VaRData: [1043x6 double]
                 Time: [1043x1 datetime]
          PortfolioID: "Equity"
                VaRID: ["Normal95"    "Normal99"    "Historical95"    "Historical99"    "EWMA95"    "EWMA99"]
             VaRLevel: [0.9500 0.9900 0.9500 0.9900 0.9500 0.9900]
    
    
    newEquityData = [-0.0021; 0.0005];
    newVaRData = [0.02029, 0.0287, 0.01935, 0.02954, 0.01662, 0.02351; ...
        0.020285, 0.0282, 0.01335, 0.02954, 0.01630, 0.023878];
    newDates = [datetime(2003, 1, 2); datetime(2003, 1, 3)];
    vbt = append(vbt,newEquityData,newVaRData,Time=newDates)
    vbt = 
      varbacktest with properties:
    
        PortfolioData: [1045x1 double]
              VaRData: [1045x6 double]
                 Time: [1045x1 datetime]
          PortfolioID: "Equity"
                VaRID: ["Normal95"    "Normal99"    "Historical95"    "Historical99"    "EWMA95"    "EWMA99"]
             VaRLevel: [0.9500 0.9900 0.9500 0.9900 0.9500 0.9900]
    
    

    Input Arguments

    collapse all

    VaR backtest object, specified as a varbacktest object. vbt contains a copy of the given data (the PortfolioData and VarData properties) and all combinations of portfolio ID, VaR ID, and VaR levels to be tested.

    New equity data to be added to the existing portfolio data vector, specified as a numeric vector.

    Data Types: double

    New value-at-risk data to be added to the existing VaR data vector, specified as a matrix with the number of columns matching the number of VaR IDs from the VaRID property in the parent varbacktest object.

    Data Types: double

    New dates to be added to the existing date vector, specified as a datetime vector or a numeric vector.

    • The data type of newDates must match the data type of the Time property in the parent varbacktest object.

    • The size of newDates must match the size of the newPortolioData argument.

    Data Types: double | datetime

    Version History

    Introduced in R2023b