Close a position
close_positionClose all or part of an open perpetual position with a reduce-only MARKET order. Reads the current position, flips the side automatically (LONG→SELL, SHORT→BUY) and sizes the close. percent defaults to 100 (full close); a partial close is floored to the market step size. The close is bounded at oracle ± slippageBps mirrored by side (closing a SHORT buys up to oracle×(1+slip), closing a LONG sells down to oracle×(1−slip); default 500 bps = 5%). Returns the verified confirmation outcome — if it is unfilled or partially_filled, the book was thinner than the cap: re-run with a larger slippageBps to sweep deeper. Errors NOT_FOUND if there is no open position in the market.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| market | Yes | Market ticker, e.g. BTC-USD | |
| confirm | No | ||
| percent | No | Portion of the position to close (default 100). | |
| slippageBps | No | Max slippage vs oracle, in bps (default 500). Raise to sweep a thin book. |