# VWAP & Execution Benchmark API
> Live VWAP (volume-weighted average price) and execution-benchmark analytics that trading desks and algos run to judge a fill, computed on demand from the OHLCV candles you pass in — no key, no cache, nothing stored. The vwap endpoint returns the session VWAP, its cumulative curve and where the last price sits relative to it (above, below or at VWAP), using the typical price (high+low+close)/3 weighted by volume. The anchored endpoint returns the VWAP measured from a chosen bar — an anchored VWAP from a swing high, a session open or a news event. The benchmark endpoint scores an execution price against both VWAP and TWAP (time-weighted average price): the slippage in basis points and whether the fill beat the benchmark, separately for a buy or a sell. Works for any market — forex, equities, crypto or commodities — because you supply the candles. This is an execution-analytics engine: it turns price and volume into the benchmark a trader's fill is measured against, distinct from indicator and pattern tools. Computed locally and deterministically, so it is instant and private. Ideal for execution-quality (TCA) reporting, algo-trading back-tests, broker fill analysis and trading dashboards. VWAP uses the typical price (H+L+C)/3. Live, nothing stored. 3 compute endpoints. For raw price feeds use an exchange or FX 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/vwap-api/..."
```

## Pricing
- **Free** (Free) — 4,000 calls/Mo, 2 req/s
- **Starter** ($9/Mo) — 86,000 calls/Mo, 6 req/s
- **Pro** ($26/Mo) — 445,000 calls/Mo, 18 req/s
- **Business** ($62/Mo) — 2,700,000 calls/Mo, 45 req/s

## Endpoints

### VWAP

#### `GET /v1/anchored` — Anchored VWAP from a chosen bar

**Parameters:**
- `candles` (query, required, string) — OHLCV candles open:high:low:close:volume Example: `100:101:99:100:1000,100:103:101:102:2000,102:104:101:103:3000`
- `anchor` (query, optional, string) — Bar index to anchor from (default 0) Example: `1`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/vwap-api/v1/anchored?candles=100%3A101%3A99%3A100%3A1000%2C100%3A103%3A101%3A102%3A2000%2C102%3A104%3A101%3A103%3A3000&anchor=1"
```

**Response:**
```json
{
    "data": {
        "source": "VWAP",
        "candles": 3,
        "position": "above_vwap",
        "last_price": 103,
        "anchor_index": 1,
        "total_volume": 5000,
        "anchored_vwap": 102.4,
        "deviation_pct": 0.5859,
        "bars_in_anchor": 2
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:28.817Z",
        "request_id": "df0af8c0-6995-44b6-ae1f-2c96bca774d1"
    },
    "status": "ok",
    "message": "Anchored VWAP computed",
    "success": true
}
```

#### `GET /v1/benchmark` — Score a fill vs VWAP & TWAP

**Parameters:**
- `candles` (query, required, string) — OHLCV candles open:high:low:close:volume Example: `100:101:99:100:1000,100:103:101:102:2000,102:104:101:103:3000`
- `fill_price` (query, required, string) — Your execution price Example: `101`
- `side` (query, optional, string) — buy or sell (default buy) Example: `buy`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/vwap-api/v1/benchmark?candles=100%3A101%3A99%3A100%3A1000%2C100%3A103%3A101%3A102%3A2000%2C102%3A104%3A101%3A103%3A3000&fill_price=101&side=buy"
```

**Response:**
```json
{
    "data": {
        "note": "Slippage positive = worse than the benchmark; beat_benchmark = the fill was better than the benchmark for this side. bps relative to the benchmark.",
        "side": "buy",
        "twap": 101.66666667,
        "vwap": 102,
        "source": "VWAP",
        "candles": 3,
        "vs_twap": {
            "slippage": -0.66666667,
            "slippage_bps": -65.57,
            "beat_benchmark": true
        },
        "vs_vwap": {
            "slippage": -1,
            "slippage_bps": -98.04,
            "beat_benchmark": true
        },
        "fill_price": 101
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:28.915Z",
        "request_id": "86754eb0-442b-40dc-bc65-46c1e5a0b60e"
    },
    "status": "ok",
    "message": "Execution benchmarked",
    "success": true
}
```

#### `GET /v1/vwap` — Session VWAP + cumulative curve

**Parameters:**
- `candles` (query, required, string) — OHLCV candles open:high:low:close:volume, comma-separated oldest first Example: `100:101:99:100:1000,100:103:101:102:2000,102:104:101:103:3000`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/vwap-api/v1/vwap?candles=100%3A101%3A99%3A100%3A1000%2C100%3A103%3A101%3A102%3A2000%2C102%3A104%3A101%3A103%3A3000"
```

**Response:**
```json
{
    "data": {
        "vwap": 102,
        "source": "VWAP",
        "candles": 3,
        "position": "above_vwap",
        "deviation": 1,
        "last_price": 103,
        "total_volume": 6000,
        "deviation_pct": 0.9804,
        "cumulative_vwap": [
            100,
            101.33333333,
            102
        ]
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:29.008Z",
        "request_id": "bed0b933-4c15-406d-b56d-52387a9fa164"
    },
    "status": "ok",
    "message": "VWAP computed",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "note": "candles = open:high:low:close:volume, comma-separated, oldest first. Volume is required for VWAP.",
        "source": "Computed in-process from caller-supplied OHLCV candles (no upstream)",
        "service": "vwap-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/vwap": "Session VWAP + cumulative curve (candles=o:h:l:c:v,...).",
            "GET /v1/anchored": "VWAP measured from a chosen bar (candles=..., anchor=0).",
            "GET /v1/benchmark": "Score a fill vs VWAP & TWAP (candles=..., fill_price=100.5, side=buy)."
        },
        "description": "Live VWAP and execution-benchmark analytics computed on demand from OHLCV candles. The vwap endpoint returns the session VWAP, its cumulative curve and where the last price sits relative to it; the anchored endpoint returns the VWAP measured from a chosen bar; the benchmark endpoint scores an execution price against VWAP and TWAP (slippage in basis points and whether the fill beat the benchmark). Computed live from your input, nothing stored — works for forex, stocks, crypto or commodities. An execution-analytics engine, distinct from indicator and pattern tools. VWAP uses the typical price (H+L+C)/3.",
        "upstream_status": "ok"
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:29.105Z",
        "request_id": "4c94268c-d0a4-4465-9e4d-e81a90e1ed2d"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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