binance_trade_cancelOrder
Cancel a spot trading order on Binance by specifying the symbol and order ID to manage open positions or correct errors.
Instructions
Cancel a spot order by symbol and orderId.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | ||
| orderId | Yes |
Implementation Reference
- src/tools/trade.ts:54-68 (handler)The tool handler implementation, which validates input, ensures trading is enabled, calls binance.cancelOrder, and returns the result or throws a tool error.export const tool_cancel_order: BinanceTool = { name: "binance_trade_cancelOrder", description: "Cancel a spot order by symbol and orderId.", parameters: cancelOrderSchema, async run(input) { ensureTradingEnabled(); const params = cancelOrderSchema.parse(input); try { const res = await binance.cancelOrder(params.symbol, withCommonParams({ orderId: params.orderId })); return res.data; } catch (err) { throw toToolError(err); } } };
- src/tools/trade.ts:16-19 (schema)Zod schema for input validation: requires symbol (string) and orderId (positive integer). Used in the tool parameters and parsing.const cancelOrderSchema = z.object({ symbol: z.string().min(1), orderId: z.number().int().positive() });
- src/index.ts:15-23 (registration)The tool is included in the tools array, which is then iterated to register each tool with the FastMCP server via server.addTool.const tools = [ tool_market_price, tool_market_klines, tool_exchange_info, tool_account_balances, tool_open_orders, tool_place_order, tool_cancel_order, ];