Main Content

plot

Visualize value-at-risk (VaR), portfolio data, and highlight exceptions

Since R2023b

    Description

    example

    hPlot = plot(vbt) plots the VaR vectors and the portfolio data contained in the varbacktest object, vbt, with the exceptions function.

    example

    hPlot = plot(vbt,Name=Value) specifies additional plot styles using one or more name-value arguments. For example, hPlot = plot(vbt,Type="bar") specifies a bar-style plot.

    Examples

    collapse all

    Plots varbacktest data as a line and highlight the exceptions as dot markers. The plot function highlights a loss as an exception with respect to any VaR value.

    load VaRBacktestData
    vbt = varbacktest(EquityIndex, ...
       [Normal95 Normal99], ...
       'PortfolioID',"Equity", ...
       'VaRID',{'Normal95' 'Normal99'}, ...
       'VaRLevel',[0.95 0.99], ...
       'Time',Date);
    plot(vbt)

    Figure contains an axes object. The axes object with title VaR Backtesting, xlabel Time contains 4 objects of type line. One or more of the lines displays its values using only markers These objects represent Equity, Normal95, Normal99, Exceptions.

    A bar-style plot is effective for smaller time windows. Use the select function to choose the time window. In the bar-style plot, the plot function highlights the exceptions for each VaR vector separately, whereas the line plot highlights the point where an exception occurs with respect to any VaR value.

    load VaRBacktestData
    vbt = varbacktest(EquityIndex, ...
       [Normal95 Normal99], ...
       'PortfolioID',"Equity", ...
       'VaRID',{'Normal95' 'Normal99'}, ...
       'VaRLevel',[0.95 0.99], ...
       'Time',Date);
    vbtQ2 = select(vbt,TimeRange=[datetime(2000,4,1),datetime(2000,6,30)]);
    plot(vbtQ2,Type="bar")

    Figure contains an axes object. The axes object with title VaR Backtesting, xlabel Time contains 5 objects of type bar, stair, line. One or more of the lines displays its values using only markers These objects represent Equity, Normal95, Normal99, Normal95 exceptions, Normal99 exceptions.

    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.

    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: hPlot = plot(vbt,Type="bar")

    Axes object in which to plot. If you do not specify Parent, the plot function plots on the current Cartesian axes.

    Output plot type, specified as one of the following:

    • "line" — plots the portfolio data as a line with the exceptions highlighted as dot markers.

    • "bar" — plots the portfolio data as bars with the exceptions highlighted as circle markers.

    Example: hPlot = plot(vbt,Type="bar")

    Exception highlighting, specified as true (1) to display exception highlighting or false (0) to exclude it.

    Example: hPlot = plot(vbt,ShowExceptions=false)

    Output Arguments

    collapse all

    Figure handle for the line objects, returned as handle object.

    Version History

    Introduced in R2023b