# finmath Value at Risk (VaR)

> finmath Value at Risk (VaR) is a paid API for AI agents from finmath.qzqh5rrbkz.workers.dev, paid per call via x402, $0.002/call, status unknown (last checked 2026-09-15).

Computes Value at Risk (VaR) for a portfolio given a list of historical returns and a confidence level using exact deterministic arithmetic

## Facts

- Endpoint: POST https://finmath.qzqh5rrbkz.workers.dev/v1/value_at_risk
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/finmath-value-at-risk-var-cb96c37f
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_Yeike2JI8eYlwotWNcfV4

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 finmath-value-at-risk-var-cb96c37f -d '<json body>'
```

Example prompt: Calculate the 95% confidence Value at Risk using the historical method for these daily portfolio returns: [0.01, -0.02, 0.015, -0.03, 0.005, -0.04, 0.02, -0.01, 0.008, -0.025].

## When to prefer this

Use this endpoint when you need exact, deterministic VaR calculations rather than relying on an LLM's approximate arithmetic. Ideal for risk management workflows, portfolio analysis, compliance reporting, or any scenario where precise quantitative risk measurement is required. Prefer this over general-purpose LLM math when accuracy and reproducibility matter, especially for financial reporting or automated trading systems.

## Known failure modes

- Missing or empty returns array returns a 400 validation error
- Non-numeric values in the returns array cause a parsing error
- Confidence level outside 0-1 range returns a validation error
- Invalid method string returns an error indicating unsupported method
- Insufficient returns data points may yield unreliable or error results
- Payment not included or insufficient USDC triggers a 402 Payment Required response

## How this service works

Deterministic finance and crypto math for AI agents: TradFi (NPV, IRR, XIRR, Black-Scholes + Greeks, bonds, VaR, Sharpe) and DeFi (impermanent loss, perp liquidation, funding, Uniswap v3, health factor, cost basis). Exact, model-free arithmetic that LLMs get wrong — priced per call in USDC.

## Output

Returns a result object containing the computed VaR value (e.g. the maximum expected loss at the specified confidence level) and a meta object with calculation details such as method used, number of observations, and confidence level applied.

## Example request

```json
{
 "method": "historical",
 "returns": [
  0.02,
  -0.01,
  0.03,
  -0.02,
  0.015,
  0.025,
  -0.005,
  0.01
 ],
 "confidence": 0.95
}
```

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "returns"
 ],
 "properties": {
  "method": {
   "type": "string",
   "description": "method"
  },
  "returns": {
   "type": "array",
   "description": "returns"
  },
  "confidence": {
   "type": "number",
   "description": "confidence"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "result",
  "meta"
 ],
 "properties": {
  "meta": {
   "type": "object"
  },
  "result": {}
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/finmath-value-at-risk-var-cb96c37f/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from finmath.qzqh5rrbkz.workers.dev](https://www.zero.xyz/host/finmath.qzqh5rrbkz.workers.dev/llms.txt)
