Skip to main content
Glama
ethancod1ng

Binance MCP Server

by ethancod1ng

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
NameRequiredDescriptionDefault
limitNo数量限制,默认500
symbolYes交易对符号,如 BTCUSDT

Implementation Reference

  • 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);
      }
    },
  • 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'),
    });
  • 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);
        }
      },
    },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ethancod1ng/binance-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server