# Trade Setup & R:R Planner API
> Live trade-planning analytics built on the geometry of a setup, the numbers a trader checks before pulling the trigger, computed on demand from the entry, stop and target you pass in — no key, no cache, nothing stored. The plan endpoint turns an entry, stop-loss and target into the risk and reward per unit, the reward-to-risk ratio and the break-even win rate — the minimum win rate that makes the trade profitable — and, if you supply an account size and a risk percent, the position size, risk amount and reward amount. The targets endpoint projects target prices at chosen R-multiples of the stop distance, so you can ladder out at 1R, 2R and 3R. The expectancy endpoint turns a reward-to-risk ratio and a win rate into the expected value per trade in R and the profit factor, telling you whether an edge is positive. This is a trade-geometry planner, fundamentally different from account-based position sizers, forward Monte-Carlo simulators and backward trade-journal analyzers: it reasons from the entry, stop and target. Works for any market — forex, stocks, crypto or futures — and for long or short. Computed locally and deterministically, so it is instant and private. Ideal for trade journals, risk checklists, broker tools and trading dashboards. Live, nothing stored. 3 compute endpoints. For Kelly position sizing use a trading-risk API; for a full outcome distribution use a strategy simulator.

## 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/tradesetup-api/..."
```

## Pricing
- **Free** (Free) — 4,450 calls/Mo, 2 req/s
- **Starter** ($7/Mo) — 89,500 calls/Mo, 6 req/s
- **Pro** ($21/Mo) — 462,000 calls/Mo, 18 req/s
- **Business** ($48/Mo) — 2,860,000 calls/Mo, 45 req/s

## Endpoints

### Setup

#### `GET /v1/expectancy` — Expected value & profit factor

**Parameters:**
- `reward_risk_ratio` (query, optional, string) — Reward-to-risk ratio Example: `3`
- `win_rate` (query, required, string) — Win rate (fraction or percent) Example: `40`
- `entry` (query, optional, string) — Entry (alternative to RR) Example: `100`
- `stop` (query, optional, string) — Stop (alternative to RR) Example: `98`
- `target` (query, optional, string) — Target (alternative to RR) Example: `106`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/tradesetup-api/v1/expectancy?reward_risk_ratio=3&win_rate=40&entry=100&stop=98&target=106"
```

**Response:**
```json
{
    "data": {
        "edge": "positive",
        "note": "Expectancy in R = win_rate x RR - (1 - win_rate). Above the break-even win rate the edge is positive.",
        "source": "TRADE-SETUP",
        "expectancy_r": 0.6,
        "win_rate_pct": 40,
        "profit_factor": 2,
        "reward_risk_ratio": 3,
        "breakeven_win_rate_pct": 25,
        "expectancy_pct_of_risk": 60
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:06.925Z",
        "request_id": "9f89b72f-f43f-44f9-84bd-af91da181e48"
    },
    "status": "ok",
    "message": "Expectancy computed",
    "success": true
}
```

#### `GET /v1/plan` — Risk/reward, RR ratio, break-even + position size

**Parameters:**
- `entry` (query, required, string) — Entry price Example: `100`
- `stop` (query, required, string) — Stop-loss price Example: `98`
- `target` (query, required, string) — Target price Example: `106`
- `side` (query, optional, string) — long or short (default long) Example: `long`
- `account` (query, optional, string) — Account size for position sizing Example: `10000`
- `risk_pct` (query, optional, string) — Risk percent of account (e.g. 1 = 1%) Example: `1`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/tradesetup-api/v1/plan?entry=100&stop=98&target=106&side=long&account=10000&risk_pct=1"
```

**Response:**
```json
{
    "data": {
        "note": "reward_risk_ratio = reward / risk; break-even win rate = 1 / (1 + RR). Give account & risk_pct for position sizing.",
        "side": "long",
        "stop": 98,
        "entry": 100,
        "source": "TRADE-SETUP",
        "target": 106,
        "account": 10000,
        "risk_pct": 1,
        "risk_amount": 100,
        "position_size": 50,
        "reward_amount": 300,
        "risk_per_unit": 2,
        "reward_per_unit": 6,
        "reward_risk_ratio": 3,
        "risk_pct_from_entry": 2,
        "reward_pct_from_entry": 6,
        "breakeven_win_rate_pct": 25
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:07.024Z",
        "request_id": "c46c324d-4a64-48c9-a955-f3d7527b3fd2"
    },
    "status": "ok",
    "message": "Trade plan computed",
    "success": true
}
```

#### `GET /v1/targets` — Target prices at R-multiples of the stop

**Parameters:**
- `entry` (query, required, string) — Entry price Example: `100`
- `stop` (query, required, string) — Stop-loss price Example: `98`
- `side` (query, optional, string) — long or short (default long) Example: `long`
- `r_multiples` (query, optional, string) — R-multiples, comma-separated Example: `1,2,3`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/tradesetup-api/v1/targets?entry=100&stop=98&side=long&r_multiples=1%2C2%2C3"
```

**Response:**
```json
{
    "data": {
        "note": "Target at R = entry +/- R x risk (per side). Each R-multiple is one unit of the stop distance.",
        "side": "long",
        "stop": 98,
        "entry": 100,
        "source": "TRADE-SETUP",
        "targets": [
            {
                "r_multiple": 1,
                "target_price": 102,
                "reward_per_unit": 2,
                "gain_pct_from_entry": 2
            },
            {
                "r_multiple": 2,
                "target_price": 104,
                "reward_per_unit": 4,
                "gain_pct_from_entry": 4
            },
            {
                "r_multiple": 3,
                "target_price": 106,
                "reward_per_unit": 6,
                "gain_pct_from_entry": 6
            }
        ],
        "risk_per_unit": 2
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:07.099Z",
        "request_id": "f3a9cd32-54c8-41f5-b851-c8957585cbba"
    },
    "status": "ok",
    "message": "Targets computed",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "note": "entry, stop and target are prices; side is long or short. account & risk_pct optional for sizing; win_rate accepts a fraction or percent.",
        "source": "Computed in-process from caller-supplied entry/stop/target prices (no upstream)",
        "service": "tradesetup-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/plan": "Risk/reward, RR ratio, break-even win rate + position size (entry=100&stop=98&target=106&side=long&account=10000&risk_pct=1).",
            "GET /v1/targets": "Target prices at R-multiples of the stop (entry=100&stop=98&side=long&r_multiples=1,2,3).",
            "GET /v1/expectancy": "Expected value & profit factor (reward_risk_ratio=3&win_rate=40, or entry/stop/target+win_rate)."
        },
        "description": "Live trade-planning analytics built on the geometry of a setup. The plan endpoint turns an entry, stop and target into risk/reward per unit, the reward-to-risk ratio and the break-even win rate, plus position sizing from an account and risk percent; the targets endpoint projects target prices at chosen R-multiples; the expectancy endpoint turns a reward-to-risk ratio and win rate into expected value per trade and profit factor. A trade-geometry planner, distinct from account-based position sizers, forward simulators and backward trade analyzers. Computed locally, nothing stored.",
        "upstream_status": "ok"
    },
    "meta": {
        "timestamp": "2026-06-
…(truncated, see openapi.json for full schema)
```


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