Stress Test¶
Stress Test calculates the expected behavior of the portfolio under different scenarios, including extreme events. Everysk API calculates the probabilities of extreme events happening and factors those probabilities into the calculations. For example: it takes into account that correlations and volatility tend to increase in periods of market distress, resulting in large price oscillations for securities.
This API call returns 3 main measures for the specific scenario requested, namely:
- Conditional value at risk at the left tail of the distribution (CVaR-): The average of the worst (
1-confidence) percentile outcomes from the forward looking P&L distribution of the portfolio. - Expected profit and loss (EV): The average of the full forward looking P&L distribution of the portfolio.
- Conditional value at risk at the right tail of the distribution (CVaR+): The average of the best (
1-confidence) percentile outcomes from the forward looking P&L distribution of the portfolio.
To compute CVaR-, EV, CVaR+ for a portfolio, make an HTTP POST to your calculation resource URI:
HTTP Request
POST /calculations/stress_test
HTTP Parameters
| Parameter | Description |
|---|---|
portfolio_id string |
optional It is the ID of an existing portfolio. When passing a portfolio's ID as parameter the calculation will be performed using the given portfolio's securities, date, base currency and nlv. The securities parameter is no longer required. |
securities array |
REQUIRED * An array of objects to describe the securities in the portfolio. Each object represents a security with a unique id, symbol, quantity and label. For more details click here. * Not required if portfolio_id is provided. |
date string date |
optional, default is null (today) Portfolio date in the format: YYYYMMDD. The Portfolio Date instructs the API to use the market conditions and security prices prevailing on that date. Historical portfolios will be calculated without look ahead. To run using today’s conditions, use null. |
base_currency string |
optional, default is USD 3-letter ISO 4217 code for currency. Changing the base currency introduces new currency risks automatically. See all supported currencies here. |
nlv file |
optional, default is null (calculated) The net liquidating value (NAV). If not supplied, the API calculates it from all cash securities. Margin-traded securities are assumed to have NLV zero. Supplying an NLV reconciles the margin. |
horizon integer |
optional, default is 5 Simulation horizon. Accepts: 1, 5, 20 or 60. Passing null instructs the engine to extend horizons until the shock magnitude is observable. More info here. |
sampling integer |
optional, default is 1 Sampling frequency of historical data. 1 = daily, 5 = weekly (non-overlapping). |
aggregation string |
optional, default is position (no aggregation) Aggregates individual security MCTR’s by criteria such as: custom, position, country, sector, gics_sector, market_capitalization, liquidity, implied_rating, duration, security_type, security_type_refined, dividend_yield, exposure, currency, fixed_income, total_esg. See Risk Aggregations. |
projection array |
optional, default is ["IND:SPX"] Array of securities to be used as a top-down factor model. Max: 15. |
volatility_half_life integer |
optional, default is 2 Volatility half life in months: 0, 2, 6, 12, 24, or 48. |
correlation_half_life integer |
optional, default is 6 Correlation half life in months: 0, 2, 6, 12, 24, or 48. |
shock string |
optional, default is "IND:SPX" The security used for the stress test. |
magnitude file |
REQUIRED The magnitude of the shock. See more here. |
confidence string |
optional, default is "95%" Confidence level for CVaR calculation. Accepts: 1sigma, 2sigma, 3sigma, 85%, 90%, 95%, 97%, 99%. Details here. |
filter string |
optional, default is null (use the whole portfolio) Filter expression to pre-select identifiers (e.g., only fixed income). Calculations are run on the whole portfolio but only displayed for the filtered subset. See Filter Expression. |
To calculate the CVaR-, EV, CVaR+, run the following:
curl https://api.everysk.com/v2/calculations/stress_test \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-d '{
"securities": [
{
"id": "id1",
"symbol": "AAPL",
"quantity": 1000.0
},
{
"id": "id2",
"symbol": "SIE:XETR",
"quantity": 750.0
}
],
"date": "20210622",
"projection": ["SPY"],
"shock": "IND:SPX",
"magnitude": -0.1
}' \
-X POST
The above call returns the following JSON object:
{
"stress_test": {
"magnitude": -0.1,
"extrapolated": false,
"out_of_range": false,
"implied_magnitudes": [-0.1],
"results": [
{
"ev": [
{
"projection": "SPY",
"value": -0.05381884985690465
},
{
"projection": "residual",
"value": -0.00029460954393996727
}
],
"cvar_neg": [
{
"projection": "SPY",
"value": -0.09483311872511944
},
{
"projection": "residual",
"value": -0.024535867284700787
}
],
"cvar_pos": [
{
"projection": "SPY",
"value": -0.009455158729183554
},
{
"projection": "residual",
"value": 0.029583437854230045
}
],
"id": "id2"
},
{
"ev": [
{
"projection": "SPY",
"value": -0.08655629290002333
},
{
"projection": "residual",
"value": -0.0001557620360950901
}
],
"cvar_neg": [
{
"projection": "SPY",
"value": -0.15251911222218337
},
{
"projection": "residual",
"value": -0.0412765118097164
}
],
"cvar_pos": [
{
"projection": "SPY",
"value": -0.015206632816483687
},
{
"projection": "residual",
"value": 0.061881587296071544
}
],
"id": "id1"
}
],
"dynamic_range": [-0.11251559173161693, 0.12721726088932167],
"unmapped_tickers": [],
"implied_horizon": 90
}
}