# Trade Stats API
> Live trading-performance analytics that traders run on a list of realised trade results, computed on demand from the profit-and-loss series you pass in — no key, no cache, nothing stored. The analyze endpoint returns the full performance scorecard: number of wins and losses, win rate, gross profit and loss, profit factor, expectancy, average win and loss, payoff ratio, and the largest win and loss — the numbers a trader pulls from a trade journal to judge a strategy. The equity endpoint builds the equity curve from a starting balance and returns the running balance after every trade, the peak, the maximum drawdown in money and percent, and the total return. The streaks endpoint returns the longest winning and losing runs and the current streak. This is a backward-looking trade-journal analyzer — it scores actual results, which is fundamentally different from forward Monte-Carlo simulators and position sizers that work from assumptions. Each value you pass is one closed trade's profit (positive) or loss (negative). Works for any market or strategy — stocks, forex, crypto or futures. Computed locally and deterministically, so it is instant and private. Ideal for trade journals, strategy dashboards, back-test scorecards and broker reports. Live, nothing stored. 3 compute endpoints. For forward simulation of an edge use a strategy-simulator API; for position sizing use a trading-risk 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/tradestats-api/..."
```

## Pricing
- **Free** (Free) — 4,400 calls/Mo, 2 req/s
- **Starter** ($7/Mo) — 89,000 calls/Mo, 6 req/s
- **Pro** ($19/Mo) — 460,000 calls/Mo, 18 req/s
- **Business** ($44/Mo) — 2,840,000 calls/Mo, 45 req/s

## Endpoints

### Trades

#### `GET /v1/analyze` — Full performance scorecard

**Parameters:**
- `trades` (query, required, string) — Closed-trade P&L, comma-separated (profit +, loss -) Example: `120,-50,80,-30,200,-90,45,-60,150`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/tradestats-api/v1/analyze?trades=120%2C-50%2C80%2C-30%2C200%2C-90%2C45%2C-60%2C150"
```

**Response:**
```json
{
    "data": {
        "note": "Profit factor = gross profit / gross loss. Expectancy = average P&L per trade. Payoff ratio = average win / average loss.",
        "wins": 5,
        "losses": 4,
        "source": "TRADE-STATS",
        "trades": 9,
        "breakeven": 0,
        "total_pnl": 365,
        "expectancy": 40.55555556,
        "gross_loss": -230,
        "average_win": 119,
        "largest_win": 200,
        "average_loss": -57.5,
        "gross_profit": 595,
        "largest_loss": -90,
        "payoff_ratio": 2.069565,
        "win_rate_pct": 55.5556,
        "average_trade": 40.55555556,
        "loss_rate_pct": 44.4444,
        "profit_factor": 2.586957
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:17.252Z",
        "request_id": "2fc8aa87-a091-487b-95dc-2ecf1576215e"
    },
    "status": "ok",
    "message": "Trades analyzed",
    "success": true
}
```

#### `GET /v1/equity` — Equity curve + drawdown

**Parameters:**
- `trades` (query, required, string) — Closed-trade P&L, comma-separated Example: `120,-50,80,-30,200,-90,45,-60,150`
- `starting_balance` (query, optional, string) — Starting balance (default 10000) Example: `10000`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/tradestats-api/v1/equity?trades=120%2C-50%2C80%2C-30%2C200%2C-90%2C45%2C-60%2C150&starting_balance=10000"
```

**Response:**
```json
{
    "data": {
        "note": "Equity curve includes the starting balance as the first point. Max drawdown is the largest peak-to-trough decline.",
        "source": "TRADE-STATS",
        "trades": 9,
        "total_pnl": 365,
        "return_pct": 3.65,
        "equity_curve": [
            10000,
            10120,
            10070,
            10150,
            10120,
            10320,
            10230,
            10275,
            10215,
            10365
        ],
        "max_drawdown": 105,
        "peak_balance": 10365,
        "final_balance": 10365,
        "max_drawdown_pct": 1.017442,
        "starting_balance": 10000
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:17.362Z",
        "request_id": "8e9a8ca2-6b49-4bf5-a733-6dd7381cac52"
    },
    "status": "ok",
    "message": "Equity curve computed",
    "success": true
}
```

#### `GET /v1/streaks` — Longest winning/losing runs + current streak

**Parameters:**
- `trades` (query, required, string) — Closed-trade P&L, comma-separated Example: `120,-50,80,-30,200,-90,45,-60,150`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/tradestats-api/v1/streaks?trades=120%2C-50%2C80%2C-30%2C200%2C-90%2C45%2C-60%2C150"
```

**Response:**
```json
{
    "data": {
        "note": "A streak is a run of consecutive wins or losses; a breakeven trade (0) resets the streak.",
        "source": "TRADE-STATS",
        "trades": 9,
        "losing_runs": 4,
        "winning_runs": 5,
        "current_streak": {
            "type": "winning",
            "length": 1
        },
        "longest_win_streak": 1,
        "longest_loss_streak": 1
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:17.473Z",
        "request_id": "5f55e9a9-c8bf-46f1-b5b1-eb530d697076"
    },
    "status": "ok",
    "message": "Streaks computed",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "note": "trades = the P&L of each closed trade, comma-separated; profit positive, loss negative (trades=120,-50,80,-30,...). starting_balance optional for the equity endpoint.",
        "source": "Computed in-process from caller-supplied trade P&L results (no upstream)",
        "service": "tradestats-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/equity": "Equity curve + drawdown (trades=...&starting_balance=10000).",
            "GET /v1/analyze": "Full performance scorecard (trades=120,-50,80,-30,200,-90,45,-60,150).",
            "GET /v1/streaks": "Longest winning/losing runs and current streak (trades=...)."
        },
        "description": "Live trading-performance analytics computed on demand from a list of realised trade results. The analyze endpoint returns the full scorecard (win rate, profit factor, expectancy, average win/loss, payoff ratio, largest win/loss); the equity endpoint builds the equity curve from a starting balance with running balance, drawdown series, max drawdown and total return; the streaks endpoint returns the longest winning and losing runs and the current streak. A backward-looking trade-journal analyzer that scores actual results, distinct from forward Monte-Carlo simulators and position sizers. Computed locally, nothing stored.",
        "upstream_status": "ok"
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:17.549Z",
        "request_id": "a455431c-2c8d-49
…(truncated, see openapi.json for full schema)
```


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