cancel_order
Cancel an open trading order by its ID to manage positions and prevent unwanted executions.
Instructions
Cancel an open order by its ID.
Args: order_id: ID of the order to cancel
Returns: Confirmation of cancellation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| order_id | Yes |
Implementation Reference
- src/server.py:505-521 (handler)The main handler function for the 'cancel_order' tool. Decorated with @mcp.tool() which registers it in the MCP server. Takes order_id as input, calls trading_client.cancel_order_by_id() to perform the cancellation, and returns a success or error message.@mcp.tool() def cancel_order(order_id: str) -> str: """ Cancel an open order by its ID. Args: order_id: ID of the order to cancel Returns: Confirmation of cancellation """ try: trading_client.cancel_order_by_id(order_id) return f"Order {order_id} has been successfully canceled." except Exception as e: return f"Error canceling order {order_id}: {str(e)}"