Skip to content

Close All Positions

writes · destructive

Close ALL open positions (or filtered by symbol) with opposing market orders.

Emergency/batch tool to flatten the entire book. Each position is closed sequentially with independent trade lock acquisition. Partial failures do NOT stop the batch.

PARAMETERS:

  • symbol: Optional filter. Provide to close only positions for that symbol. Omit to close ALL.
  • comment: Optional comment attached to each closing order.

BEHAVIOR:

  • Iterates all matching positions and sends an opposing MARKET IOC order for each
  • Each close goes through independent risk checks
  • Partial failures are reported but do not abort remaining closes
  • Returns detailed per-position results

MODES:

  • readonly: Rejected
  • paper: Simulated, not sent to broker
  • live: Real execution

This flattens multiple positions at once — confirm the scope (all positions, or the symbol filter) with the user once before calling. The server enforces all risk checks on each close.

ParameterTypeRequiredDescription
symbolstringNoOptional symbol filter. Omit to close ALL open positions.
commentstringNoOptional comment attached to each closing order