Main Content

select

Select value-at-risk (VaR) or expected shortfall (ES) data from backtest objects

Since R2023b

    Description

    example

    subbtobj = select(btobj,Name=Value) returns a selection of backtesting data, where btobj is either an esbacktest (since R2024a) or a varbacktest object. For example, subbtobj = select(btobj,TimeRange=timeRange) selects ES or VaR data for a specified time range.

    Examples

    collapse all

    Use the select function and specify the optional arguments TimeRange and NewPortfolioID to create a varbacktest subobject containing data for Q1 of year 2000. Reset the portfolio ID to reflect your selection.

    load VaRBacktestData
    btobj = varbacktest(EquityIndex,Normal95,'Time',Date);
    timeRange = [datetime(2000,1,1),datetime(2000,3,31)];
    subbtobj = select(btobj,TimeRange=timeRange,NewPortfolioID="Equity, Q1 2000")
    subbtobj = 
      varbacktest with properties:
    
        PortfolioData: [65x1 double]
              VaRData: [65x1 double]
                 Time: [65x1 datetime]
          PortfolioID: "Equity, Q1 2000"
                VaRID: "VaR"
             VaRLevel: 0.9500
    
    

    Use the select function and specify the optional arguments TimeRange and NewPortfolioID to create an esbacktest subobject containing data for Q1 of year 2000. Reset the portfolio ID to reflect your selection.

    load ESBacktestData
    btobj = esbacktest(Returns,VaRModel1,ESModel1,'Time',Dates);
    timeRange = [datetime(2000,1,1), datetime(2000,3,31)];
    subbtobj = select(btobj,TimeRange=timeRange,NewPortfolioID='S&P, Q1 2000')
    subbtobj = 
      esbacktest with properties:
    
        PortfolioData: [65x1 double]
              VaRData: [65x1 double]
               ESData: [65x1 double]
                 Time: [65x1 datetime]
          PortfolioID: "S&P, Q1 2000"
                VaRID: "VaR"
             VaRLevel: 0.9500
    
    

    Input Arguments

    collapse all

    Backtest object, specified as either a varbacktest or an esbacktest object.

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: subbtobj = select(btobj,TimeRange=[1,100])

    Time range for the backtesting data you would like to select from a varbacktest or esbacktest object, specified as either of the following:

    • Numeric row vector, datetime row vector, or duration row vector with the data type matching the data type of the Time property vector in the backtest object

    • Logical row vector with the size matching the size of the Time property vector in the backtest object

    The output for the object contains data points corresponding to either the time window TimeRange(1) through TimeRange(2) or to the time points specified by a logical row vector. If you do not specify TimeRange, the select function includes all time points in the output window.

    Example: subbtobj = select(btobj,TimeRange=[1,100])

    Example: subbtobj = select(btobj,TimeRange=[datetime(2000,1,1),datetime(2000,3,31)])

    Data Types: double | datetime | duration | logical

    VaR IDs from the input varbacktest or esbacktest object, specified as a string vector. The output backtest object contains the selected VaR data. If you do not specify VaRID, the select function returns data for all VaR IDs.

    Example: subbtobj = select(btobj,VaRID=["Historical95","Historical99"])

    Data Types: string

    New portfolio ID contained the output backtest object, specified as a string scalar. If you do not specify NewPortfolioID, select function uses the portfolio ID of the input varbacktest or esbacktest object.

    Example: subbtobj = select(btobj,TimeRange=timeRange,NewPortfolioID="Equity Q1 2000")

    Data Types: string

    Version History

    Introduced in R2023b

    expand all