Skip to content

Parametric Risk Attribution


Calculates the magnitude of a security's reaction to changes in underlying factors, most often in terms of its price response to other factors.

HTTP Request

POST /calculations/parametric_risk_attribution

HTTP Parameters

Parameter Description
portfolio_id string optional The ID of an existing portfolio. When provided, the calculation uses the portfolio's securities, date, base currency, and NLV. The securities parameter is no longer required.
securities array REQUIRED * An array of objects describing the securities in the portfolio. Each object includes 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 API uses the market conditions and security prices of that date.
base_currency string optional, default is USD 3-letter ISO 4217 currency code. Changing the base currency adds the currency risks. See supported currencies here.
nlv float optional, default is null (calculated) The net liquidating value (NAV) of the portfolio. If you do not send it, the API calculates it from all cash securities.
projection array optional, default is ["IND:SPX"] User-supplied array of securities to be used as a top-down factor model. Maximum number of elements is 15.
projection_model object optional The factors of the top-down factor model, with a name and a label for each factor. When you send it, the API ignores projection. See Projection model.
use_cashflow boolean optional, default is True For fixed income securities:
• True: maps each cashflow event (interest, principal amortization) to key points in the respective interest rate curve.
• False: uses Macaulay duration to map bond price to neighboring key points in the respective curve.
sampling integer optional, default is 5 Frequency of historical data sampling. Use 1 for daily, 5 for weekly (non-overlapping). Accepts: 1 or 5. If you send a horizon less than sampling, the API uses the horizon value as the sampling.
confidence string optional, default is 95% Confidence level for calculating VaR and CVaR. Accepts: 1_sigma, 2_sigma, 3_sigma, 85%, 90%, 95%, 97%, 97.5% or 99%. More details here.
historical_days integer optional, default is 252 Number of business days used to calculate the covariance for the primitive risk factors.
exponential_decay float optional, default is 0.94 Factor used in the exponentially weighted moving average (EWMA). Accepts float values from 0 to 1.
risk_factor_mean string optional, default is zero How the engine estimates the risk factor volatilities and correlations: zero or decayed. Both weight the returns with exponential_decay. With decayed, the engine also builds the correlation matrix from the decayed returns. Another value makes the calculation fail.
idi_as_riskfactor boolean optional, default is true Applies only to options on the Brazilian IDI future (BRFUT:IDI). When true, the engine uses their underlying, IND:IDI2009, as a risk factor. When false, it does not.
filter string optional, default is null (use the whole portfolio) Filter expression to select a subset of securities for display. The calculation runs on the whole portfolio. See Filter Expression.
model string optional, default is v1 The calculation engine: v1 or v2. See Calculation model.

To calculate the parametric risk, run the following:

curl https://api.everysk.com/v2/calculations/parametric_risk_attribution \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
        "projection": ["IND:BVSP"],
        "securities": [
          {
            "id": "id1",
            "symbol": "PETR4:BVMF",
            "quantity": 150.0
          }
        ],
        "base_currency": "BRL",
        "date": "20210711"
      }' \
  -X POST

The above call returns the following JSON object:

{
  "parametric_risk_attribution": {
    "results": {
      "port_parametric_vol": 428.93616533156944,
      "port_parametric_var": -705.5372072762883,
      "port_parametric_cvar": -884.87,
      "sec_parametric_contribution_to_vol": {
        "id1": 428.93616533156944
      },
      "sec_parametric_contribution_to_var": {
        "id1": -705.5372072762883
      },
      "sec_parametric_standalone_vol": {
        "id1": 428.93616533156944
      },
      "sec_parametric_standalone_var": {
        "id1": -705.5372072762883
      },
      "sec_factor_exposure_dixpre": {
        "id1": 0.0
      },
      "sec_parametric_factor_exposure": {
        "id1": [6881.49]
      },
      "sec_parametric_no_sens_factor_exposure": {
        "id1": [6881.49]
      },
      "factor_parametric_correlations": [
        [1.0]
      ],
      "factor_labels": ["IND:BVSP"]
    },
    "unmapped_tickers": []
  }
}

The example shows part of the response. The results object also contains sec_parametric_contribution_to_cvar, sec_parametric_standalone_cvar, sec_factor_exposure_cupomlimpo, sec_factor_exposure_dixipca, factor_parametric_contribution_to_vol, factor_parametric_contribution_to_var, factor_parametric_contribution_to_cvar, port_max_contribution_to_var, port_max_contribution_to_var_sec, factor_parametric_standalone_vol and factor_parametric_sensitivities.