close_position
Closes an open position fully or partially (fraction (0,1]). Works for crypto and FOREX/MT5. This is a RISK-REDUCING operation: the policy wall NEVER blocks this tool (except the kill switch). idempotency_key is REQUIRED: even 10 calls with the same key perform ONE close. If no position exists, POSITION_NOT_FOUND is returned together with the open positions on that venue.
MT5 positions can only be closed IN FULL (no partial close) -> use fraction=1. If several
MT5 positions are open on the same symbol, `ticket` becomes REQUIRED; while it is
ambiguous, none are closed.
get_portfolio_context shows the open positions (and MT5 tickets).Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"venue": "<venue>",
"symbol": "<symbol>",
"side": "<side>",
"idempotency_key": "<idempotency_key>"
},
"name": "close_position"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| side | Yes | 'buy' (long) or 'sell' (short). The side the user stated. | |
| venue | Yes | Exchange/venue name — must be one of the user's CONNECTED accounts (e.g. binance, bybit, okx, mt5, paper). A venue that is not connected is rejected with VENUE_NOT_CONNECTED. | |
| symbol | Yes | Trading symbol, e.g. BTCUSDT, ETHUSDT, EURUSD. | |
| ticket | No | FOREX/MT5 only: the ticket number of the position this action targets (the 'ticket' field on forex positions in get_portfolio_context). REQUIRED when several positions are open on the same symbol — if which one is meant is not certain, nothing is done. May be left empty when there is only one position. | |
| account | No | TARGET ACCOUNT — the account this call acts on (for place_order/simulate_order the account the order is opened in; for close/modify the account holding the position). For MT5 the login number (e.g. '12345678'), for exchanges the account label (e.g. 'Binance2'). Copy it EXACTLY from the 'account' field in the get_portfolio_context output. REQUIRED when the user has more than one account in the same market: if left empty the action is NOT performed and the user is asked which account — it is never silently applied to the default/primary account. | |
| fraction | No | Close fraction (0,1]. 1.0 = full close, 0.5 = half. MT5 positions can only be closed in full — use 1.0 there; a partial close on MT5 is refused rather than silently converted to a full close. | |
| idempotency_key | Yes | Client-generated unique idempotency key (min 8 characters). Reuse the SAME key when retrying the same action — the stored response is replayed and the action is NOT performed a second time. |