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
| Name | Required | Description | Default |
|---|---|---|---|
| epic | Yes | Market epic code | |
| from | No | Start date/time (YYYY-MM-DDTHH:MM:SS) | |
| max | No | Maximum number of data points | |
| resolution | Yes | Time resolution | |
| to | No | End date/time (YYYY-MM-DDTHH:MM:SS) |
Implementation Reference
- src/services/ig-service.js:372-396 (handler)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; } }
- src/services/mcp-service.js:702-719 (handler)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), }, ], };
- src/services/mcp-service.js:393-420 (schema)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'], },
- src/services/mcp-service.js:390-421 (registration)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'], }, },