---
name: openprop-trading
description: Trade one OpenProp account (evaluation, funded or free practice) through the OpenProp MCP tools or REST API, inside the account rules.
---

# OpenProp — how to trade an account for your user

You act for ONE OpenProp account, reached with the user's API key (`opk_...`). The key decides which account and what you may do:
`read` = look only; `trade` = place, cancel and close orders. No key can withdraw, request a payout or change an address. Do not try.

## The rules (same as the web terminal)

- **Floor.** If equity reaches the floor (account size − 3% on the standard Tight level; call `get_evaluation` for this account's own max loss), the account ends. This is the only loss rule: no daily loss limit, no time limit.
- **Target.** An evaluation passes when equity reaches size + 9%. Funded accounts have no target.
- **Position cap.** Long + short notional on one market is capped (5 × account size on BTC). Reducing or closing is always allowed.
- **Hedge mode.** `buy` opens or adds to the long (`BTC:long`), `sell` opens or adds to the short (`BTC:short`). They do not net. To exit, close the position.
- **Costs.** 3.3 bps per side. Market orders fill on the real Lighter order book after ~300 ms, with slippage.
- **Minimums.** BTC 0.00007 and $10 notional.

## Before every order

1. Call `get_rules_status` (REST `GET /v1/rules_status`). Read `remaining_loss_before_floor` and `available_notional_usd`.
2. Size the trade so that its stop loss cannot take more than the user's agreed share of `remaining_loss_before_floor`. Without an agreed number, use at most 25%.
3. Put a `stop_loss` on every opening order unless the user says otherwise.
4. Above 50% of the room left under the cap, ask the user first, then send with `confirm_size: true`.
5. Send a `client_order_id` you generate. If the call times out, retry with the SAME id: it will never create a second order.

## After every order

Tell the user, in one or two lines: what filled (size, average price, fees), the open positions, and the **remaining loss before the floor**.

## Tools (MCP) / endpoints (REST, base `https://<server>/pf-api`, header `Authorization: Bearer opk_...`)

| MCP tool | REST | Use |
|---|---|---|
| get_account | GET /v1/account | size, equity, net P&L, floor, target |
| get_rules_status | GET /v1/rules_status | remaining loss, room under the cap |
| get_evaluation | GET /v1/evaluation | the rules this account was bought with (risk level, max loss, target, split, price paid). Read it first: they override the defaults above |
| get_pricing | GET /v1/pricing | today's evaluation prices, read-only |
| get_positions | GET /v1/positions + /v1/orders | open positions and orders |
| get_markets | GET /v1/markets | markets, last price, decimals, minimums |
| get_history | GET /v1/history | last 50 fills and events |
| place_order | POST /v1/orders | market / limit / stop / stop_limit, size_usd or size, take_profit, stop_loss |
| close_position | POST /v1/positions/close | `{"position":"BTC:long"}` or `{"market":"all"}` |
| cancel_order | POST /v1/orders/cancel | `{"order_id":"12"}` or `{"order_id":"all"}` |
| set_tpsl | POST /v1/positions/tpsl | set or clear TP/SL on a position |
| — | GET /v1/events?since=&wait= | fills and events after a cursor; keep `cursor` to resume |

Errors are JSON: `{"error": "...", "code": "..."}`. `rejected` means the engine refused (read the message, do not retry blindly). `rate_limited` means slow down (5 requests/s, 2 orders/s).

## Never

- Never move equity to the floor "to see". Never double down to recover a loss without the user's go.
- Never claim a trade happened without a fill in the answer.
- Never print or store the API key in a chat, file or log.

## Errors

Every error has `error`, `code` and often `hint`: one sentence on what to do. Show the hint to the user. On `engine_timeout`, read orders before resending. Never retry `rejected` with the same order.
