# QuantOracle Portfolio Optimizer

> QuantOracle Portfolio Optimizer is a paid API for AI agents from api.quantoracle.dev, paid per call via x402, $0.015/call, status unknown (last checked 2026-09-13).

Optimizes a multi-asset portfolio's weight allocation using mean-variance analysis (e.g. max Sharpe ratio) given historical return series and a risk-free rate

## Facts

- Endpoint: POST https://api.quantoracle.dev/v1/portfolio/optimize
- Price: $0.015/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/api-quantoracle-dev-71b5ac03
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_QTc7ZqmWK6HVbNE19-Fj7

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 api-quantoracle-dev-71b5ac03 -d '<json body>'
```

Example prompt: Optimize the weights for my portfolio of AAPL, MSFT, and TSLA to maximize the Sharpe ratio — here are 10 periods of returns for each: AAPL [0.01, -0.005, 0.02, 0.015, -0.01, 0.008, 0.012, -0.003, 0.018, 0.005], MSFT [0.008, 0.003, -0.01, 0.012, 0.006, -0.002, 0.014, 0.009, -0.005, 0.011], TSLA [0.03, -0.02, 0.015, 0.025, -0.015, 0.022, 0.018, -0.008, 0.028, 0.012], and use a risk-free rate of 5%.

## When to prefer this

Use this endpoint when you need quantitative, mean-variance portfolio optimization (e.g. max Sharpe or min volatility) given raw historical return series. Prefer this over simpler equal-weight or rule-based rebalancing endpoints when you have asset return history and want mathematically optimal weight allocation with Sharpe ratio output.

## Known failure modes

- Insufficient return data (fewer periods than assets) leading to singular covariance matrix
- Mismatched return series lengths across assets
- Invalid or unsupported optimization mode
- Risk-free rate provided as decimal vs percentage mismatch
- All-zero or constant return series causing division errors
- Network or payment (x402) failure returning 402 or 5xx

## How this service works

QuantOracle: portfolio/optimize

## Output

Returns the optimal portfolio weight for each asset (summing to 1), the annualized expected return, portfolio volatility, Sharpe ratio, the optimization mode used, and computation time in milliseconds. Assets with zero weight are excluded from the optimal allocation.

## Example request

```json
{
 "input": {
  "body": {
   "mode": "max_sharpe",
   "returns": {
    "AAPL": [
     0.01,
     -0.005,
     0.02,
     0.015,
     -0.01,
     0.008,
     0.012,
     -0.003,
     0.018,
     0.005
    ],
    "MSFT": [
     0.008,
     0.003,
     -0.01,
     0.012,
     0.006,
     -0.002,
     0.014,
     0.009,
     -0.005,
     0.011
    ],
    "TSLA": [
     0.03,
     -0.02,
     0.015,
     0.025,
     -0.015,
     0.022,
     0.018,
     -0.008,
     0.028,
     0.012
    ]
   },
   "risk_free_rate": 0.05
  },
  "type": "http",
  "method": "POST",
  "bodyType": "json"
 }
}
```

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "mode": {
   "enum": [
    "max_sharpe",
    "min_vol",
    "risk_parity"
   ],
   "type": "string",
   "title": "Mode",
   "default": "max_sharpe",
   "description": "Optimization objective"
  },
  "returns": {
   "type": "object",
   "title": "Returns",
   "description": "Named return series per asset, e.g. {\"AAPL\": [...], \"MSFT\": [...]}",
   "additionalProperties": {
    "type": "array",
    "items": {
     "type": "number"
    }
   }
  },
  "risk_free_rate": {
   "type": "number",
   "title": "Risk Free Rate",
   "default": 0.05,
   "description": "Annual risk-free rate"
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/api-quantoracle-dev-71b5ac03/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.quantoracle.dev](https://www.zero.xyz/host/api.quantoracle.dev/llms.txt)
