cancelOrder
Cancel specific orders on Bitget cryptocurrency exchange by providing the order ID and trading pair symbol, ensuring precise control over spot and futures trading activities.
Instructions
Cancel an existing order
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| orderId | Yes | Order ID to cancel | |
| symbol | Yes | Trading pair symbol |
Implementation Reference
- src/server.ts:400-411 (handler)MCP server tool handler for cancelOrder: validates input with CancelOrderSchema, calls BitgetRestClient.cancelOrder, and returns success/error message.case 'cancelOrder': { const { orderId, symbol } = CancelOrderSchema.parse(args); const success = await this.bitgetClient.cancelOrder(orderId, symbol); return { content: [ { type: 'text', text: success ? `Order ${orderId} cancelled successfully` : `Failed to cancel order ${orderId}`, }, ], } as CallToolResult; }
- src/types/mcp.ts:51-54 (schema)Zod schema for validating cancelOrder tool parameters: orderId and symbol.export const CancelOrderSchema = z.object({ orderId: z.string().describe('Order ID to cancel'), symbol: z.string().describe('Trading pair symbol') });
- src/server.ts:181-192 (registration)Tool registration in listTools handler, defining name, description, and JSON inputSchema for cancelOrder.{ name: 'cancelOrder', description: 'Cancel an existing order', inputSchema: { type: 'object', properties: { orderId: { type: 'string', description: 'Order ID to cancel' }, symbol: { type: 'string', description: 'Trading pair symbol' } }, required: ['orderId', 'symbol'] }, },
- src/api/rest-client.ts:650-656 (helper)Core implementation of cancelOrder in BitgetRestClient: detects spot/futures and delegates to specific cancel methods which make API calls.async cancelOrder(orderId: string, symbol: string): Promise<boolean> { if (this.isFuturesSymbol(symbol)) { return this.cancelFuturesOrder(orderId, symbol); } else { return this.cancelSpotOrder(orderId, symbol); } }