cancel_all_orders
Cancel all active trading orders for a specific symbol or product category on Bybit. Use this tool to clear pending orders and manage your trading positions effectively.
Instructions
Cancel all orders for a symbol or category (⚠️ WARNING: Affects real orders on mainnet)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | Yes | Product type | |
| symbol | No | Trading symbol (optional, if not provided cancels all orders in category) |
Implementation Reference
- src/server.ts:129-134 (handler)Dispatches the 'cancel_all_orders' tool call to the BybitClient's cancelAllOrders method with category and optional symbol arguments.case 'cancel_all_orders': result = await this.client.cancelAllOrders( args.category as string, args.symbol as string ); break;
- src/tools.ts:105-123 (registration)Registers the 'cancel_all_orders' tool including its name, description, and input schema definition.{ name: 'cancel_all_orders', description: 'Cancel all orders for a symbol or category (⚠️ WARNING: Affects real orders on mainnet)', inputSchema: { type: 'object', properties: { category: { type: 'string', enum: ['spot', 'linear', 'inverse', 'option'], description: 'Product type' }, symbol: { type: 'string', description: 'Trading symbol (optional, if not provided cancels all orders in category)' } }, required: ['category'] } }
- src/client.ts:170-184 (helper)Implements the core logic for canceling all orders by calling the Bybit API's cancelAllOrders endpoint, with mainnet warning.async cancelAllOrders(category: string, symbol?: string) { try { if (this.config.environment === 'mainnet') { console.error('⚠️ WARNING: Canceling ALL orders on MAINNET!'); } const response = await this.client.cancelAllOrders({ category: category as any, symbol: symbol }); return response; } catch (error) { throw new Error(`Failed to cancel all orders: ${error instanceof Error ? error.message : JSON.stringify(error)}`); } }