Close all agent-wallet positions
close_all_positionsClose EVERY open perp position in YOUR agent wallet (requires the api:trade scope). REAL MONEY, in two calls. 1) Call with no arguments: nothing is closed; the answer lists the open positions (symbol, side, size, entry price, unrealized PnL) and confirm_echo.positions. Present that list to the human user. 2) Only after their explicit approval, call again with positions set to confirm_echo.positions exactly as returned. The server re-reads the live positions and refuses with 409 positions_changed unless they still match (then preview again); otherwise, for each position, it cancels that symbol's TP/SL orders and places a REDUCE-ONLY market close, which can only close, never open or flip. NEVER make the second call autonomously or chain it after the first. The answer lists each close with its own success in data.closed; if any close fails the call returns an error that names, per position, whether it closed — tell the user which positions are still open. Only the agent wallet is touched, never the main wallet.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| positions | No | ONLY on the confirming call: confirm_echo.positions from the preview, unchanged |