get_order_history
Retrieve past order records for a specific trading pair on Binance to analyze trading history and performance.
Instructions
获取历史订单记录
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | 数量限制,默认500 | |
| symbol | Yes | 交易对符号,如 BTCUSDT |
Implementation Reference
- src/tools/account.ts:125-163 (handler)Executes the get_order_history tool by validating input, calling binanceClient.allOrders, mapping the order data, and handling errors.handler: async (binanceClient: any, args: unknown) => { const input = validateInput(GetOrderHistorySchema, args); validateSymbol(input.symbol); try { const orderHistory = await binanceClient.allOrders({ symbol: input.symbol, limit: input.limit, }); return { symbol: input.symbol, orders: orderHistory.map((order: any) => ({ symbol: order.symbol, orderId: order.orderId, orderListId: order.orderListId, clientOrderId: order.clientOrderId, price: order.price, origQty: order.origQty, executedQty: order.executedQty, cummulativeQuoteQty: order.cummulativeQuoteQty, status: order.status, timeInForce: order.timeInForce, type: order.type, side: order.side, stopPrice: order.stopPrice, icebergQty: order.icebergQty, time: order.time, updateTime: order.updateTime, isWorking: order.isWorking, origQuoteOrderQty: order.origQuoteOrderQty, })), count: orderHistory.length, timestamp: Date.now(), }; } catch (error) { handleBinanceError(error); } },
- src/types/mcp.ts:28-31 (schema)Zod schema defining the input parameters for the get_order_history tool: symbol (required string) and optional limit (number, default 500).export const GetOrderHistorySchema = z.object({ symbol: z.string().describe('交易对符号'), limit: z.number().optional().default(500).describe('数量限制,默认500'), });
- src/tools/account.ts:107-164 (registration)Registers the get_order_history tool as part of the accountTools array, including name, description, inputSchema (mirroring the Zod schema), and reference to the handler function.{ name: 'get_order_history', description: '获取历史订单记录', inputSchema: { type: 'object', properties: { symbol: { type: 'string', description: '交易对符号,如 BTCUSDT', }, limit: { type: 'number', description: '数量限制,默认500', default: 500, }, }, required: ['symbol'], }, handler: async (binanceClient: any, args: unknown) => { const input = validateInput(GetOrderHistorySchema, args); validateSymbol(input.symbol); try { const orderHistory = await binanceClient.allOrders({ symbol: input.symbol, limit: input.limit, }); return { symbol: input.symbol, orders: orderHistory.map((order: any) => ({ symbol: order.symbol, orderId: order.orderId, orderListId: order.orderListId, clientOrderId: order.clientOrderId, price: order.price, origQty: order.origQty, executedQty: order.executedQty, cummulativeQuoteQty: order.cummulativeQuoteQty, status: order.status, timeInForce: order.timeInForce, type: order.type, side: order.side, stopPrice: order.stopPrice, icebergQty: order.icebergQty, time: order.time, updateTime: order.updateTime, isWorking: order.isWorking, origQuoteOrderQty: order.origQuoteOrderQty, })), count: orderHistory.length, timestamp: Date.now(), }; } catch (error) { handleBinanceError(error); } }, },