binance.market.klines
Retrieve historical candlestick data for cryptocurrency pairs to analyze market trends and price movements over specified time intervals.
Instructions
Get historical klines/candles for a symbol and interval.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | ||
| interval | Yes | ||
| limit | No |
Implementation Reference
- src/tools/market.ts:29-42 (handler)The handler implementation for the 'binance.market.klines' tool. It defines the tool object with name, description, parameters schema, and the async run function that validates input, fetches klines data via the binance client, and handles errors.export const tool_market_klines: BinanceTool = { name: "binance.market.klines", description: "Get historical klines/candles for a symbol and interval.", parameters: klinesSchema, async run(input) { const params = klinesSchema.parse(input); try { const res = await binance.klines(params.symbol, params.interval, { limit: params.limit }); return res.data; } catch (err) { throw toToolError(err); } } };
- src/tools/market.ts:7-11 (schema)Zod schema defining the input parameters for the klines tool: symbol (string), interval (string), limit (number, 1-1000, default 200).const klinesSchema = z.object({ symbol: z.string().min(1), interval: z.string().min(1), limit: z.number().int().min(1).max(1000).default(200) });
- src/index.ts:14-22 (registration)The tool is imported from './tools/market.js' (line 2) and included in the 'tools' array, which is then iterated over to register each tool with the FastMCP server using server.addTool (lines 24-39). This is the registration point.const tools = [ tool_market_price, tool_market_klines, tool_exchange_info, tool_account_balances, tool_open_orders, tool_place_order, tool_cancel_order, ];