binance.account.openOrders
Retrieve current open orders for a specific trading symbol on Binance to monitor active positions and manage trades.
Instructions
List open orders for a symbol.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes |
Implementation Reference
- src/tools/account.ts:24-37 (handler)The tool handler function that validates input with Zod, calls the Binance client's openOrders method with the symbol and common params, returns the data, and handles errors by converting to ToolError.export const tool_open_orders: BinanceTool = { name: "binance.account.openOrders", description: "List open orders for a symbol.", parameters: openOrdersSchema, async run(input) { const params = openOrdersSchema.parse(input); try { const res = await binance.openOrders(params.symbol, withCommonParams({})); return res.data; } catch (err) { throw toToolError(err); } } };
- src/tools/account.ts:7-7 (schema)Zod schema defining the input parameters for the tool: requires a 'symbol' string.const openOrdersSchema = z.object({ symbol: z.string().min(1) });
- src/index.ts:14-39 (registration)Registers the tool_open_orders (imported earlier) by including it in the tools array and using FastMCP's addTool method in a loop, which sets up the execute handler forwarding to the tool's run method.const tools = [ tool_market_price, tool_market_klines, tool_exchange_info, tool_account_balances, tool_open_orders, tool_place_order, tool_cancel_order, ]; tools.forEach((tool) => { server.addTool({ name: tool.name, description: tool.description, parameters: tool.parameters, execute: async (args) => { try { const result = await tool.run(args); return JSON.stringify(result, null, 2); } catch (error) { const handled = error instanceof ToolError ? error : new ToolError((error as Error).message); throw handled; } }, }); });
- src/binance/client.ts:14-14 (helper)Creates and exports the Binance Spot client instance used by the tool handler to call openOrders.export const binance = new Spot(apiKey, apiSecret, { baseURL });
- src/binance/client.ts:16-18 (helper)Helper function to add common parameters like recvWindow to API calls.export function withCommonParams<T extends Record<string, unknown>>(params: T) { return { ...params, recvWindow }; }