# finmath Sharpe Ratio Calculator

> finmath Sharpe Ratio Calculator 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 the Sharpe ratio from a series of returns, optional risk-free rate, and annualization frequency using exact arithmetic

## Facts

- Endpoint: POST https://finmath.qzqh5rrbkz.workers.dev/v1/sharpe_ratio
- 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-sharpe-ratio-calculator-c3c97979
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_SKDD-rDi5eM0c-ESyPTJb

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-sharpe-ratio-calculator-c3c97979 -d '<json body>'
```

Example prompt: Calculate the Sharpe ratio for this series of monthly returns: [0.02, -0.01, 0.03, 0.015, -0.005, 0.04, 0.01, -0.02, 0.025, 0.03, 0.005, 0.02], using a risk-free rate of 0.04 and 12 periods per year.

## When to prefer this

Use this endpoint when you need deterministic, exact Sharpe ratio computation that an LLM might calculate incorrectly due to floating-point imprecision or hallucination. Prefer this over asking an LLM to do the math inline, especially when you have a specific risk-free rate and annualization period and need a verifiable result for financial reporting or automated trading strategy evaluation.

## Known failure modes

- Empty returns array — returns an error indicating insufficient data
- Returns array with zero standard deviation (all identical values) — division by zero scenario, likely returns null or error
- Invalid type for returns elements (non-numeric) — schema validation error
- Missing required 'returns' field — 400-level validation error
- Periods per year of zero — division by zero or error 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 JSON object with a 'result' field containing the computed Sharpe ratio (annualized if periods_per_year is provided) and a 'meta' object with details about the computation such as mean return, standard deviation, and excess return statistics.

## Example request

```json
{
 "returns": [
  0.02,
  0.015,
  0.03,
  -0.01,
  0.025,
  0.018,
  0.022,
  0.012
 ],
 "risk_free": 0.02,
 "periods_per_year": 12
}
```

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "returns"
 ],
 "properties": {
  "returns": {
   "type": "array",
   "description": "returns"
  },
  "risk_free": {
   "type": "number",
   "description": "risk_free"
  },
  "periods_per_year": {
   "type": "number",
   "description": "periods_per_year"
  }
 }
}
```

## 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-sharpe-ratio-calculator-c3c97979/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)
