# Strategy Simulator API
> Live Monte-Carlo simulation of a trading strategy's outcome that traders run to judge an edge — computed on demand and reproducibly, no key, nothing cached. Run a sequence of trades many times from a win rate, reward-to-risk payoff and risk-per-trade, and get the distribution of final equity, the probability of profit, the probability of ruin and the drawdown distribution; get the modelled chance of blowing up the account; or get the analytical edge — expectancy per trade, breakeven win rate and profit factor. Every run is seeded, so the same inputs always give the same numbers. A strategy-outcome engine, distinct from position-sizing tools and price simulators: it turns an edge into the equity, drawdown and ruin a strategy faces.

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

## Pricing
- **Free** (Free) — 4,700 calls/Mo, 3 req/s
- **Starter** ($7/Mo) — 105,000 calls/Mo, 10 req/s
- **Pro** ($19/Mo) — 512,000 calls/Mo, 25 req/s
- **Business** ($45/Mo) — 3,140,000 calls/Mo, 55 req/s

## Endpoints

### Strategy Sim

#### `GET /v1/expectancy` — Analytical edge — expectancy, breakeven, profit factor

**Parameters:**
- `win_rate` (query, required, string) — Win probability 0-1 Example: `0.55`
- `payoff` (query, required, string) — Reward-to-risk ratio Example: `1.5`
- `risk_pct` (query, optional, string) — Percent risked per trade (default 2) Example: `2`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/strategysim-api/v1/expectancy?win_rate=0.55&payoff=1.5&risk_pct=2"
```

**Response:**
```json
{
    "data": {
        "note": "Analytical edge per trade. expectancy_R > 0 means a positive edge; breakeven_win_rate is the win rate at which the strategy is flat for this payoff.",
        "inputs": {
            "payoff": 1.5,
            "risk_pct": 2,
            "win_rate": 0.55
        },
        "source": "STRATEGYSIM",
        "has_edge": true,
        "expectancy_R": 0.375,
        "profit_factor": 1.8333,
        "breakeven_win_rate": 0.4,
        "expected_return_per_trade_pct": 0.75
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:31.371Z",
        "request_id": "0c518a35-34a1-4126-8d82-5aacba9b27a7"
    },
    "status": "ok",
    "message": "Expectancy computed",
    "success": true
}
```

#### `GET /v1/meta` — Service metadata and endpoint list

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

**Response:**
```json
{
    "data": {
        "note": "win_rate 0-1, payoff = reward:risk ratio, risk_pct = % of equity risked per trade. Runs are deterministic per seed (default 12345).",
        "source": "Computed in-process (seeded mulberry32 PRNG, fixed-fractional compounding)",
        "service": "strategysim-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/simulate": "Monte-Carlo equity outcome + ruin & drawdown (win_rate=0.55, payoff=1.5, risk_pct=2, trades=100, capital=10000).",
            "GET /v1/expectancy": "Analytical edge — expectancy, breakeven win rate, profit factor (win_rate=0.55, payoff=1.5).",
            "GET /v1/risk-of-ruin": "Modelled probability of ruin (win_rate=0.5, payoff=1, risk_pct=5, trades=100, ruin_drawdown=0.5)."
        },
        "description": "Live Monte-Carlo simulation of a trading strategy's outcome, computed on demand and reproducibly. The simulate endpoint runs a sequence of trades many times from a win rate, reward-to-risk payoff and risk-per-trade, and returns the distribution of final equity, the probability of profit, the probability of ruin and the drawdown distribution; the risk-of-ruin endpoint returns the modelled chance of blowing up the account; the expectancy endpoint returns the analytical edge (expectancy per trade, breakeven win rate, profit factor). Every run is seeded, so the same inputs always give the same numbers. A strategy-outcome engine, distinct from position-sizing tools and price 
…(truncated, see openapi.json for full schema)
```

#### `GET /v1/risk-of-ruin` — Modelled probability of ruin

**Parameters:**
- `win_rate` (query, required, string) — Win probability 0-1 Example: `0.5`
- `payoff` (query, required, string) — Reward-to-risk ratio Example: `1`
- `risk_pct` (query, optional, string) — Percent risked per trade (default 2) Example: `5`
- `trades` (query, optional, string) — Trades (default 100) Example: `100`
- `ruin_drawdown` (query, optional, string) — Drawdown that counts as ruin 0-1 (default 0.5) Example: `0.5`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/strategysim-api/v1/risk-of-ruin?win_rate=0.5&payoff=1&risk_pct=5&trades=100&ruin_drawdown=0.5"
```

**Response:**
```json
{
    "data": {
        "edge": {
            "has_edge": false,
            "expectancy_R": 0,
            "profit_factor": 1,
            "breakeven_win_rate": 0.5,
            "expected_return_per_trade_pct": 0
        },
        "note": "Ruin = the equity ever falls to a 50% drawdown from the starting capital, over 100 trades.",
        "inputs": {
            "runs": 10000,
            "seed": 12345,
            "payoff": 1,
            "trades": 100,
            "risk_pct": 5,
            "win_rate": 0.5,
            "ruin_drawdown": 0.5
        },
        "source": "STRATEGYSIM",
        "probability_of_ruin": 0.2174,
        "probability_of_profit": 0.3732
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:31.600Z",
        "request_id": "fb35d261-1c14-4d6b-a076-eb25eed5d80b"
    },
    "status": "ok",
    "message": "Risk of ruin computed",
    "success": true
}
```

#### `GET /v1/simulate` — Monte-Carlo equity outcome + ruin & drawdown

**Parameters:**
- `win_rate` (query, required, string) — Win probability 0-1 Example: `0.55`
- `payoff` (query, required, string) — Reward-to-risk ratio Example: `1.5`
- `risk_pct` (query, optional, string) — Percent of equity risked per trade (default 2) Example: `2`
- `trades` (query, optional, string) — Trades per run 1-10000 (default 100) Example: `100`
- `capital` (query, optional, string) — Starting capital (default 10000) Example: `10000`
- `runs` (query, optional, string) — Simulations 100-100000 (default 10000) Example: `10000`
- `seed` (query, optional, string) — PRNG seed (default 12345) Example: `12345`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/strategysim-api/v1/simulate?win_rate=0.55&payoff=1.5&risk_pct=2&trades=100&capital=10000&runs=10000&seed=12345"
```

**Response:**
```json
{
    "data": {
        "edge": {
            "has_edge": true,
            "expectancy_R": 0.375,
            "profit_factor": 1.8333,
            "breakeven_win_rate": 0.4,
            "expected_return_per_trade_pct": 0.75
        },
        "inputs": {
            "runs": 10000,
            "seed": 12345,
            "payoff": 1.5,
            "trades": 100,
            "capital": 10000,
            "risk_pct": 2,
            "win_rate": 0.55,
            "ruin_drawdown": 0.5
        },
        "source": "STRATEGYSIM",
        "final_equity": {
            "max": 55391.58,
            "min": 8786.81,
            "mean": 21087.54,
            "median": 20474.85,
            "percentiles": {
                "p5": 13750.91,
                "p25": 17635.48,
                "p50": 20474.85,
                "p75": 23771.37,
                "p95": 30486.67
            }
        },
        "max_drawdown": {
            "median_pct": 11.4158,
            "percentiles": {
                "p5": 6.8962,
                "p25": 9.6079,
                "p50": 11.4158,
                "p75": 14.124,
                "p95": 19.4148
            }
        },
        "mean_return_pct": 110.8754,
        "probability_of_ruin": 0,
        "probability_of_profit": 0.9976
    },
    "meta": {
        "timestamp": "2026-06-11T07:49:31.761Z",
        "request_id": "c5db3217-6bfe-4c4b-8aa2-ece27cce874a"
    },
    "status": "ok",
    "message": "Simulation computed",
    "success": true
}
```


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