append
Add portfolio, value-at-risk (VaR), and expected shortfall (ES) data to backtest objects
Since R2023b
Syntax
Description
vbt = append(
adds portfolio and VaR data to a vbt
,newPortfolioData
,newVaRData
)varbacktest
object, vbt
.
ebt = append(
adds portfolio, VaR, and ES data to an ebt
,newPortfolioData
,newVaRData
,newESData
)esbacktest
object, ebt
(since R2024a).
___ = append(___,Time=
adds the new dates contained in newDates
)newDates
to either a varbacktest
or an esbacktest
object.
Examples
Append VaR Backtest Portfolio Data
Create a varbacktest
object and append a new entry to it by using the append
function.
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
Append ES Backtest Portfolio Data
Create an esbacktest
object and append a new entry to it by using the append
function.
load ESBacktestData
ebt = esbacktest(Returns,VaRModel1,ESModel1)
ebt = esbacktest with properties: PortfolioData: [1966x1 double] VaRData: [1966x1 double] ESData: [1966x1 double] Time: [1966x1 double] PortfolioID: "Portfolio" VaRID: "VaR" VaRLevel: 0.9500
ebt = append(ebt,-0.0135,0.0300,0.0358)
ebt = esbacktest with properties: PortfolioData: [1967x1 double] VaRData: [1967x1 double] ESData: [1967x1 double] Time: [1967x1 double] PortfolioID: "Portfolio" VaRID: "VaR" VaRLevel: 0.9500
Append VaR Backtest Portfolio Data with Dates
Create a varbacktest
object and append two new entities with explicit dates by using the Time
name-value argument.
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]
Append ES Backtest Portfolio Data with Dates
Create an esbacktest
object and append two new entities with explicit dates by using the Time
name-value argument.
load ESBacktestData ebt = esbacktest(Returns, ... [VaRModel1 VaRModel2 VaRModel3], ... [ESModel1 ESModel2 ESModel3], ... 'Time', Dates, ... 'PortfolioID','S&P', ... 'VaRID',{'Model 1','Model 2','Model3'}, ... 'VaRLevel',VaRLevel)
ebt = esbacktest with properties: PortfolioData: [1966x1 double] VaRData: [1966x3 double] ESData: [1966x3 double] Time: [1966x1 datetime] PortfolioID: "S&P" VaRID: ["Model 1" "Model 2" "Model3"] VaRLevel: [0.9750 0.9750 0.9750]
newReturnsData = [-0.0056; 0.0034]; newVaRData = [0.0308,0.0313,0.0313; ... 0.0310,0.0315,0.0315]; newESData = [0.0367,0.0396,0.0429; ... 0.0370, 0.0399, 0.0431]; newDates = [datetime(2003,7,15); datetime(2003,7,16)]; ebt = append(ebt,newReturnsData,newVaRData,newESData,Time=newDates)
ebt = esbacktest with properties: PortfolioData: [1968x1 double] VaRData: [1968x3 double] ESData: [1968x3 double] Time: [1968x1 datetime] PortfolioID: "S&P" VaRID: ["Model 1" "Model 2" "Model3"] VaRLevel: [0.9750 0.9750 0.9750]
Input Arguments
vbt
— VaR backtest object
varbacktest
object
VaR backtest object, specified as a varbacktest
object. Use this input argument when working with the first or
third syntax. 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.
ebt
— ES backtest object
esbacktest
object
ES backtest object, specified as an esbacktest
object. Use this input argument when working with the second or
third syntax. ebt
contains a copy of the given data (the
PortfolioData
, VarData
, and
ESData
properties) and all combinations of portfolio ID, VaR ID,
and VaR levels to be tested.
newPortfolioData
— New portfolio data
numeric vector
New equity data to be added to the existing portfolio data vector, specified as a numeric vector.
Data Types: double
newVaRData
— New value-at-risk data
numeric matrix
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.
The VaR vectors should represent the VaR levels at the same confidence level in the same
order.
Data Types: double
newESData
— New expected shortfall data
numeric matrix
New expected shortfall data, specified as a matrix with the number of columns
matching the number of ES vectors in the parent esbacktest
object.
The ES vectors should represent the ES levels for the same VaR levels in the same
order.
Data Types: double
newDates
— New dates
numeric vector (default) | datetime vector | duration vector
New dates to be added to the existing date vector, specified as a sequential numeric
vector, a datetime
vector, or a duration
vector.
The default numeric vector is
NumRows+1:NumRows+NumNewDataRows
, whereNumRows
is the number of data points in the parentvarbacktest
oresbacktest
object andNumNewDataRows
is the number of new data points being appended. For example,vbt=append(vbt,newEquityData,newVaRData,Time=newDates)
appends new equity data to the VaR backtest object with explicit dates contained innewDates
by using theTime
name-value argument.The data type of
newDates
must match the data type of theTime
property in the inputvarbacktest
oresbacktest
object.The size of
newDates
must match the size of thenewPortolioData
argument.
Data Types: double
| datetime
| duration
Version History
Introduced in R2023bR2024a: Append data to ES backtest objects
Append portfolio, VaR, and ES backtest data to ES backtest objects.
See Also
varbacktest
| esbacktest
| bin
| pof
| tuff
| cc
| cci
| tbf
| tbfi
| summary
| runtests
| exceptions
| select
| plot
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)