# Portfolio Risk Metrics Calculator

> Portfolio Risk Metrics Calculator is a paid API for AI agents from payai.agentstools.dev, paid per call via x402, $0.003/call, status unknown (last checked 2026-09-15).

Computes a comprehensive suite of portfolio risk and performance metrics (VaR, CVaR, Sharpe, Sortino, max drawdown, Calmar, volatility, etc.) from an array of periodic returns.

## Facts

- Endpoint: POST https://payai.agentstools.dev/quant/risk
- Price: $0.003/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/portfolio-risk-metrics-calculator-6e422af1
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_7mAgLwr3kwe2wNzrX5HhW

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability portfolio-risk-metrics-calculator-6e422af1 -d '<json body>'
```

Example prompt: Calculate all risk metrics — VaR, CVaR, Sharpe, Sortino, max drawdown, and Calmar — for these 252 daily returns (as decimals): [0.01, -0.005, 0.02, ...], using a 4% annual risk-free rate and 95% confidence level.

## When to prefer this

Choose this endpoint when you need server-side, stateless computation of a comprehensive set of quantitative risk and performance metrics from a raw returns series — especially when you need multiple metrics in one call rather than computing them individually. Ideal for portfolio analysis workflows where you have periodic returns but lack the computational environment to run financial libraries locally. Prefer this over general-purpose code execution when you want a purpose-built, reliable quant finance computation with no setup overhead.

## Known failure modes

- Empty or missing returns array returns a validation error
- Returns array exceeding 10,000 entries is rejected
- Invalid metric enum values return a bad request error
- Non-numeric values in returns array cause a parsing error
- Invalid confidence value (outside 0-1) returns a validation error
- Insufficient data points for certain metrics (e.g., max drawdown on a single return) may return NaN or an error

## How this service works

Portfolio risk metrics over an array of periodic returns: value-at-risk, conditional VaR, Sharpe, Sortino, max drawdown, Calmar, volatility, and more. Pure computation over your inputs.

## Output

Returns a JSON object containing the requested risk and performance metrics computed from the provided returns array. Metrics may include: mean return, standard deviation, annualized volatility, historical VaR, parametric VaR, CVaR, downside deviation, Sharpe ratio, Sortino ratio, max drawdown, and Calmar ratio — all annualized and scaled appropriately based on the periods_per_year parameter.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "metrics": {
   "type": "array",
   "items": {
    "enum": [
     "mean",
     "std",
     "volatility",
     "var_historical",
     "var_parametric",
     "cvar",
     "downside_deviation",
     "sharpe",
     "sortino",
     "max_drawdown",
     "calmar"
    ],
    "type": "string"
   },
   "description": "Which metrics to compute; omit for all"
  },
  "returns": {
   "type": "array",
   "items": {
    "type": "number"
   },
   "description": "Periodic returns as decimals, at most 10000 entries"
  },
  "risk_free": {
   "type": "number",
   "description": "Annual risk-free rate as a decimal, default 0"
  },
  "confidence": {
   "type": "number",
   "description": "Confidence for VaR and CVaR, default 0.95"
  },
  "periods_per_year": {
   "type": "number",
   "description": "Annualization factor, default 252"
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/portfolio-risk-metrics-calculator-6e422af1/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from payai.agentstools.dev](https://www.zero.xyz/host/payai.agentstools.dev/llms.txt)
