# OlaXBT Trading Challenge

## Briefing: Turn Your Strategy into an MCP Tool

Everything runs at **https://olaxbt.xyz** — the web app, the API, and the MCP gateway all live under a single domain.

### Service Overview

| Component   | URL                                     | Purpose                                     |
| ----------- | --------------------------------------- | ------------------------------------------- |
| Web app     | `https://olaxbt.xyz/app/`               | Strategy builder, backtesting, and API keys |
| MCP gateway | `https://olaxbt.xyz/api/mcp/tools/call` | Endpoint for all MCP tool calls             |
| MCP docs    | `https://olaxbt.xyz/api/mcp/docs`       | Interactive tool reference                  |

### Step-by-Step Guide

**1. Register on the web app.** Use the invite code `HACKATHON2026` at signup (or redeem it later). This upgrades your account tier and waives all credit charges.

**2. Build a strategy.** Navigate to the Strategy Builder. Select your trading desks, set weights (must sum to 100%), and choose between Deterministic (math-only) or Agentic LLM mode. For optimal speed, enable LLM on only 1–2 desks. Each strategy will generate a unique `str_id` (e.g., `str_a1b2c3d4e5f6`).

**3. Run a backtest.** Click "Run Backtest" in the builder. A progress bar will show real-time, step-by-step updates along with trade counts and equity metrics. A 30-bar test takes approximately 5 minutes with the LLM enabled.

**4. Generate an MCP key.** Go to Settings → API Keys → Create Key. Select your strategy from the dropdown menu. Copy the `nxk_` secret — it is only displayed once. Behind the scenes, this key is securely bound to your strategy's ID, automatically routing all associated MCP calls to your strategy's data.

**5. Call MCP tools.** Include your key in the `X-API-KEY` header. Every request is automatically scoped to your strategy, eliminating the need to pass a strategy ID manually:

```bash
# Get backtest metrics
curl -X POST https://olaxbt.xyz/api/mcp/tools/call \
  -H "Content-Type: application/json" \
  -H "X-API-KEY: nxk_YOUR_KEY" \
  -d '{"name": "get_strategy_metrics", "arguments": {}}'

# Get live trading signal
curl -X POST https://olaxbt.xyz/api/mcp/tools/call \
  -H "Content-Type: application/json" \
  -H "X-API-KEY: nxk_YOUR_KEY" \
  -d '{"name": "get_strategy_signal", "arguments": {"symbol": "BTC/USDT"}}'

# Start a new backtest
curl -X POST https://olaxbt.xyz/api/mcp/tools/call \
  -H "Content-Type: application/json" \
  -H "X-API-KEY: nxk_YOUR_KEY" \
  -d '{"name": "run_backtest", "arguments": {"n_bars": 30}}'

# Poll until complete
curl -X POST https://olaxbt.xyz/api/mcp/tools/call \
  -H "Content-Type: application/json" \
  -H "X-API-KEY: nxk_YOUR_KEY" \
  -d '{"name": "get_backtest_job", "arguments": {"run_id": "bt-..."}}'
```

### How MCP Binds to Your Strategy

The `nxk_` key is bound to your strategy's unique ID. When you call any MCP tool, the gateway:

1. Reads the `X-API-KEY` header to identify the associated strategy.
2. Routes the request to that strategy's cached data (metrics, trades, equity, and signals).
3. Replays the last backtest's deploy JSON config when running a new backtest.

This means one key = one strategy If you build multiple strategies, you must generate a separate key for each.

### Available MCP Tools

| Tool                   | Returns                                                                              |
| ---------------------- | ------------------------------------------------------------------------------------ |
| `get_strategy_metrics` | Sharpe ratio, return %, win rate, profit factor, max drawdown, and trade count       |
| `get_strategy_trades`  | Detailed execution per fill: entry/exit price, PnL, exit reason, and holding bars    |
| `get_strategy_equity`  | Equity curve data points (ranging from 30–120 points)                                |
| `get_strategy_signal`  | Live BUY/SELL/HOLD signal with confidence levels and reasoning logs                  |
| `run_backtest`         | Initiates an asynchronous backtest (utilizing your last Studio deploy configuration) |
| `get_backtest_job`     | Polls progress via a specific `run_id`                                               |

**Authentication Note:** Authorization requires the `X-API-KEY: nxk_...` header. Requests without a valid key will return an `HTTP 401` error. If you update your strategy configuration in the builder, please run a new Studio backtest — MCP will automatically pick up the new configuration on the next call.
