Skip to main content
Glama

ig_get_historical_prices

Retrieve historical market price data for specific instruments using the market epic code, time resolution, and date range. Analyze trends and make informed trading decisions with accurate historical insights.

Instructions

Get historical price data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
epicYesMarket epic code
fromNoStart date/time (YYYY-MM-DDTHH:MM:SS)
maxNoMaximum number of data points
resolutionYesTime resolution
toNoEnd date/time (YYYY-MM-DDTHH:MM:SS)

Implementation Reference

  • Core implementation of historical prices fetching via IG API endpoint /prices/{epic} with query parameters for resolution, max, pageSize, from, to.
    async getHistoricalPrices(epic, resolution, options = {}) { const { max = 10, pageSize = 20, from, to } = options; const params = new URLSearchParams({ resolution, max: max.toString(), pageSize: pageSize.toString() }); if (from) params.append('from', from); if (to) params.append('to', to); try { const response = await this.apiClient.get(`/prices/${epic}?${params}`, 3); return response.data; } catch (error) { logger.error('Failed to get historical prices:', error.message); throw error; } }
  • MCP tool execution handler that extracts arguments and delegates to igService.getHistoricalPrices, formats response as JSON text.
    case 'ig_get_historical_prices': const prices = await igService.getHistoricalPrices( args.epic, args.resolution, { max: args.max, from: args.from, to: args.to, } ); return { content: [ { type: 'text', text: JSON.stringify(prices, null, 2), }, ], };
  • Input schema defining parameters: epic (required), resolution (required, enum), max (default 10), from, to.
    inputSchema: { type: 'object', properties: { epic: { type: 'string', description: 'Market epic code', }, resolution: { type: 'string', enum: ['SECOND', 'MINUTE', 'MINUTE_2', 'MINUTE_3', 'MINUTE_5', 'MINUTE_10', 'MINUTE_15', 'MINUTE_30', 'HOUR', 'HOUR_2', 'HOUR_3', 'HOUR_4', 'DAY', 'WEEK', 'MONTH'], description: 'Time resolution', }, max: { type: 'number', description: 'Maximum number of data points', default: 10, }, from: { type: 'string', description: 'Start date/time (YYYY-MM-DDTHH:MM:SS)', }, to: { type: 'string', description: 'End date/time (YYYY-MM-DDTHH:MM:SS)', }, }, required: ['epic', 'resolution'], },
  • Tool definition in TOOLS array for registration in MCP server's listTools response.
    { name: 'ig_get_historical_prices', description: 'Get historical price data', inputSchema: { type: 'object', properties: { epic: { type: 'string', description: 'Market epic code', }, resolution: { type: 'string', enum: ['SECOND', 'MINUTE', 'MINUTE_2', 'MINUTE_3', 'MINUTE_5', 'MINUTE_10', 'MINUTE_15', 'MINUTE_30', 'HOUR', 'HOUR_2', 'HOUR_3', 'HOUR_4', 'DAY', 'WEEK', 'MONTH'], description: 'Time resolution', }, max: { type: 'number', description: 'Maximum number of data points', default: 10, }, from: { type: 'string', description: 'Start date/time (YYYY-MM-DDTHH:MM:SS)', }, to: { type: 'string', description: 'End date/time (YYYY-MM-DDTHH:MM:SS)', }, }, required: ['epic', 'resolution'], }, },

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/kea0811/ig-trading-mcp'

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