cancel_order
Cancel active trading orders on Bybit exchange by specifying category and symbol. Use order ID or link ID to remove specific pending positions from spot, linear, or inverse markets.
Instructions
Cancel order
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | Yes | Category (spot, linear, inverse, etc.) | |
| symbol | Yes | Symbol (e.g., BTCUSDT) | |
| orderId | No | Order ID | |
| orderLinkId | No | Order link ID | |
| orderFilter | No | Order filter |
Implementation Reference
- src/bybit-service.ts:330-342 (handler)Core handler function that executes the cancel order logic by building API parameters and calling the Bybit /v5/order/cancel endpoint.async cancelOrder( category: string, symbol: string, orderId?: string, orderLinkId?: string, orderFilter?: string ): Promise<BybitResponse<any> | { error: string }> { const params: any = { category, symbol }; if (orderId) params.orderId = orderId; if (orderLinkId) params.orderLinkId = orderLinkId; if (orderFilter) params.orderFilter = orderFilter; return this.makeBybitRequest('/v5/order/cancel', 'POST', params); }
- src/index.ts:273-302 (schema)Defines the tool schema including name, description, and input validation schema for the cancel_order tool.{ name: 'cancel_order', description: 'Cancel order', inputSchema: { type: 'object', properties: { category: { type: 'string', description: 'Category (spot, linear, inverse, etc.)', }, symbol: { type: 'string', description: 'Symbol (e.g., BTCUSDT)', }, orderId: { type: 'string', description: 'Order ID', }, orderLinkId: { type: 'string', description: 'Order link ID', }, orderFilter: { type: 'string', description: 'Order filter', }, }, required: ['category', 'symbol'], }, },
- src/index.ts:830-846 (handler)MCP request handler case that dispatches cancel_order tool calls to the BybitService.cancelOrder method and formats the response.case 'cancel_order': { const result = await this.bybitService.cancelOrder( typedArgs.category, typedArgs.symbol, typedArgs.orderId, typedArgs.orderLinkId, typedArgs.orderFilter ); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/index.ts:691-692 (registration)Registers all tools including cancel_order with the MCP server using setTools.], }));