# CAPM & Beta API
> Live capital-asset-pricing-model and systematic-risk analytics that quants and portfolio managers run on an asset against a market benchmark, computed on demand from the two series you pass in — no key, no cache, nothing stored. The beta endpoint regresses an asset's returns on the market's and returns the beta, the alpha (per period and annualised), the correlation and the R-squared, so you see how strongly the asset tracks the market and how much it amplifies it. The capm endpoint returns the CAPM expected return — risk-free rate plus beta times the market risk premium — and Jensen's alpha, the excess over what beta says the asset should earn; it also has a direct mode where you pass beta, market return and risk-free rate with no series. The treynor endpoint returns the Treynor ratio, the reward per unit of systematic (market) risk. This measures risk relative to a market — systematic risk — which is fundamentally different from single-series total-risk tools: it needs two series and answers how an asset moves with, and is priced against, the market. Works for any asset against any benchmark: stocks, funds, crypto, FX or a whole portfolio. Computed locally and deterministically, so it is instant and private. Ideal for portfolio analytics, factor and risk dashboards, fund fact-sheets and back-tests. Rates are fractions (0.02 = 2%). Live, nothing stored. 3 compute endpoints. For single-series Sharpe/volatility/drawdown use a risk-metrics API.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/capm-api/..."
```

## Pricing
- **Free** (Free) — 4,800 calls/Mo, 2 req/s
- **Starter** ($7/Mo) — 92,000 calls/Mo, 6 req/s
- **Pro** ($21/Mo) — 480,000 calls/Mo, 18 req/s
- **Business** ($48/Mo) — 2,950,000 calls/Mo, 45 req/s

## Endpoints

### CAPM

#### `GET /v1/beta` — Beta, alpha, correlation, R-squared

**Parameters:**
- `asset` (query, required, string) — Asset price series (or returns with as=returns) Example: `100,103,101,106,104,109`
- `market` (query, required, string) — Market benchmark series Example: `200,202,201,204,203,206`
- `as` (query, optional, string) — prices (default) or returns Example: `prices`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/capm-api/v1/beta?asset=100%2C103%2C101%2C106%2C104%2C109&market=200%2C202%2C201%2C204%2C203%2C206&as=prices"
```

**Response:**
```json
{
    "data": {
        "beta": 3.414164,
        "source": "CAPM",
        "r_squared": 0.999179,
        "correlation": 0.99959,
        "observations": 5,
        "interpretation": "more volatile than the market",
        "alpha_annualised": -0.636076,
        "alpha_per_period": -0.00252411,
        "periods_per_year": 252,
        "asset_return_annualised": 4.500542,
        "market_return_annualised": 1.504503
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:25.094Z",
        "request_id": "041f72df-b606-4612-83ad-a3300b51cc73"
    },
    "status": "ok",
    "message": "Beta computed",
    "success": true
}
```

#### `GET /v1/capm` — CAPM expected return + Jensen alpha

**Parameters:**
- `asset` (query, optional, string) — Asset series (series mode) Example: `100,103,101,106,104,109`
- `market` (query, optional, string) — Market series (series mode) Example: `200,202,201,204,203,206`
- `beta` (query, optional, string) — Beta (direct mode) Example: `1.2`
- `market_return` (query, optional, string) — Market return (direct mode, fraction) Example: `0.08`
- `risk_free` (query, optional, string) — Annual risk-free rate (fraction) Example: `0.02`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/capm-api/v1/capm?asset=100%2C103%2C101%2C106%2C104%2C109&market=200%2C202%2C201%2C204%2C203%2C206&beta=1.2&market_return=0.08&risk_free=0.02"
```

**Response:**
```json
{
    "data": {
        "beta": 1.2,
        "mode": "direct",
        "note": "Expected return = risk_free + beta x (market_return - risk_free). All rates as fractions (0.08 = 8%).",
        "source": "CAPM",
        "risk_free": 0.02,
        "market_return": 0.08,
        "market_risk_premium": 0.06,
        "capm_expected_return": 0.092
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:25.206Z",
        "request_id": "416dc418-e510-44c3-8b09-2aa345e6ca77"
    },
    "status": "ok",
    "message": "CAPM computed",
    "success": true
}
```

#### `GET /v1/treynor` — Treynor ratio — reward per systematic risk

**Parameters:**
- `asset` (query, required, string) — Asset price series Example: `100,103,101,106,104,109`
- `market` (query, required, string) — Market benchmark series Example: `200,202,201,204,203,206`
- `risk_free` (query, optional, string) — Annual risk-free rate (fraction) Example: `0.02`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/capm-api/v1/treynor?asset=100%2C103%2C101%2C106%2C104%2C109&market=200%2C202%2C201%2C204%2C203%2C206&risk_free=0.02"
```

**Response:**
```json
{
    "data": {
        "beta": 3.414164,
        "note": "Treynor = (asset return - risk_free) / beta, i.e. reward per unit of systematic (market) risk. Higher is better.",
        "source": "CAPM",
        "risk_free": 0.02,
        "observations": 5,
        "excess_return": 4.480542,
        "jensens_alpha": -0.587792,
        "treynor_ratio": 1.31234,
        "periods_per_year": 252,
        "asset_return_annualised": 4.500542
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:25.301Z",
        "request_id": "ff12339e-1c5a-469b-b056-93782ed6ad39"
    },
    "status": "ok",
    "message": "Treynor ratio computed",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Spec

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/capm-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "note": "asset & market = price series (default) or returns (as=returns), comma-separated oldest first, equal length. risk_free & periods_per_year optional; rates are fractions (0.02 = 2%).",
        "source": "Computed in-process from caller-supplied asset & market series (no upstream)",
        "service": "capm-api",
        "endpoints": {
            "GET /v1/beta": "Beta, alpha, correlation, R-squared (asset=100,102,...&market=200,201,...).",
            "GET /v1/capm": "CAPM expected return + Jensen's alpha; or direct mode (beta=1.2&market_return=0.08&risk_free=0.02).",
            "GET /v1/meta": "This document.",
            "GET /v1/treynor": "Treynor ratio — reward per unit of systematic risk (asset=...&market=...&risk_free=0.02)."
        },
        "description": "Live CAPM and systematic-risk (beta) analytics computed on demand from an asset and a market-benchmark series. The beta endpoint regresses asset returns on the market and returns beta, alpha, correlation and R-squared; the capm endpoint returns the CAPM expected return (risk-free + beta x market risk premium) and Jensen's alpha; the treynor endpoint returns the Treynor ratio (reward per unit of systematic risk). This measures risk relative to a market, distinct from single-series total-risk tools — it needs two series. Computed locally, nothing stored. Works for stocks, funds, crypto, FX or portfolios.",
        "upstream_status": "ok"
    },
    "meta": {
        "timestamp": 
…(truncated, see openapi.json for full schema)
```


---
Marketplace page: https://www.oanor.com/api/capm-api
OpenAPI spec: https://www.oanor.com/api/capm-api/openapi.json
