binance.trade.cancelOrder
Cancel a spot order on Binance by specifying the trading symbol and order ID to manage your trades effectively.
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:58-67 (handler)The handler function for the binance.trade.cancelOrder tool. Parses input, ensures trading is enabled, calls the binance client to cancel the order, and handles errors.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 defining the input parameters for the cancelOrder tool: symbol (string) and orderId (positive integer).const cancelOrderSchema = z.object({ symbol: z.string().min(1), orderId: z.number().int().positive() });
- src/index.ts:14-22 (registration)The tool_cancel_order is included in the tools array, which is then iterated to register each tool with the FastMCP server using its name, description, parameters, and wrapped execute function calling tool.run.const tools = [ tool_market_price, tool_market_klines, tool_exchange_info, tool_account_balances, tool_open_orders, tool_place_order, tool_cancel_order, ];