cancel_order
Cancel open orders on Bybit exchange by specifying the category, symbol, and order details. Use this tool to manage trades efficiently and maintain control over active positions.
Instructions
Cancel order
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | Yes | Category (spot, linear, inverse, etc.) | |
| orderFilter | No | Order filter | |
| orderId | No | Order ID | |
| orderLinkId | No | Order link ID | |
| symbol | Yes | Symbol (e.g., BTCUSDT) |
Implementation Reference
- src/bybit-service.ts:330-342 (handler)The core handler function that constructs the cancel order parameters and makes a POST request to Bybit's /v5/order/cancel API 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:274-302 (schema)JSON schema defining the input parameters and validation 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 (registration)MCP tool request handler switch case that dispatches cancel_order requests 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), }, ], }; }