Skip to main content
Glama

get-ohlcv

Fetch OHLCV candlestick data for trading pairs from cryptocurrency exchanges using exchange ID, symbol, timeframe, and limit parameters.

Instructions

Get OHLCV candlestick data for a trading pair

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exchangeYesExchange ID (e.g., binance, coinbase)
limitNoNumber of candles to fetch (max 1000)
symbolYesTrading pair symbol (e.g., BTC/USDT)
timeframeNoTimeframe (e.g., 1m, 5m, 1h, 1d)1d

Implementation Reference

  • The handler function for the 'get-ohlcv' tool. It uses rate limiting and caching to fetch OHLCV candlestick data from the specified exchange using the exchange instance's fetchOHLCV method and returns the data as JSON.
    }, async ({ exchange, symbol, timeframe, limit }) => {
      try {
        return await rateLimiter.execute(exchange, async () => {
          const ex = getExchange(exchange);
          const cacheKey = `ohlcv:${exchange}:${symbol}:${timeframe}:${limit}`;
          
          const ohlcv = await getCachedData(cacheKey, async () => {
            log(LogLevel.INFO, `Fetching OHLCV for ${symbol} on ${exchange}, timeframe: ${timeframe}, limit: ${limit}`);
            return await ex.fetchOHLCV(symbol, timeframe, undefined, limit);
          });
          
          return {
            content: [{
              type: "text",
              text: JSON.stringify(ohlcv, null, 2)
            }]
          };
        });
      } catch (error) {
        log(LogLevel.ERROR, `Error fetching OHLCV data: ${error instanceof Error ? error.message : String(error)}`);
        return {
          content: [{
            type: "text",
            text: `Error: ${error instanceof Error ? error.message : String(error)}`
          }],
          isError: true
        };
      }
    });
  • Zod input schema for the 'get-ohlcv' tool defining parameters: exchange, symbol, timeframe (optional, default '1d'), and limit (optional, default 100).
    exchange: z.string().describe("Exchange ID (e.g., binance, coinbase)"),
    symbol: z.string().describe("Trading pair symbol (e.g., BTC/USDT)"),
    timeframe: z.string().optional().default("1d").describe("Timeframe (e.g., 1m, 5m, 1h, 1d)"),
    limit: z.number().optional().default(100).describe("Number of candles to fetch (max 1000)")
  • Registration of the 'get-ohlcv' tool using server.tool(), including description, input schema, and inline handler function.
    server.tool("get-ohlcv", "Get OHLCV candlestick data for a trading pair", {
      exchange: z.string().describe("Exchange ID (e.g., binance, coinbase)"),
      symbol: z.string().describe("Trading pair symbol (e.g., BTC/USDT)"),
      timeframe: z.string().optional().default("1d").describe("Timeframe (e.g., 1m, 5m, 1h, 1d)"),
      limit: z.number().optional().default(100).describe("Number of candles to fetch (max 1000)")
    }, async ({ exchange, symbol, timeframe, limit }) => {
      try {
        return await rateLimiter.execute(exchange, async () => {
          const ex = getExchange(exchange);
          const cacheKey = `ohlcv:${exchange}:${symbol}:${timeframe}:${limit}`;
          
          const ohlcv = await getCachedData(cacheKey, async () => {
            log(LogLevel.INFO, `Fetching OHLCV for ${symbol} on ${exchange}, timeframe: ${timeframe}, limit: ${limit}`);
            return await ex.fetchOHLCV(symbol, timeframe, undefined, limit);
          });
          
          return {
            content: [{
              type: "text",
              text: JSON.stringify(ohlcv, null, 2)
            }]
          };
        });
      } catch (error) {
        log(LogLevel.ERROR, `Error fetching OHLCV data: ${error instanceof Error ? error.message : String(error)}`);
        return {
          content: [{
            type: "text",
            text: `Error: ${error instanceof Error ? error.message : String(error)}`
          }],
          isError: true
        };
      }
    });
  • Invocation of registerPublicTools which includes the registration of get-ohlcv among other public tools.
    registerPublicTools(server);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure but only states the basic action without details on rate limits, authentication needs, data freshness, or error handling. It fails to address key operational traits beyond the minimal purpose.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and appropriately sized, with no wasted content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of financial data retrieval, no annotations, and no output schema, the description is incomplete. It lacks details on return format, data structure, error cases, or operational constraints, making it insufficient for full contextual understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the input schema fully documents all parameters. The description adds no additional meaning beyond what's in the schema, such as examples or constraints not covered. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('OHLCV candlestick data for a trading pair'), making the purpose specific and understandable. However, it does not explicitly differentiate from sibling tools like 'get-ticker' or 'get-trades', which also retrieve market data but for different metrics, so it misses full sibling distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, such as 'get-ticker' for current prices or 'get-trades' for transaction data. It lacks context on prerequisites, exclusions, or comparisons to sibling tools, leaving usage unclear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/doggybee/mcp-server-ccxt'

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