Skip to content

Close Position

writes · destructive

Close an open trading position (full or partial close).

Submits an opposing market order to close a position. The opposite side is automatically inferred from the position (do NOT specify side parameter).

PARAMETERS:

  • positionId: Position ID from get_positions response (required)
  • volume: Optional partial close volume in units
    • Omit to close entire position
    • Provide to close partial (e.g., close half of a 100000 unit position with volume=50000)
    • Must not exceed current position volume
  • comment: Optional comment/label for the closing order

BEHAVIOR:

  • If position is LONG (BUY), submits a SELL market order
  • If position is SHORT (SELL), submits a BUY market order
  • Side is inferred automatically - do NOT ask LLM for side
  • Market order executes immediately at best available price
  • Risk checks apply (rate limits, kill switch, etc.)

FULL vs PARTIAL CLOSE:

  • Full close: Omit volume parameter, entire position is closed
  • Partial close: Provide volume < position volume, remaining position stays open

Returns execution details with realized P&L on success.

For a partial close, volume is in UNITS and must be ≤ the position volume — show it to the user and confirm once. The server enforces all risk checks; one confirmation is sufficient.

ParameterTypeRequiredDescription
positionIdstringYesPosition ID to close (from get_positions response)
volumenumberNoOptional partial close volume in UNITS. Omit to close entire position. Must not exceed position volume. Fractional values allowed for instruments with small lot sizes.
commentstringNoOptional comment for the closing order