ClickAPIs
Docs · Portfolio risk

Docs / Endpoints

Portfolio risk

POST/v1/riskunits: 2 + 1 per holdingdaily

Portfolio volatility, historical and parametric VaR and CVaR (in money with a portfolio value), each holding’s share of risk, diversification ratio, beta and the worst days.

Add "async": true to run it as a job, and "webhook_url" to be called when it finishes (Jobs & async). Calls estimated above 1,000 units run as jobs automatically.

Parameters

FieldTypeDefaultDescription
symbolsrequiredarray of string—1–100 tickers.
weightsarray of numberequalWeights in the order of symbols; normalised to sum to 1.
lookback_daysinteger252Window in trading days.
benchmarkstring"SPY"Benchmark for portfolio beta.
portfolio_valuenumber—Notional; adds VaR and CVaR in money.
confidence_levelsarray of number[0.95, 0.99]VaR confidence levels.

Example request

Portfolio VaR for a 60/40 Read the walkthrough →

Request POST /v1/risk
{
  "symbols": [
    "SPY",
    "AGG"
  ],
  "weights": [
    0.6,
    0.4
  ],
  "portfolio_value": 1000000,
  "confidence_levels": [
    0.95,
    0.99
  ]
}
The same call with curl, Python and JavaScript
curl https://clickapis.com/v1/risk \
  -H "Authorization: Bearer $CLICKAPIS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"symbols":["SPY","AGG"],"weights":[0.6,0.4],"portfolio_value":1000000,"confidence_levels":[0.95,0.99]}'
import os, requests

r = requests.post(
    "https://clickapis.com/v1/risk",
    headers={"Authorization": f"Bearer {os.environ['CLICKAPIS_KEY']}"},
    json={
      "symbols": [
        "SPY",
        "AGG"
      ],
      "weights": [
        0.6,
        0.4
      ],
      "portfolio_value": 1000000,
      "confidence_levels": [
        0.95,
        0.99
      ]
    },
    timeout=60,
)
print(r.json()["data"])
const r = await fetch("https://clickapis.com/v1/risk", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.CLICKAPIS_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "symbols": [
      "SPY",
      "AGG"
    ],
    "weights": [
      0.6,
      0.4
    ],
    "portfolio_value": 1000000,
    "confidence_levels": [
      0.95,
      0.99
    ]
  }),
});
console.log((await r.json()).data);

Example response

Response 200 OK
{
  "ok": true,
  "data": {
    "start": "2025-11-12",
    "end": "2026-11-12",
    "days": 252,
    "portfolio_value": 1000000.0,
    "annual_volatility": 0.089883,
    "annual_return": 0.064943,
    "sharpe": 0.744931,
    "max_drawdown": -0.058648,
    "value_at_risk": [
      {
        "confidence": 0.95,
        "historical_var_1d": 0.00926,
        "historical_cvar_1d": 0.012578,
        "parametric_var_1d": 0.009313,
        "historical_var_10d_scaled": 0.029282,
        "historical_var_1d_amount": 9260.0,
        "historical_cvar_1d_amount": 12578.0,
        "parametric_var_1d_amount": 9313.0,
        "historical_var_10d_scaled_amount": 29282.0
      },
      {
        "confidence": 0.99,
        "historical_var_1d": 0.01334,
        "historical_cvar_1d": 0.018888,
        "parametric_var_1d": 0.013172,
        "historical_var_10d_scaled": 0.042183,
        "historical_var_1d_amount": 13340.0,
        "historical_cvar_1d_amount": 18888.0,
        "parametric_var_1d_amount": 13172.0,
        "historical_var_10d_scaled_amount": 42183.0
      }
    ],
    "diversification_ratio": 1.101921,
    "holdings": [
      {
        "symbol": "SPY",
        "weight": 0.6,
        "annual_volatility": 0.137333,
        "risk_contribution": 0.08117,
        "risk_contribution_pct": 0.903071,
        "value": 600000.0
      },
      {
        "symbol": "AGG",
        "weight": 0.4,
        "annual_volatility": 0.041609,
        "risk_contribution": 0.008712,
        "risk_contribution_pct": 0.096929,
        "value": 400000.0
      }
    ],
    "worst_days": [
      {
        "date": "2026-11-05",
        "return": -0.025459,
        "pnl": -25459.0
      },
      {
        "date": "2026-06-05",
        "return": -0.017466,
        "pnl": -17465.86
      },
      {
        "date": "2026-01-20",
        "return": -0.013739,
        "pnl": -13739.32
      },
      {
        "date": "2026-03-26",
        "return": -0.012955,
        "pnl": -12955.47
      },
      {
        "date": "2026-03-20",
        "return": -0.011909,
        "pnl": -11908.64
      }
    ],
    "benchmark": "SPY",
    "beta": 0.64472,
    "correlation": 0.985079
  },
  "meta": {
    "op": "risk",
    "units": 4,
    "cost_usd": 0.0,
    "billing": "internal",
    "free_call": false,
    "free_calls_left": 0,
    "balance_usd": 5.0,
    "ms": 99,
    "interval": "1day",
    "data_as_of": "2026-11-12",
    "partial_last_bar": false
  }
}

Every response has the same envelope: ok, data and meta (op, units, cost_usd, ms, interval, billing, balance_usd, data_as_of, partial_last_bar). Numbers are decimals (0.05 = 5%), dates ISO, and a value that cannot be computed is null.

More examples